Version Notes
version 1.1.2
Download this release
Release Info
Developer | Paymentwall |
Extension | paymentwall_magento_module |
Version | 1.1.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.1.2
- app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Abstract.php +56 -0
- app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Pwbrick.php +71 -0
- app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Pwlocal.php +68 -0
- app/code/community/Paymentwall/Paymentwall/Block/Checkout/Info/Method/Pwbrick.php +23 -0
- app/code/community/Paymentwall/Paymentwall/Block/Checkout/Info/Method/Pwlocal.php +15 -0
- app/code/community/Paymentwall/Paymentwall/Helper/Data.php +10 -0
- app/code/community/Paymentwall/Paymentwall/Model/Method/Abstract.php +136 -0
- app/code/community/Paymentwall/Paymentwall/Model/Method/Pwbrick.php +107 -0
- app/code/community/Paymentwall/Paymentwall/Model/Method/Pwlocal.php +83 -0
- app/code/community/Paymentwall/Paymentwall/Model/Pingback.php +54 -0
- app/code/community/Paymentwall/Paymentwall/controllers/PaymentController.php +77 -0
- app/code/{local → community}/Paymentwall/Paymentwall/etc/config.xml +34 -16
- app/code/community/Paymentwall/Paymentwall/etc/system.xml +176 -0
- app/code/local/Paymentwall/Paymentwall/Helper/Data.php +0 -2
- app/code/local/Paymentwall/Paymentwall/Model/Payment.php +0 -14
- app/code/local/Paymentwall/Paymentwall/controllers/IndexController.php +0 -126
- app/code/local/Paymentwall/Paymentwall/etc/system.xml +0 -78
- app/design/frontend/base/default/layout/paymentwall.xml +44 -0
- app/design/frontend/base/default/template/paymentwall/checkout/form/method/pwbrick.phtml +66 -0
- app/design/frontend/base/default/template/paymentwall/checkout/form/method/pwlocal.phtml +25 -0
- app/design/frontend/base/default/template/paymentwall/checkout/info/method/pwbrick.phtml +10 -0
- app/etc/modules/Paymentwall_Paymentwall.xml +0 -14
- lib/paymentwall-php/LICENSE +20 -0
- lib/paymentwall-php/README.md +273 -0
- lib/paymentwall-php/composer.json +37 -0
- lib/paymentwall-php/features/bootstrap/ChargeContext.php +112 -0
- lib/paymentwall-php/features/bootstrap/FeatureContext.php +71 -0
- lib/paymentwall-php/features/bootstrap/PingbackContext.php +69 -0
- lib/paymentwall-php/features/bootstrap/WidgetContext.php +163 -0
- lib/paymentwall-php/features/charge.feature +23 -0
- lib/paymentwall-php/features/pingback.feature +128 -0
- lib/paymentwall-php/features/widget.feature +107 -0
- lib/paymentwall-php/lib/Paymentwall/ApiObject.php +96 -0
- lib/paymentwall-php/lib/Paymentwall/ApiObjectInterface.php +6 -0
- lib/paymentwall-php/lib/Paymentwall/Base.php +22 -0
- lib/paymentwall-php/lib/Paymentwall/Card.php +41 -0
- lib/paymentwall-php/lib/Paymentwall/Charge.php +69 -0
- lib/paymentwall-php/lib/Paymentwall/Config.php +102 -0
- lib/paymentwall-php/lib/Paymentwall/HttpAction.php +119 -0
- lib/paymentwall-php/lib/Paymentwall/Instance.php +50 -0
- lib/paymentwall-php/lib/Paymentwall/OneTimeToken.php +31 -0
- lib/paymentwall-php/lib/Paymentwall/Pingback.php +238 -0
- lib/paymentwall-php/lib/Paymentwall/Product.php +70 -0
- lib/paymentwall-php/lib/Paymentwall/Response/Abstract.php +22 -0
- lib/paymentwall-php/lib/Paymentwall/Response/Error.php +27 -0
- lib/paymentwall-php/lib/Paymentwall/Response/Factory.php +23 -0
- lib/paymentwall-php/lib/Paymentwall/Response/Interface.php +6 -0
- lib/paymentwall-php/lib/Paymentwall/Response/Success.php +17 -0
- lib/paymentwall-php/lib/Paymentwall/Signature/Abstract.php +30 -0
- lib/paymentwall-php/lib/Paymentwall/Signature/Pingback.php +39 -0
- lib/paymentwall-php/lib/Paymentwall/Signature/Widget.php +48 -0
- lib/paymentwall-php/lib/Paymentwall/Subscription.php +44 -0
- lib/paymentwall-php/lib/Paymentwall/Widget.php +154 -0
- lib/paymentwall-php/lib/paymentwall.php +51 -0
- package.xml +9 -9
- skin/frontend/base/default/css/paymentwall.css +6 -0
- skin/frontend/base/default/js/paymentwall.js +86 -0
app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Abstract.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('Paymentwall_Config'))
|
4 |
+
require_once Mage::getBaseDir('lib') . '/paymentwall-php/lib/paymentwall.php';
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
8 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
9 |
+
*
|
10 |
+
* Class Paymentwall_Paymentwall_Block_Checkout_Form_Method_Abstract
|
11 |
+
*/
|
12 |
+
class Paymentwall_Paymentwall_Block_Checkout_Form_Method_Abstract extends Mage_Payment_Block_Form
|
13 |
+
{
|
14 |
+
private $modelName;
|
15 |
+
private $paymentModel;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Get total amount of current order
|
19 |
+
* @return mixed|null
|
20 |
+
*/
|
21 |
+
public function getTotal()
|
22 |
+
{
|
23 |
+
return $this->getOrder() ? $this->getOrder()->getGrandTotal() : null;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Get currency code of current order
|
28 |
+
* @return string|null
|
29 |
+
*/
|
30 |
+
public function getOrderCurrencyCode()
|
31 |
+
{
|
32 |
+
return $this->getOrder() ? $this->getOrder()->getOrderCurrencyCode() : null;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Set payment model name
|
37 |
+
* @param $name
|
38 |
+
*/
|
39 |
+
public function setPaymentModelName($name)
|
40 |
+
{
|
41 |
+
$this->modelName = $name;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get Payment Model
|
46 |
+
* @return false|Mage_Core_Model_Abstract
|
47 |
+
*/
|
48 |
+
public function getPaymentModel()
|
49 |
+
{
|
50 |
+
if (!$this->paymentModel) {
|
51 |
+
$this->paymentModel = Mage::getModel('paymentwall/method_' . $this->modelName);
|
52 |
+
}
|
53 |
+
|
54 |
+
return $this->paymentModel;
|
55 |
+
}
|
56 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Pwbrick.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
6 |
+
*
|
7 |
+
* Class Paymentwall_Paymentwall_Block_Checkout_Form_Method_Pwbrick
|
8 |
+
*/
|
9 |
+
class Paymentwall_Paymentwall_Block_Checkout_Form_Method_Pwbrick extends Paymentwall_Paymentwall_Block_Checkout_Form_Method_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Set template for block
|
13 |
+
* @return void
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->setPaymentModelName('pwbrick');
|
19 |
+
$this->setTemplate('paymentwall/checkout/form/method/pwbrick.phtml');
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get merchant public key from configuration
|
24 |
+
* @return string|null
|
25 |
+
*/
|
26 |
+
public function getPublicKey()
|
27 |
+
{
|
28 |
+
if ($this->getPaymentModel()) {
|
29 |
+
return $this->getPaymentModel()->getConfigData('paymentwall_public_key');
|
30 |
+
}
|
31 |
+
return null;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get private key from configuration
|
36 |
+
* @return string|null
|
37 |
+
*/
|
38 |
+
public function getPrivateKey()
|
39 |
+
{
|
40 |
+
if ($this->getMethod()) {
|
41 |
+
return $this->getPaymentModel()->getConfigData('paymentwall_private_key');
|
42 |
+
}
|
43 |
+
return null;
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Retrieve payment configuration object
|
49 |
+
*
|
50 |
+
* @return Mage_Payment_Model_Config
|
51 |
+
*/
|
52 |
+
protected function _getConfig()
|
53 |
+
{
|
54 |
+
return Mage::getSingleton('payment/config');
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Retrieve availables credit card types
|
59 |
+
*
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
public function getCcAvailableTypes()
|
63 |
+
{
|
64 |
+
$type = $this->_getConfig()->getCcTypes();
|
65 |
+
unset($type['OT']);
|
66 |
+
unset($type['SM']);
|
67 |
+
unset($type['SO']);
|
68 |
+
return $type;
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Pwlocal.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
6 |
+
*
|
7 |
+
* Class Paymentwall_Paymentwall_Block_Checkout_Form_Method_Local
|
8 |
+
*/
|
9 |
+
class Paymentwall_Paymentwall_Block_Checkout_Form_Method_Pwlocal extends Paymentwall_Paymentwall_Block_Checkout_Form_Method_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Set template for block
|
13 |
+
* @return void
|
14 |
+
*/
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->setPaymentModelName('pwlocal');
|
19 |
+
}
|
20 |
+
|
21 |
+
function getWidget()
|
22 |
+
{
|
23 |
+
$order = $this->getOrder();
|
24 |
+
$return = array(
|
25 |
+
'content' => '',
|
26 |
+
'status' => false
|
27 |
+
);
|
28 |
+
|
29 |
+
if ($order) {
|
30 |
+
try {
|
31 |
+
$model = $this->getPaymentModel();
|
32 |
+
$widget = $model->getPaymentWidget($order);
|
33 |
+
|
34 |
+
// Get widget iframe
|
35 |
+
$return['content'] = $widget->getHtmlCode(array(
|
36 |
+
'frameborder' => '0',
|
37 |
+
'width' => '100%',
|
38 |
+
'height' => '600'
|
39 |
+
));
|
40 |
+
$return['status'] = true;
|
41 |
+
} catch (Exception $e) {
|
42 |
+
Mage::logException($e);
|
43 |
+
$return['content'] = Mage::helper('paymentwall')->__('Errors, Please try again!');
|
44 |
+
}
|
45 |
+
} else {
|
46 |
+
$return['content'] = Mage::helper('paymentwall')->__('Order invalid'); //should redirect back to homepage
|
47 |
+
}
|
48 |
+
|
49 |
+
return $return;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Get last order
|
54 |
+
*/
|
55 |
+
protected function getOrder()
|
56 |
+
{
|
57 |
+
if (!$this->_order) {
|
58 |
+
$session = Mage::getSingleton('checkout/session');
|
59 |
+
$this->_order = $this->loadOrderById($session->getLastRealOrderId());
|
60 |
+
}
|
61 |
+
return $this->_order;
|
62 |
+
}
|
63 |
+
|
64 |
+
protected function loadOrderById($orderId)
|
65 |
+
{
|
66 |
+
return Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
67 |
+
}
|
68 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Block/Checkout/Info/Method/Pwbrick.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
6 |
+
*
|
7 |
+
* Class Paymentwall_Paymentwall_Block_Checkout_Info_Method_Pwbrick
|
8 |
+
*/
|
9 |
+
class Paymentwall_Paymentwall_Block_Checkout_Info_Method_Pwbrick extends Mage_Payment_Block_Info
|
10 |
+
{
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
parent::_construct();
|
14 |
+
$this->setTemplate('paymentwall/checkout/info/method/pwbrick.phtml');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function setInfo($info)
|
18 |
+
{
|
19 |
+
$this->setData('info', $info);
|
20 |
+
$this->setData('method', $info->getMethodInstance());
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Block/Checkout/Info/Method/Pwlocal.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
6 |
+
*
|
7 |
+
* Class Paymentwall_Paymentwall_Block_Checkout_Info_Method_Local
|
8 |
+
*/
|
9 |
+
class Paymentwall_Paymentwall_Block_Checkout_Info_Method_Pwlocal extends Mage_Payment_Block_Info
|
10 |
+
{
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
parent::_construct();
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Helper/Data.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
6 |
+
*/
|
7 |
+
class Paymentwall_Paymentwall_Helper_Data extends Mage_Core_Helper_Abstract
|
8 |
+
{
|
9 |
+
|
10 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Abstract.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('Paymentwall_Config'))
|
4 |
+
require_once Mage::getBaseDir('lib') . '/paymentwall-php/lib/paymentwall.php';
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
8 |
+
* @package Paymentwall_Paymentwall
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class Paymentwall_Paymentwall_Model_Method_Abstract
|
13 |
+
*/
|
14 |
+
class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_Method_Abstract
|
15 |
+
{
|
16 |
+
protected $_code;
|
17 |
+
protected $_logFile = 'paymentwall.log';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param string $code
|
21 |
+
*/
|
22 |
+
public function __construct($code = '')
|
23 |
+
{
|
24 |
+
if ($code) {
|
25 |
+
$this->_code = 'paymentwall_' . $code;
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->_formBlockType = 'paymentwall/checkout_form_method_' . $code;
|
29 |
+
$this->_infoBlockType = 'paymentwall/checkout_info_method_' . $code;
|
30 |
+
$this->setData('original_code', $code);
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Process pending payment
|
36 |
+
* @param Paymentwall_Pingback $pingback
|
37 |
+
* @throws Exception
|
38 |
+
* @return void
|
39 |
+
*/
|
40 |
+
public function processPendingPayment(Paymentwall_Pingback $pingback)
|
41 |
+
{
|
42 |
+
$order = $this->getCurrentOrder();
|
43 |
+
if ($order->getState() === Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW || $order->getState() === Mage_Sales_Model_Order::STATE_NEW) {
|
44 |
+
if ($pingback->isDeliverable()) {
|
45 |
+
$this->makeInvoice();
|
46 |
+
} elseif ($pingback->isCancelable()) {
|
47 |
+
$reason = $pingback->getParameter('reason');
|
48 |
+
$order->setState(
|
49 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
50 |
+
$reason == self::REASON_ORDER_FRAUD || $reason == self::REASON_CC_FRAUD ? Mage_Sales_Model_Order::STATUS_FRAUD : true
|
51 |
+
);
|
52 |
+
$order->save();
|
53 |
+
}
|
54 |
+
} else {
|
55 |
+
$incrementId = $order->getIncrementId();
|
56 |
+
throw new Exception("This order {$incrementId} is not put in PENDING REVIEW STATE", 1);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Init paymentwall configs
|
62 |
+
*/
|
63 |
+
public function initPaymentwallConfig()
|
64 |
+
{
|
65 |
+
Paymentwall_Config::getInstance()->set(array(
|
66 |
+
'api_type' => Paymentwall_Config::API_GOODS,
|
67 |
+
'public_key' => $this->getConfigData('paymentwall_public_key'),
|
68 |
+
'private_key' => $this->getConfigData('paymentwall_private_key')
|
69 |
+
));
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getMethodCode()
|
73 |
+
{
|
74 |
+
return $this->_code;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param $order
|
79 |
+
* @return array
|
80 |
+
*/
|
81 |
+
protected function prepareUserProfile($order)
|
82 |
+
{
|
83 |
+
$billing = $order->getBillingAddress();
|
84 |
+
$data = array(
|
85 |
+
'customer[city]' => $billing->getCity(),
|
86 |
+
'customer[state]' => $billing->getRegion(),
|
87 |
+
'customer[address]' => $billing->getStreetFull(),
|
88 |
+
'customer[country]' => $billing->getCountry(),
|
89 |
+
'customer[zip]' => $billing->getPostcode(),
|
90 |
+
);
|
91 |
+
|
92 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
93 |
+
// Load the customer's data
|
94 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
95 |
+
$data = array_merge($data, array(
|
96 |
+
'customer[birthday]' => $customer->getDob() ? strtotime($customer->getDob()) : '',
|
97 |
+
'customer[sex]' => $customer->getGender() ? $customer->getGender() : '',
|
98 |
+
'customer[username]' => $customer->getEntityId(),
|
99 |
+
'customer[firstname]' => $customer->getFirstname(),
|
100 |
+
'customer[lastname]' => $customer->getLastname(),
|
101 |
+
'email' => $customer->getEmail(),
|
102 |
+
'history[registration_email]' => $customer->getEmail(),
|
103 |
+
'history[registration_email_verified]' => $customer->getIsActive(),
|
104 |
+
'history[registration_date]' => $customer->getCreatedAtTimestamp(),
|
105 |
+
));
|
106 |
+
} else {
|
107 |
+
$data = array_merge($data, array(
|
108 |
+
'customer[username]' => $billing->getCustomerEmail(),
|
109 |
+
'customer[firstname]' => $billing->getFirstname(),
|
110 |
+
'customer[lastname]' => $billing->getLastname(),
|
111 |
+
'email' => $billing->getEmail()
|
112 |
+
));
|
113 |
+
}
|
114 |
+
|
115 |
+
return $data;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Log Function
|
120 |
+
* @param $message
|
121 |
+
*/
|
122 |
+
public function log($message, $section = '')
|
123 |
+
{
|
124 |
+
if ($this->getConfigData('debug_mode')) {
|
125 |
+
if (!is_string($message)) {
|
126 |
+
$message = var_export($message, true);
|
127 |
+
}
|
128 |
+
$message = "\n/********** " . $this->getCode() . ($section ? " " . $section : "") . " **********/\n" . $message;
|
129 |
+
Mage::log($message, null, $this->_logFile);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Pwbrick.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall_Paymentwall
|
6 |
+
*
|
7 |
+
* Class Paymentwall_Paymentwall_Model_Method_Pwbrick
|
8 |
+
*/
|
9 |
+
class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwall_Model_Method_Abstract
|
10 |
+
{
|
11 |
+
protected $_isInitializeNeeded = false;
|
12 |
+
protected $_canUseInternal = false;
|
13 |
+
protected $_canUseForMultishipping = false;
|
14 |
+
protected $_canCapture = true;
|
15 |
+
protected $_canAuthorize = true;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Constructor method.
|
19 |
+
* Set some internal properties
|
20 |
+
*/
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
parent::__construct('pwbrick');
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Prepare data for payment
|
28 |
+
* @param $payment
|
29 |
+
* @return $this
|
30 |
+
*/
|
31 |
+
public function prepareCardInfo($payment)
|
32 |
+
{
|
33 |
+
$order = $payment->getOrder();
|
34 |
+
$info = $this->getInfoInstance();
|
35 |
+
$this->setCurrentOrder($order);
|
36 |
+
return array(
|
37 |
+
'email' => $order->getBillingAddress()->getEmail(),
|
38 |
+
'amount' => $order->getGrandTotal(),
|
39 |
+
'currency' => $order->getOrderCurrencyCode(),
|
40 |
+
'token' => $info->getAdditionalInformation('brick_token'),
|
41 |
+
'fingerprint' => $info->getAdditionalInformation('brick_fingerprint'),
|
42 |
+
'description' => 'Order #' . $order->getIncrementId(),
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param $data
|
48 |
+
* @return mixed
|
49 |
+
*/
|
50 |
+
public function assignData($data)
|
51 |
+
{
|
52 |
+
if (!($data instanceof Varien_Object)) {
|
53 |
+
$data = new Varien_Object($data);
|
54 |
+
}
|
55 |
+
|
56 |
+
$info = $this->getInfoInstance();
|
57 |
+
$info->setCcType($data->getCcType())
|
58 |
+
->setCcOwner($data->getCcOwner())
|
59 |
+
->setCcLast4(substr($data->getCcNumber(), -4))
|
60 |
+
->setCcNumber($data->getCcNumber())
|
61 |
+
->setCcCid($data->getCcCid())
|
62 |
+
->setCcExpMonth($data->getCcExpMonth())
|
63 |
+
->setCcExpYear($data->getCcExpYear())
|
64 |
+
|
65 |
+
->setAdditionalInformation('brick_token', $data->getBrickToken())
|
66 |
+
->setAdditionalInformation('brick_fingerprint', $data->getBrickFingerprint());
|
67 |
+
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @param $payment
|
73 |
+
* @param Varien_Object $amount
|
74 |
+
* @return Mage_Payment_Model_Abstract|void
|
75 |
+
* @throws Mage_Core_Exception
|
76 |
+
*/
|
77 |
+
public function capture(Varien_Object $payment, $amount)
|
78 |
+
{
|
79 |
+
$this->initPaymentwallConfig();
|
80 |
+
$charge = new Paymentwall_Charge();
|
81 |
+
$charge->create(array_merge(
|
82 |
+
$this->prepareUserProfile($payment->getOrder()), // for User Profile API
|
83 |
+
$this->prepareCardInfo($payment)
|
84 |
+
));
|
85 |
+
$response = $charge->getPublicData();
|
86 |
+
|
87 |
+
// Debug
|
88 |
+
$this->log($response, 'Charge response');
|
89 |
+
|
90 |
+
if ($charge->isSuccessful()) {
|
91 |
+
if ($charge->isCaptured()) {
|
92 |
+
// deliver a product
|
93 |
+
|
94 |
+
} elseif ($charge->isUnderReview()) {
|
95 |
+
$payment->setIsTransactionPending(true);
|
96 |
+
}
|
97 |
+
} else {
|
98 |
+
$payment->setIsTransactionPending(true)
|
99 |
+
->setIsFraudDetected(true);
|
100 |
+
$errors = json_decode($response, true);
|
101 |
+
$this->log($errors, 'Charge error response');
|
102 |
+
$strErrors = Mage::helper('paymentwall')->__("Brick error(s):");
|
103 |
+
$strErrors .= "\n - Code #{$errors['error']['code']}: " . Mage::helper('paymentwall')->__($errors['error']['message']);
|
104 |
+
Mage::throwException($strErrors);
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Pwlocal.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento\Model\Method
|
6 |
+
*/
|
7 |
+
class Paymentwall_Paymentwall_Model_Method_Pwlocal extends Paymentwall_Paymentwall_Model_Method_Abstract
|
8 |
+
{
|
9 |
+
protected $_isGateway = true;
|
10 |
+
protected $_canUseInternal = false;
|
11 |
+
protected $_canUseForMultishipping = false;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Constructor method.
|
15 |
+
* Set some internal properties
|
16 |
+
*/
|
17 |
+
public function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct('pwlocal');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getOrderPlaceRedirectUrl()
|
23 |
+
{
|
24 |
+
return Mage::getUrl('paymentwall/payment/pwlocal', array('_secure' => true));
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Make invoice for paid order
|
29 |
+
* @return void
|
30 |
+
*/
|
31 |
+
protected function makeInvoice()
|
32 |
+
{
|
33 |
+
$order = $this->getCurrentOrder();
|
34 |
+
if ($order) {
|
35 |
+
$invoice = $order->prepareInvoice()
|
36 |
+
->setTransactionId($order->getId())
|
37 |
+
->addComment("Invoice created by Paymentwall Brick")
|
38 |
+
->register()
|
39 |
+
->pay();
|
40 |
+
|
41 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
42 |
+
->addObject($invoice)
|
43 |
+
->addObject($invoice->getOrder());
|
44 |
+
$transactionSave->save();
|
45 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Generate Paymentwall Widget
|
51 |
+
* @param $order
|
52 |
+
* @return Paymentwall_Widget
|
53 |
+
*/
|
54 |
+
public function getPaymentWidget($order)
|
55 |
+
{
|
56 |
+
$this->initPaymentwallConfig();
|
57 |
+
|
58 |
+
$widget = new Paymentwall_Widget(
|
59 |
+
$order->getCustomerEmail(),
|
60 |
+
$this->getConfigData('paymentwall_widget_code'),
|
61 |
+
array(
|
62 |
+
new Paymentwall_Product(
|
63 |
+
$order->getIncrementId(),
|
64 |
+
$order->getGrandTotal(),
|
65 |
+
$order->getOrderCurrencyCode(),
|
66 |
+
'Order id #' . $order->getIncrementId(),
|
67 |
+
Paymentwall_Product::TYPE_FIXED
|
68 |
+
)
|
69 |
+
),
|
70 |
+
array_merge(
|
71 |
+
array(
|
72 |
+
'email' => $order->getCustomerEmail(),
|
73 |
+
'success_url' => $this->getConfigData('paymentwall_url'),
|
74 |
+
'test_mode' => (int)$this->getConfigData('paymentwall_istest'),
|
75 |
+
'integration_module' => 'magento'
|
76 |
+
),
|
77 |
+
$this->prepareUserProfile($order) // for User Profile API
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
return $widget;
|
82 |
+
}
|
83 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Model/Pingback.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('Paymentwall_Config'))
|
4 |
+
require_once Mage::getBaseDir('lib') . '/paymentwall-php/lib/paymentwall.php';
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @author Paymentwall Inc <devsupport@paymentwall.com>
|
8 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
9 |
+
*/
|
10 |
+
class Paymentwall_Paymentwall_Model_Pingback extends Mage_Core_Model_Abstract
|
11 |
+
{
|
12 |
+
const DEFAULT_PINGBACK_RESPONSE = 'OK';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Handle pingback
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public function handlePingback()
|
19 |
+
{
|
20 |
+
// Load paymentwall configs
|
21 |
+
Mage::getModel('paymentwall/method_pwlocal')->initPaymentwallConfig();
|
22 |
+
|
23 |
+
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
24 |
+
|
25 |
+
if ($pingback->validate(true)) {
|
26 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($pingback->getProductId());
|
27 |
+
if ($order->getId()) {
|
28 |
+
try {
|
29 |
+
if ($pingback->isDeliverable()) {
|
30 |
+
$paymentModel = $order->getPayment()->getMethodInstance();
|
31 |
+
$paymentModel->setCurrentOrder($order)->processPendingPayment($pingback);
|
32 |
+
$result = self::DEFAULT_PINGBACK_RESPONSE;
|
33 |
+
} elseif ($pingback->isCancelable()) {
|
34 |
+
$order->registerCancellation(Mage::helper('sales')->__('Order marked as cancelled by Paymentwall.'))
|
35 |
+
->save();
|
36 |
+
$result = Mage::helper('sales')->__('Order marked as cancelled by Paymentwall.');
|
37 |
+
}
|
38 |
+
} catch (Exception $e) {
|
39 |
+
Mage::log($e->getMessage());
|
40 |
+
$result = 'Internal server error';
|
41 |
+
$result .= ' ' . $e->getMessage();
|
42 |
+
}
|
43 |
+
} else {
|
44 |
+
$result = 'Invalid order';
|
45 |
+
}
|
46 |
+
} else {
|
47 |
+
$result = $pingback->getErrorSummary();
|
48 |
+
}
|
49 |
+
|
50 |
+
return $result;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
}
|
app/code/community/Paymentwall/Paymentwall/controllers/PaymentController.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author Paymentwall Inc. <devsupport@paymentwall.com>
|
5 |
+
* @package Paymentwall\ThirdpartyIntegration\Magento
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Paymentwall_Payment_PaymentController
|
10 |
+
*/
|
11 |
+
class Paymentwall_Paymentwall_PaymentController extends Mage_Core_Controller_Front_Action
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Action that handles pingback call from paymentwall system
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public function ipnAction()
|
19 |
+
{
|
20 |
+
$result = Mage::getModel('paymentwall/pingback')->handlePingback();
|
21 |
+
die($result);
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Show Paymentwall widget
|
26 |
+
* For Pw Local
|
27 |
+
*/
|
28 |
+
public function pwlocalAction()
|
29 |
+
{
|
30 |
+
$this->loadLayout();
|
31 |
+
$this->renderLayout();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Handle ajax payment listener on Widget page
|
36 |
+
* For Pw Local
|
37 |
+
*/
|
38 |
+
public function ajaxPwlocalAction()
|
39 |
+
{
|
40 |
+
// Get current order id
|
41 |
+
$curOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
42 |
+
$response = array(
|
43 |
+
'status' => 0,
|
44 |
+
'url' => '',
|
45 |
+
'message' => ''
|
46 |
+
);
|
47 |
+
|
48 |
+
if ($curOrderId) {
|
49 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($curOrderId);
|
50 |
+
if ($order->getId()) {
|
51 |
+
|
52 |
+
if ($response['status'] = $order->getStatus() == Mage_Sales_Model_Order::STATE_PROCESSING
|
53 |
+
|| $order->getStatus() == Mage_Sales_Model_Order::STATE_CANCELED
|
54 |
+
) {
|
55 |
+
$response['status'] = 1;
|
56 |
+
$response['message'] = $order->getStatus() == Mage_Sales_Model_Order::STATE_CANCELED
|
57 |
+
? "<h3>{$this->__("Payment Canceled")}</h3>"
|
58 |
+
: "<h3>{$this->__("Payment Processed")}</h3>";
|
59 |
+
|
60 |
+
// Clear shopping cart
|
61 |
+
Mage::getSingleton('checkout/cart')->truncate();
|
62 |
+
|
63 |
+
} else {
|
64 |
+
$response['status'] = 0;
|
65 |
+
}
|
66 |
+
// Get success page redirect url
|
67 |
+
$response['url'] = '';
|
68 |
+
} else {
|
69 |
+
$response['status'] = 2; // Error
|
70 |
+
$response['message'] = 'Order Invalid';
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
|
75 |
+
$this->getResponse()->setBody(json_encode($response));
|
76 |
+
}
|
77 |
+
}
|
app/code/{local → community}/Paymentwall/Paymentwall/etc/config.xml
RENAMED
@@ -2,9 +2,27 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Paymentwall_Paymentwall>
|
5 |
-
<version>1.
|
6 |
</Paymentwall_Paymentwall>
|
7 |
</modules>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
<global>
|
9 |
<models>
|
10 |
<paymentwall>
|
@@ -24,25 +42,25 @@
|
|
24 |
</global>
|
25 |
<default>
|
26 |
<payment>
|
27 |
-
<
|
|
|
28 |
<active>1</active>
|
29 |
-
<model>paymentwall/
|
30 |
<order_status>pending_payment</order_status>
|
31 |
-
<title>Paymentwall</title>
|
32 |
<fee_payer>buyer</fee_payer>
|
33 |
<allowspecific>0</allowspecific>
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
</payment>
|
36 |
</default>
|
37 |
-
<frontend>
|
38 |
-
<routers>
|
39 |
-
<paymentwall>
|
40 |
-
<use>standard</use>
|
41 |
-
<args>
|
42 |
-
<module>Paymentwall_Paymentwall</module>
|
43 |
-
<frontName>paymentwall</frontName>
|
44 |
-
</args>
|
45 |
-
</paymentwall>
|
46 |
-
</routers>
|
47 |
-
</frontend>
|
48 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Paymentwall_Paymentwall>
|
5 |
+
<version>1.1.2</version>
|
6 |
</Paymentwall_Paymentwall>
|
7 |
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<paymentwall>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Paymentwall_Paymentwall</module>
|
14 |
+
<frontName>paymentwall</frontName>
|
15 |
+
</args>
|
16 |
+
</paymentwall>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<paymentwall>
|
21 |
+
<file>paymentwall.xml</file>
|
22 |
+
</paymentwall>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
<global>
|
27 |
<models>
|
28 |
<paymentwall>
|
42 |
</global>
|
43 |
<default>
|
44 |
<payment>
|
45 |
+
<paymentwall_pwlocal>
|
46 |
+
<title>Paymentwall</title>
|
47 |
<active>1</active>
|
48 |
+
<model>paymentwall/method_pwlocal</model>
|
49 |
<order_status>pending_payment</order_status>
|
|
|
50 |
<fee_payer>buyer</fee_payer>
|
51 |
<allowspecific>0</allowspecific>
|
52 |
+
<paymentwall_istest>0</paymentwall_istest>
|
53 |
+
<debug_mode>0</debug_mode>
|
54 |
+
</paymentwall_pwlocal>
|
55 |
+
<paymentwall_pwbrick>
|
56 |
+
<title>Credit Card</title>
|
57 |
+
<model>paymentwall/method_pwbrick</model>
|
58 |
+
<active>1</active>
|
59 |
+
<order_status>processing</order_status>
|
60 |
+
<payment_action>authorize_capture</payment_action>
|
61 |
+
<allowspecific>0</allowspecific>
|
62 |
+
<debug_mode>0</debug_mode>
|
63 |
+
</paymentwall_pwbrick>
|
64 |
</payment>
|
65 |
</default>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
</config>
|
app/code/community/Paymentwall/Paymentwall/etc/system.xml
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<paymentwall_pwlocal translate="label" module="paymentwall">
|
7 |
+
<label>Paymentwall</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>103</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<active translate="label">
|
15 |
+
<label>Enabled</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>0</show_in_store>
|
22 |
+
</active>
|
23 |
+
<title translate="label">
|
24 |
+
<label>Title</label>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>2</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>1</show_in_store>
|
30 |
+
</title>
|
31 |
+
<paymentwall_public_key translate="label">
|
32 |
+
<label>Project Key</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>3</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
</paymentwall_public_key>
|
39 |
+
<paymentwall_private_key translate="label">
|
40 |
+
<label>Secret Key</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
<sort_order>4</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
</paymentwall_private_key>
|
47 |
+
<paymentwall_widget_code translate="label">
|
48 |
+
<label>Widget Code</label>
|
49 |
+
<frontend_type>text</frontend_type>
|
50 |
+
<sort_order>5</sort_order>
|
51 |
+
<show_in_default>1</show_in_default>
|
52 |
+
<show_in_website>1</show_in_website>
|
53 |
+
<show_in_store>1</show_in_store>
|
54 |
+
</paymentwall_widget_code>
|
55 |
+
<paymentwall_url translate="label">
|
56 |
+
<label>Success URL</label>
|
57 |
+
<frontend_type>text</frontend_type>
|
58 |
+
<sort_order>6</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>1</show_in_website>
|
61 |
+
<show_in_store>0</show_in_store>
|
62 |
+
</paymentwall_url>
|
63 |
+
<paymentwall_delivery translate="label">
|
64 |
+
<label>Enable Delivery Confirmation API</label>
|
65 |
+
<frontend_type>select</frontend_type>
|
66 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
67 |
+
<sort_order>6</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>0</show_in_store>
|
71 |
+
</paymentwall_delivery>
|
72 |
+
<paymentwall_istest translate="label">
|
73 |
+
<label>Test Mode</label>
|
74 |
+
<frontend_type>select</frontend_type>
|
75 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
76 |
+
<sort_order>7</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>0</show_in_store>
|
80 |
+
</paymentwall_istest>
|
81 |
+
<debug_mode translate="label">
|
82 |
+
<label>Debug Mode</label>
|
83 |
+
<frontend_type>select</frontend_type>
|
84 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
85 |
+
<sort_order>10</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>0</show_in_store>
|
89 |
+
</debug_mode>
|
90 |
+
</fields>
|
91 |
+
</paymentwall_pwlocal>
|
92 |
+
<paymentwall_pwbrick translate="label" module="paymentwall">
|
93 |
+
<label>Paymentwall Brick</label>
|
94 |
+
<frontend_type>text</frontend_type>
|
95 |
+
<sort_order>104</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>1</show_in_store>
|
99 |
+
<fields>
|
100 |
+
<active translate="label">
|
101 |
+
<label>Enabled</label>
|
102 |
+
<frontend_type>select</frontend_type>
|
103 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
104 |
+
<sort_order>10</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>0</show_in_store>
|
108 |
+
</active>
|
109 |
+
<title translate="label">
|
110 |
+
<label>Title</label>
|
111 |
+
<frontend_type>text</frontend_type>
|
112 |
+
<sort_order>20</sort_order>
|
113 |
+
<show_in_default>1</show_in_default>
|
114 |
+
<show_in_website>1</show_in_website>
|
115 |
+
<show_in_store>1</show_in_store>
|
116 |
+
</title>
|
117 |
+
<order_status translate="label">
|
118 |
+
<label>New order status</label>
|
119 |
+
<frontend_type>select</frontend_type>
|
120 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
121 |
+
<sort_order>21</sort_order>
|
122 |
+
<show_in_default>1</show_in_default>
|
123 |
+
<show_in_website>1</show_in_website>
|
124 |
+
<show_in_store>1</show_in_store>
|
125 |
+
</order_status>
|
126 |
+
<paymentwall_public_key translate="label">
|
127 |
+
<label>Public Key</label>
|
128 |
+
<frontend_type>text</frontend_type>
|
129 |
+
<comment>Merchant Public API Key</comment>
|
130 |
+
<sort_order>30</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>1</show_in_website>
|
133 |
+
<show_in_store>1</show_in_store>
|
134 |
+
</paymentwall_public_key>
|
135 |
+
<paymentwall_private_key translate="label">
|
136 |
+
<label>Private Key</label>
|
137 |
+
<frontend_type>text</frontend_type>
|
138 |
+
<comment>Merchant Private Key</comment>
|
139 |
+
<sort_order>40</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>1</show_in_website>
|
142 |
+
<show_in_store>1</show_in_store>
|
143 |
+
</paymentwall_private_key>
|
144 |
+
<allowspecific translate="label">
|
145 |
+
<label>Payment Applicable From</label>
|
146 |
+
<frontend_type>select</frontend_type>
|
147 |
+
<sort_order>50</sort_order>
|
148 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
149 |
+
<show_in_default>1</show_in_default>
|
150 |
+
<show_in_website>1</show_in_website>
|
151 |
+
<show_in_store>0</show_in_store>
|
152 |
+
</allowspecific>
|
153 |
+
<paymentwall_delivery translate="label">
|
154 |
+
<label>Enable Delivery Confirmation API</label>
|
155 |
+
<frontend_type>select</frontend_type>
|
156 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
157 |
+
<sort_order>51</sort_order>
|
158 |
+
<show_in_default>1</show_in_default>
|
159 |
+
<show_in_website>1</show_in_website>
|
160 |
+
<show_in_store>0</show_in_store>
|
161 |
+
</paymentwall_delivery>
|
162 |
+
<debug_mode translate="label">
|
163 |
+
<label>Debug Mode</label>
|
164 |
+
<frontend_type>select</frontend_type>
|
165 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
166 |
+
<sort_order>60</sort_order>
|
167 |
+
<show_in_default>1</show_in_default>
|
168 |
+
<show_in_website>1</show_in_website>
|
169 |
+
<show_in_store>0</show_in_store>
|
170 |
+
</debug_mode>
|
171 |
+
</fields>
|
172 |
+
</paymentwall_pwbrick>
|
173 |
+
</groups>
|
174 |
+
</payment>
|
175 |
+
</sections>
|
176 |
+
</config>
|
app/code/local/Paymentwall/Paymentwall/Helper/Data.php
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Paymentwall_Paymentwall_Helper_Data extends Mage_Core_Helper_Abstract {}
|
|
|
|
app/code/local/Paymentwall/Paymentwall/Model/Payment.php
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Paymentwall_Paymentwall_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
3 |
-
{
|
4 |
-
protected $_isGateway = true;
|
5 |
-
protected $_canUseInternal = false;
|
6 |
-
protected $_canUseForMultishipping = false;
|
7 |
-
|
8 |
-
protected $_code = 'paymentwall';
|
9 |
-
|
10 |
-
public function getOrderPlaceRedirectUrl()
|
11 |
-
{
|
12 |
-
return Mage::getUrl('paymentwall/index/redirect', array('_secure' => true));
|
13 |
-
}
|
14 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Paymentwall/Paymentwall/controllers/IndexController.php
DELETED
@@ -1,126 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Paymentwall
|
4 |
-
* @package Paymentwall_Paymentwall
|
5 |
-
* @copyright Copyright (c) 2010 - 2013 Paymentwall (http://www.paymentwall.com)
|
6 |
-
*/
|
7 |
-
|
8 |
-
DEFINE('SECRET', Mage::getStoreConfig('payment/paymentwall/paymentwall_secret')); //Secret Key
|
9 |
-
//is set using graphical interface
|
10 |
-
DEFINE('APPKEY', Mage::getStoreConfig('payment/paymentwall/paymentwall_shop_id')); //Application Key
|
11 |
-
|
12 |
-
class Paymentwall_Paymentwall_IndexController extends Mage_Core_Controller_Front_Action
|
13 |
-
{
|
14 |
-
public function updateOrderState($type, $reason)
|
15 |
-
{
|
16 |
-
$order = $this->getOrder();
|
17 |
-
if($type == "positive") {
|
18 |
-
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_COMPLETE);
|
19 |
-
} else { //chargeback
|
20 |
-
if(($reason == 2) || ($reason == 3)) {
|
21 |
-
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATUS_FRAUD);
|
22 |
-
} else {
|
23 |
-
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_CANCELED);
|
24 |
-
}
|
25 |
-
}
|
26 |
-
|
27 |
-
$order->save();
|
28 |
-
return true;
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
private function loadOrderById($orderId)
|
33 |
-
{
|
34 |
-
return Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getOrder()
|
38 |
-
{
|
39 |
-
if (!$this->_order) {
|
40 |
-
$session = Mage::getSingleton('checkout/session');
|
41 |
-
$this->_order = $this->loadOrderById($session->getLastRealOrderId());
|
42 |
-
}
|
43 |
-
return $this->_order;
|
44 |
-
}
|
45 |
-
|
46 |
-
function checkResponse($response) {
|
47 |
-
return preg_match('/^[a-z0-9]{32}$/', $response);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function redirectAction()
|
51 |
-
{
|
52 |
-
require 'lib/paymentwall.php';
|
53 |
-
Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
|
54 |
-
Paymentwall_Base::setAppKey(APPKEY); // available in your Paymentwall merchant area
|
55 |
-
Paymentwall_Base::setSecretKey(SECRET); // available in your Paymentwall merchant area
|
56 |
-
|
57 |
-
$order = $this->getOrder();
|
58 |
-
|
59 |
-
$widget = new Paymentwall_Widget(
|
60 |
-
$order->getCustomerEmail(), // id of the end-user who's making the payment
|
61 |
-
Mage::getStoreConfig('payment/paymentwall/paymentwall_widget_code'), // widget code, e.g. p1; can be picked inside of your merchant account
|
62 |
-
array( // product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty
|
63 |
-
new Paymentwall_Product(
|
64 |
-
$order->getIncrementId(),
|
65 |
-
$order->getGrandTotal(),
|
66 |
-
$order->getOrderCurrencyCode(),
|
67 |
-
'Order id #' . $order->getIncrementId(),
|
68 |
-
Paymentwall_Product::TYPE_FIXED
|
69 |
-
)
|
70 |
-
),
|
71 |
-
array(
|
72 |
-
'email' => $order->getCustomerEmail(),
|
73 |
-
'success_url' => Mage::getStoreConfig('payment/paymentwall/paymentwall_url'),
|
74 |
-
'test_mode' => Mage::getStoreConfig('payment/paymentwall/paymentwall_istest')
|
75 |
-
) // additional parameters
|
76 |
-
);
|
77 |
-
echo $widget->getHtmlCode();
|
78 |
-
}
|
79 |
-
|
80 |
-
public function ipnAction()
|
81 |
-
{
|
82 |
-
require 'lib/paymentwall.php';
|
83 |
-
Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
|
84 |
-
Paymentwall_Base::setAppKey(APPKEY); // available in your Paymentwall merchant area
|
85 |
-
Paymentwall_Base::setSecretKey(SECRET); // available in your Paymentwall merchant area
|
86 |
-
|
87 |
-
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
88 |
-
|
89 |
-
$reason = $pingback->getParameter('reason');
|
90 |
-
|
91 |
-
$productId = $pingback->getProductId();
|
92 |
-
$order = $this->loadOrderById($productId);
|
93 |
-
$this->_order = $order;
|
94 |
-
if($order) {
|
95 |
-
if ($pingback->validate()) {
|
96 |
-
if ($pingback->isDeliverable()) {
|
97 |
-
$this->updateOrderState("positive", $reason);
|
98 |
-
} else if ($pingback->isCancelable()) {
|
99 |
-
$this->updateOrderState("negative", $reason);
|
100 |
-
}
|
101 |
-
|
102 |
-
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
103 |
-
} else {
|
104 |
-
echo $pingback->getErrorSummary();
|
105 |
-
}
|
106 |
-
} else {
|
107 |
-
echo 'Order not found!';
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
public function confirmNotification()
|
112 |
-
{
|
113 |
-
return "OK";
|
114 |
-
}
|
115 |
-
|
116 |
-
private function successfulPayment(){
|
117 |
-
$message = '
|
118 |
-
You should now receive an email with the link to the widget!
|
119 |
-
<br />
|
120 |
-
In case you have not got an email, please check your spam folder.
|
121 |
-
';
|
122 |
-
|
123 |
-
return $message;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Paymentwall/Paymentwall/etc/system.xml
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<payment>
|
5 |
-
<groups>
|
6 |
-
<paymentwall translate="label" module="paymentwall">
|
7 |
-
<label>Paymentwall</label>
|
8 |
-
<frontend_type>text</frontend_type>
|
9 |
-
<sort_order>103</sort_order>
|
10 |
-
<show_in_default>1</show_in_default>
|
11 |
-
<show_in_website>1</show_in_website>
|
12 |
-
<show_in_store>0</show_in_store>
|
13 |
-
<fields>
|
14 |
-
<active translate="label">
|
15 |
-
<label>Enabled</label>
|
16 |
-
<frontend_type>select</frontend_type>
|
17 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
-
<sort_order>1</sort_order>
|
19 |
-
<show_in_default>1</show_in_default>
|
20 |
-
<show_in_website>1</show_in_website>
|
21 |
-
<show_in_store>0</show_in_store>
|
22 |
-
</active>
|
23 |
-
<title translate="label">
|
24 |
-
<label>Title</label>
|
25 |
-
<frontend_type>text</frontend_type>
|
26 |
-
<sort_order>2</sort_order>
|
27 |
-
<show_in_default>1</show_in_default>
|
28 |
-
<show_in_website>1</show_in_website>
|
29 |
-
<show_in_store>1</show_in_store>
|
30 |
-
</title>
|
31 |
-
<paymentwall_shop_id translate="label">
|
32 |
-
<label>App ID</label>
|
33 |
-
<frontend_type>text</frontend_type>
|
34 |
-
<sort_order>3</sort_order>
|
35 |
-
<show_in_default>1</show_in_default>
|
36 |
-
<show_in_website>1</show_in_website>
|
37 |
-
<show_in_store>0</show_in_store>
|
38 |
-
</paymentwall_shop_id>
|
39 |
-
<paymentwall_secret translate="label">
|
40 |
-
<label>Secret key</label>
|
41 |
-
<frontend_type>text</frontend_type>
|
42 |
-
|
43 |
-
<sort_order>4</sort_order>
|
44 |
-
<show_in_default>1</show_in_default>
|
45 |
-
<show_in_website>1</show_in_website>
|
46 |
-
<show_in_store>0</show_in_store>
|
47 |
-
</paymentwall_secret>
|
48 |
-
<paymentwall_widget_code translate="label">
|
49 |
-
<label>Widget code</label>
|
50 |
-
<frontend_type>text</frontend_type>
|
51 |
-
<sort_order>5</sort_order>
|
52 |
-
<show_in_default>1</show_in_default>
|
53 |
-
<show_in_website>1</show_in_website>
|
54 |
-
<show_in_store>0</show_in_store>
|
55 |
-
</paymentwall_widget_code>
|
56 |
-
<paymentwall_url translate="label">
|
57 |
-
<label>Success URL</label>
|
58 |
-
<frontend_type>text</frontend_type>
|
59 |
-
<sort_order>6</sort_order>
|
60 |
-
<show_in_default>1</show_in_default>
|
61 |
-
<show_in_website>1</show_in_website>
|
62 |
-
<show_in_store>0</show_in_store>
|
63 |
-
</paymentwall_url>
|
64 |
-
<paymentwall_istest translate="label">
|
65 |
-
<label>Test mode?</label>
|
66 |
-
<frontend_type>select</frontend_type>
|
67 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
68 |
-
<sort_order>6</sort_order>
|
69 |
-
<show_in_default>1</show_in_default>
|
70 |
-
<show_in_website>1</show_in_website>
|
71 |
-
<show_in_store>0</show_in_store>
|
72 |
-
</paymentwall_istest>
|
73 |
-
</fields>
|
74 |
-
</paymentwall>
|
75 |
-
</groups>
|
76 |
-
</payment>
|
77 |
-
</sections>
|
78 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/layout/paymentwall.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<checkout_onepage_index>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addItem">
|
6 |
+
<type>skin_js</type>
|
7 |
+
<name>js/paymentwall.js</name>
|
8 |
+
</action>
|
9 |
+
<action method="addItem">
|
10 |
+
<type>skin_css</type>
|
11 |
+
<name>css/paymentwall.css</name>
|
12 |
+
</action>
|
13 |
+
<block type="core/text" name="brick.js">
|
14 |
+
<action method="setText">
|
15 |
+
<text><![CDATA[<script src="//api.paymentwall.com/brick/brick.1.3.js"></script>]]></text>
|
16 |
+
</action>
|
17 |
+
</block>
|
18 |
+
</reference>
|
19 |
+
</checkout_onepage_index>
|
20 |
+
|
21 |
+
<!-- Layout settings for Paymentwall controller -->
|
22 |
+
<paymentwall_payment_pwlocal>
|
23 |
+
<reference name="head">
|
24 |
+
<action method="setTitle">
|
25 |
+
<title>Paymentwall Widget Checkout</title>
|
26 |
+
</action>
|
27 |
+
<action method="addItem">
|
28 |
+
<type>skin_js</type>
|
29 |
+
<name>js/paymentwall.js</name>
|
30 |
+
</action>
|
31 |
+
</reference>
|
32 |
+
<reference name="root">
|
33 |
+
<action method="setTemplate">
|
34 |
+
<template>page/2columns-right.phtml</template>
|
35 |
+
</action>
|
36 |
+
</reference>
|
37 |
+
<reference name="content">
|
38 |
+
<block type="paymentwall/checkout_form_method_pwlocal" name="paymentwall_widget"
|
39 |
+
template="paymentwall/checkout/form/method/pwlocal.phtml">
|
40 |
+
<label>Paymentwall Widget Checkout</label>
|
41 |
+
</block>
|
42 |
+
</reference>
|
43 |
+
</paymentwall_payment_pwlocal>
|
44 |
+
</layout>
|
app/design/frontend/base/default/template/paymentwall/checkout/form/method/pwbrick.phtml
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<ul class="form-list" id="payment_form_paymentwall_pwbrick" style="display: none">
|
2 |
+
<li>
|
3 |
+
<label for="paymentwall_pwbrick_cc_type" class="required"><em>*</em><?php echo $this->__('Card Type') ?></label>
|
4 |
+
|
5 |
+
<div class="input-box">
|
6 |
+
<select id="paymentwall_pwbrick_cc_type" name="payment[cc_type]"
|
7 |
+
title="<?php echo $this->__('Card Type') ?>"
|
8 |
+
class="required-entry validate-cc-type-select">
|
9 |
+
<option value=""><?php echo $this->__('--Please Select--') ?></option>
|
10 |
+
<?php $_ccType = $this->getInfoData('cc_type') ?>
|
11 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
12 |
+
<option
|
13 |
+
value="<?php echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>>
|
14 |
+
<?php echo $_typeName ?>
|
15 |
+
</option>
|
16 |
+
<?php endforeach ?>
|
17 |
+
</select>
|
18 |
+
</div>
|
19 |
+
</li>
|
20 |
+
<li>
|
21 |
+
<label for="paymentwall_pwbrick_cc_number" class="required">
|
22 |
+
<em>*</em>
|
23 |
+
<?php echo $this->__("Card Number") ?>
|
24 |
+
</label>
|
25 |
+
|
26 |
+
<div class="input-box">
|
27 |
+
<input name="payment[cc_number]" type="text" autocomplete="off" id="paymentwall_pwbrick_cc_number"
|
28 |
+
class="input-text validate-cc-number validate-cc-type" data-brick="card-number"/>
|
29 |
+
</div>
|
30 |
+
</li>
|
31 |
+
<li>
|
32 |
+
<label for="paymentwall_pwbrick_expiration" class="required">
|
33 |
+
<em>*</em>
|
34 |
+
<?php echo $this->__("Card expiration"); ?>
|
35 |
+
</label>
|
36 |
+
|
37 |
+
<div class="input-box">
|
38 |
+
<input name="payment[cc_exp_month]" type="text" id="paymentwall_pwbrick_expiration" autocomplete="off"
|
39 |
+
class="month validate-cc-exp required-entry" data-brick="card-expiration-month" placeholder="MM"
|
40 |
+
maxlength="2" size="2"/> /
|
41 |
+
<input name="payment[cc_exp_year]" type="text" id="paymentwall_pwbrick_expiration_yr" autocomplete="off"
|
42 |
+
class="year required-entry" data-brick="card-expiration-year" placeholder="YY" maxlength="4"
|
43 |
+
size="4"/>
|
44 |
+
</div>
|
45 |
+
</li>
|
46 |
+
<li>
|
47 |
+
<label for="paymentwall_pwbrick_cc_cid" class="required">
|
48 |
+
<em>*</em>
|
49 |
+
<?php echo $this->__("Card CVV") ?>
|
50 |
+
</label>
|
51 |
+
|
52 |
+
<div class="input-box">
|
53 |
+
<input name="payment[cc_cid]" type="text" id="paymentwall_pwbrick_cc_cid" autocomplete="off"
|
54 |
+
class="input-text cvv required-entry validate-cc-cvn"
|
55 |
+
data-brick="card-cvv" maxlength="4"/>
|
56 |
+
</div>
|
57 |
+
<div class="no-display">
|
58 |
+
<input type="hidden" name="payment[brick_token]" id="paymentwall_pwbrick_token">
|
59 |
+
<input type="hidden" name="payment[brick_fingerprint]" id="paymentwall_pwbrick_fingerprint">
|
60 |
+
</div>
|
61 |
+
</li>
|
62 |
+
</ul>
|
63 |
+
<script type="text/javascript">
|
64 |
+
var brick = PW.initPwBrick('<?php echo $this->getPublicKey(); ?>');
|
65 |
+
PW.rewriteSavePayment(brick);
|
66 |
+
</script>
|
app/design/frontend/base/default/template/paymentwall/checkout/form/method/pwlocal.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$widget = $this->getWidget();
|
3 |
+
?>
|
4 |
+
<div class="paymentwall-widget">
|
5 |
+
<?php
|
6 |
+
if ($widget['status']) {
|
7 |
+
echo $widget['content'];
|
8 |
+
} else {
|
9 |
+
echo "<h3>{$widget['content']}</h3>";
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
</div>
|
13 |
+
<?php if ($widget['status']) { ?>
|
14 |
+
<script type="text/javascript">
|
15 |
+
document.observe("dom:loaded", function () {
|
16 |
+
// Check order status
|
17 |
+
var pwinterval = setInterval(function () {
|
18 |
+
PW.ajaxPwLocalListener('<?php echo Mage::getUrl('paymentwall/payment/ajaxPwlocal');?>', function () {
|
19 |
+
clearInterval(pwinterval);
|
20 |
+
});
|
21 |
+
}, 5000);
|
22 |
+
});
|
23 |
+
</script>
|
24 |
+
<?php
|
25 |
+
}
|
app/design/frontend/base/default/template/paymentwall/checkout/info/method/pwbrick.phtml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$info = $this->getData('info');
|
3 |
+
$method = $this->getData('method');
|
4 |
+
?>
|
5 |
+
<?php if (!$this->getHideTitle()): ?>
|
6 |
+
<?php echo $this->escapeHtml($method->getConfigData('title')) ?><br/>
|
7 |
+
<?php endif; ?>
|
8 |
+
<span>
|
9 |
+
<?php echo $this->__('Card Number:') ?><br/><?php echo 'xxxx-xxxx-xxxx-' . $info->getCcLast4(); ?>
|
10 |
+
</span>
|
app/etc/modules/Paymentwall_Paymentwall.xml
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Paymentwall_Paymentwall>
|
5 |
-
<active>true</active>
|
6 |
-
<codePool>local</codePool>
|
7 |
-
<depends>
|
8 |
-
<Mage_Payment />
|
9 |
-
<Mage_Sales/>
|
10 |
-
<Mage_Checkout/>
|
11 |
-
</depends>
|
12 |
-
</Paymentwall_Paymentwall>
|
13 |
-
</modules>
|
14 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/paymentwall-php/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License (MIT)
|
2 |
+
|
3 |
+
Copyright (c) 2010-2015 Paymentwall, Inc.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6 |
+
this software and associated documentation files (the "Software"), to deal in
|
7 |
+
the Software without restriction, including without limitation the rights to
|
8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10 |
+
subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
lib/paymentwall-php/README.md
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#About Paymentwall
|
2 |
+
[Paymentwall](http://paymentwall.com/?source=gh) is the leading digital payments platform for globally monetizing digital goods and services. Paymentwall assists game publishers, dating sites, rewards sites, SaaS companies and many other verticals to monetize their digital content and services.
|
3 |
+
Merchants can plugin Paymentwall's API to accept payments from over 100 different methods including credit cards, debit cards, bank transfers, SMS/Mobile payments, prepaid cards, eWallets, landline payments and others.
|
4 |
+
|
5 |
+
To sign up for a Paymentwall Merchant Account, [click here](http://paymentwall.com/signup/merchant?source=gh).
|
6 |
+
|
7 |
+
#Paymentwall PHP Library
|
8 |
+
This library allows developers to use [Paymentwall APIs](http://paymentwall.com/en/documentation/API-Documentation/722?source=gh) (Virtual Currency, Digital Goods featuring recurring billing, and Virtual Cart).
|
9 |
+
|
10 |
+
To use Paymentwall, all you need to do is to sign up for a Paymentwall Merchant Account so you can setup an Application designed for your site.
|
11 |
+
To open your merchant account and set up an application, you can [sign up here](http://paymentwall.com/signup/merchant?source=gh).
|
12 |
+
|
13 |
+
#Installation
|
14 |
+
To install the library in your environment, you can download the [ZIP archive](https://github.com/paymentwall/paymentwall-php/archive/master.zip), unzip it and place into your project.
|
15 |
+
|
16 |
+
Alternatively, you can run:
|
17 |
+
|
18 |
+
<code>git clone git://github.com/paymentwall/paymentwall-php.git</code>
|
19 |
+
|
20 |
+
Then use a code sample below.
|
21 |
+
|
22 |
+
#Code Samples
|
23 |
+
|
24 |
+
##Digital Goods API
|
25 |
+
|
26 |
+
####Initializing Paymentwall
|
27 |
+
Using Paymentwall PHP Library v2:
|
28 |
+
```php
|
29 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
30 |
+
Paymentwall_Config::getInstance()->set(array(
|
31 |
+
'api_type' => Paymentwall_Config::API_GOODS,
|
32 |
+
'public_key' => 'YOUR_PUBLIC_KEY',
|
33 |
+
'private_key' => 'YOUR_PRIVATE_KEY'
|
34 |
+
));
|
35 |
+
```
|
36 |
+
Using Paymentwall PHP Library v1 (deprecated in v2):
|
37 |
+
```php
|
38 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
39 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
|
40 |
+
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
41 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
42 |
+
```
|
43 |
+
|
44 |
+
####Widget Call
|
45 |
+
[Web API details](http://www.paymentwall.com/en/documentation/Digital-Goods-API/710#paymentwall_widget_call_flexible_widget_call)
|
46 |
+
|
47 |
+
The widget is a payment page hosted by Paymentwall that embeds the entire payment flow: selecting the payment method, completing the billing details, and providing customer support via the Help section. You can redirect the users to this page or embed it via iframe. Below is an example that renders an iframe with Paymentwall Widget.
|
48 |
+
|
49 |
+
<pre><code>$widget = new Paymentwall_Widget(
|
50 |
+
'user40012', // id of the end-user who's making the payment
|
51 |
+
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
52 |
+
array( // product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty
|
53 |
+
new Paymentwall_Product(
|
54 |
+
'product301', // id of the product in your system
|
55 |
+
9.99, // price
|
56 |
+
'USD', // currency code
|
57 |
+
'Gold Membership', // product name
|
58 |
+
Paymentwall_Product::TYPE_SUBSCRIPTION, // this is a time-based product; for one-time products, use Paymentwall_Product::TYPE_FIXED and omit the following 3 array elements
|
59 |
+
1, // duration is 1
|
60 |
+
Paymentwall_Product::PERIOD_TYPE_MONTH, // month
|
61 |
+
true // recurring
|
62 |
+
)
|
63 |
+
),
|
64 |
+
array('email' => 'user@hostname.com') // additional parameters
|
65 |
+
);
|
66 |
+
echo $widget->getHtmlCode();
|
67 |
+
</code></pre>
|
68 |
+
|
69 |
+
####Pingback Processing
|
70 |
+
|
71 |
+
The Pingback is a webhook notifying about a payment being made. Pingbacks are sent via HTTP/HTTPS to your servers. To process pingbacks use the following code:
|
72 |
+
<pre><code>$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
73 |
+
if ($pingback->validate()) {
|
74 |
+
$productId = $pingback->getProduct()->getId();
|
75 |
+
if ($pingback->isDeliverable()) {
|
76 |
+
// deliver the product
|
77 |
+
} else if ($pingback->isCancelable()) {
|
78 |
+
// withdraw the product
|
79 |
+
}
|
80 |
+
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
81 |
+
} else {
|
82 |
+
echo $pingback->getErrorSummary();
|
83 |
+
}</code></pre>
|
84 |
+
|
85 |
+
##Virtual Currency API
|
86 |
+
|
87 |
+
####Initializing Paymentwall
|
88 |
+
Using Paymentwall PHP Library v2:
|
89 |
+
```php
|
90 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
91 |
+
Paymentwall_Config::getInstance()->set(array(
|
92 |
+
'api_type' => Paymentwall_Config::API_VC,
|
93 |
+
'public_key' => 'YOUR_PUBLIC_KEY',
|
94 |
+
'private_key' => 'YOUR_PRIVATE_KEY'
|
95 |
+
));
|
96 |
+
```
|
97 |
+
Using Paymentwall PHP Library v1 (deprecated in v2):
|
98 |
+
```php
|
99 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
100 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
|
101 |
+
Paymentwall_Base::setAppKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
102 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
103 |
+
```
|
104 |
+
|
105 |
+
####Widget Call
|
106 |
+
<pre><code>$widget = new Paymentwall_Widget(
|
107 |
+
'user40012', // id of the end-user who's making the payment
|
108 |
+
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
109 |
+
array(), // array of products - leave blank for Virtual Currency API
|
110 |
+
array('email' => 'user@hostname.com') // additional parameters
|
111 |
+
);
|
112 |
+
echo $widget->getHtmlCode();
|
113 |
+
</code></pre>
|
114 |
+
|
115 |
+
####Pingback Processing
|
116 |
+
|
117 |
+
<pre><code>$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
118 |
+
if ($pingback->validate()) {
|
119 |
+
$virtualCurrency = $pingback->getVirtualCurrencyAmount();
|
120 |
+
if ($pingback->isDeliverable()) {
|
121 |
+
// deliver the virtual currency
|
122 |
+
} else if ($pingback->isCancelable()) {
|
123 |
+
// withdraw the virual currency
|
124 |
+
}
|
125 |
+
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
126 |
+
} else {
|
127 |
+
echo $pingback->getErrorSummary();
|
128 |
+
}</code></pre>
|
129 |
+
|
130 |
+
##Cart API
|
131 |
+
|
132 |
+
####Initializing Paymentwall
|
133 |
+
Using Paymentwall PHP Library v2:
|
134 |
+
```php
|
135 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
136 |
+
Paymentwall_Config::getInstance()->set(array(
|
137 |
+
'api_type' => Paymentwall_Config::API_CART,
|
138 |
+
'public_key' => 'YOUR_PUBLIC_KEY',
|
139 |
+
'private_key' => 'YOUR_PRIVATE_KEY'
|
140 |
+
));
|
141 |
+
```
|
142 |
+
Using Paymentwall PHP Library v1 (deprecated in v2):
|
143 |
+
```php
|
144 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
145 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_CART);
|
146 |
+
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
147 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
148 |
+
```
|
149 |
+
|
150 |
+
####Widget Call
|
151 |
+
<pre><code>$widget = new Paymentwall_Widget(
|
152 |
+
'user40012', // id of the end-user who's making the payment
|
153 |
+
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account,
|
154 |
+
array(
|
155 |
+
new Paymentwall_Product('product301', 3.33, 'EUR'), // first product in cart
|
156 |
+
new Paymentwall_Product('product607', 7.77, 'EUR') // second product in cart
|
157 |
+
),
|
158 |
+
array('email' => 'user@hostname.com') // additional params
|
159 |
+
);
|
160 |
+
echo $widget->getHtmlCode();</code></pre>
|
161 |
+
|
162 |
+
####Pingback Processing
|
163 |
+
|
164 |
+
<pre><code>$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
165 |
+
if ($pingback->validate()) {
|
166 |
+
$products = $pingback->getProducts();
|
167 |
+
if ($pingback->isDeliverable()) {
|
168 |
+
// deliver products from the cart
|
169 |
+
} else if ($pingback->isCancelable()) {
|
170 |
+
// withdraw products from the cart
|
171 |
+
}
|
172 |
+
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
173 |
+
} else {
|
174 |
+
echo $pingback->getErrorSummary();
|
175 |
+
}</code></pre>
|
176 |
+
|
177 |
+
##Brick
|
178 |
+
|
179 |
+
####Initializing Paymentwall
|
180 |
+
<pre><code>Paymentwall_Config::getInstance()->set(array(
|
181 |
+
'public_key' => 'YOUR_PUBLIC_KEY',
|
182 |
+
'private_key' => 'YOUR_PRIVATE_KEY'
|
183 |
+
));</code></pre>
|
184 |
+
|
185 |
+
####Create a one-time token
|
186 |
+
<pre><code>$tokenModel = new Paymentwall_OneTimeToken();
|
187 |
+
$token = $tokenModel->create(array(
|
188 |
+
'public_key' => Paymentwall_Config::getInstance()->getPublicKey(),
|
189 |
+
'card[number]' => '4242424242424242',
|
190 |
+
'card[exp_month]' => '11',
|
191 |
+
'card[exp_year]' => '19',
|
192 |
+
'card[cvv]' => '123'
|
193 |
+
));</code></pre>
|
194 |
+
|
195 |
+
####Charge
|
196 |
+
<pre><code>$charge = new Paymentwall_Charge();
|
197 |
+
$charge->create(array(
|
198 |
+
// if generated via backend
|
199 |
+
//'token' => $token->getToken(),
|
200 |
+
// if generated via brick.js
|
201 |
+
'token' => $_POST['brick_token'],
|
202 |
+
'email' => $_POST['email'],
|
203 |
+
'currency' => 'USD',
|
204 |
+
'amount' => 10,
|
205 |
+
'fingerprint' => $_POST['brick_fingerprint'],
|
206 |
+
'description' => 'Order #123'
|
207 |
+
));
|
208 |
+
|
209 |
+
$response = $charge->getPublicData();
|
210 |
+
|
211 |
+
if ($charge->isSuccessful()) {
|
212 |
+
if ($charge->isCaptured()) {
|
213 |
+
// deliver s product
|
214 |
+
} elseif ($charge->isUnderReview()) {
|
215 |
+
// decide on risk charge
|
216 |
+
}
|
217 |
+
} else {
|
218 |
+
$errors = json_decode($response, true);
|
219 |
+
echo $errors['error']['code'];
|
220 |
+
echo $errors['error']['message'];
|
221 |
+
}
|
222 |
+
|
223 |
+
echo $response; // need for JS communication</code></pre>
|
224 |
+
|
225 |
+
####Charge - refund
|
226 |
+
|
227 |
+
<pre><code>$charge = new Paymentwall_Charge('CHARGE_ID');
|
228 |
+
$charge->refund();
|
229 |
+
|
230 |
+
echo $charge->isRefunded();</code></pre>
|
231 |
+
|
232 |
+
####Subscription
|
233 |
+
|
234 |
+
<pre><code>$subscription = new Paymentwall_Subscription();
|
235 |
+
$subscription->create(array(
|
236 |
+
// if generated via backend
|
237 |
+
//'token' => $token->getToken(),
|
238 |
+
// if generated via brick.js
|
239 |
+
'token' => $_POST['brick_token'],
|
240 |
+
'email' => $_POST['email'],
|
241 |
+
'currency' => 'USD',
|
242 |
+
'amount' => 10,
|
243 |
+
'fingerprint' => $_POST['brick_fingerprint'],
|
244 |
+
'plan' => 'product_123',
|
245 |
+
'description' => 'Order #123',
|
246 |
+
'period' => 'week',
|
247 |
+
'period_duration' => 2
|
248 |
+
));
|
249 |
+
|
250 |
+
echo $subscription->getId();</code></pre>
|
251 |
+
|
252 |
+
####Subscription - cancel
|
253 |
+
|
254 |
+
<pre><code>$subscription = new Paymentwall_Subscription('SUBSCRIPTION_ID');
|
255 |
+
$subscription->cancel();
|
256 |
+
|
257 |
+
echo $subscription->isActive();</code></pre>
|
258 |
+
|
259 |
+
###Signature calculation - Widget
|
260 |
+
|
261 |
+
<pre><code>$widgetSignatureModel = new Paymentwall_Signature_Widget();
|
262 |
+
echo $widgetSignatureModel->calculate(
|
263 |
+
array(), // widget params
|
264 |
+
2 // signature version
|
265 |
+
);</code></pre>
|
266 |
+
|
267 |
+
###Singature calculation - Pingback
|
268 |
+
|
269 |
+
<pre><code>$pingbackSignatureModel = new Paymentwall_Signature_Pingback();
|
270 |
+
echo $pingbackSignatureModel->calculate(
|
271 |
+
array(), // pingback params
|
272 |
+
1 // signature version
|
273 |
+
);</code></pre>
|
lib/paymentwall-php/composer.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "paymentwall/paymentwall-php",
|
3 |
+
"description": "Paymentwall PHP Library. Paymentwall is the leading digital payments platform for globally monetizing digital goods and services.",
|
4 |
+
"version": "2.0.0",
|
5 |
+
"type": "library",
|
6 |
+
"homepage": "http://paymentwall.com?source=gh",
|
7 |
+
"keywords": [
|
8 |
+
"paymentwall",
|
9 |
+
"api",
|
10 |
+
"payments",
|
11 |
+
"carrier billing",
|
12 |
+
"credit cards",
|
13 |
+
"alternative payments",
|
14 |
+
"monetization",
|
15 |
+
"recurring billing",
|
16 |
+
"payment processing"
|
17 |
+
],
|
18 |
+
"license": "MIT",
|
19 |
+
"authors": [
|
20 |
+
{
|
21 |
+
"name": "Paymentwall Team",
|
22 |
+
"email": "devsupport@paymentwall.com"
|
23 |
+
}
|
24 |
+
],
|
25 |
+
"require": {
|
26 |
+
"php": ">=5.2",
|
27 |
+
"ext-curl": "*",
|
28 |
+
"ext-json": "*"
|
29 |
+
},
|
30 |
+
"config": {
|
31 |
+
"bin-dir": "bin/"
|
32 |
+
},
|
33 |
+
"autoload": {
|
34 |
+
"classmap": ["lib/Paymentwall/"]
|
35 |
+
},
|
36 |
+
"minimum-stability": "dev"
|
37 |
+
}
|
lib/paymentwall-php/features/bootstrap/ChargeContext.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use Behat\Behat\Context\BehatContext;
|
4 |
+
|
5 |
+
class ChargeContext extends BehatContext
|
6 |
+
{
|
7 |
+
public function __construct(array $parameters)
|
8 |
+
{
|
9 |
+
$this->token = NULL;
|
10 |
+
$this->chargeId = NULL;
|
11 |
+
$this->cvv = '123';
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @Given /^CVV code "([^"]*)"$/
|
16 |
+
*/
|
17 |
+
public function cvvCode($cvvCode)
|
18 |
+
{
|
19 |
+
$this->cvv = $cvvCode;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @Given /^charge ID "([^"]*)"$/
|
24 |
+
*/
|
25 |
+
public function chargeId($chargeId)
|
26 |
+
{
|
27 |
+
$this->chargeId = $chargeId;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @When /^test token is retrieved$/
|
32 |
+
*/
|
33 |
+
public function testTokenIsRetrieved()
|
34 |
+
{
|
35 |
+
$tokenModel = new Paymentwall_OneTimeToken();
|
36 |
+
$this->token = $tokenModel->create($this->getTestDetailsForOneTimeToken())->getToken();
|
37 |
+
if (strpos($this->token, 'ot_') === FALSE) {
|
38 |
+
throw new Exception($this->token->getPublicData());
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @Then /^charge should be successful$/
|
44 |
+
*/
|
45 |
+
public function chargeShouldBeSuccessful()
|
46 |
+
{
|
47 |
+
$charge = $this->getChargeObject();
|
48 |
+
if (!$charge->isSuccessful()) {
|
49 |
+
throw new Exception($charge->getPublicData());
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @Then /^charge should be refunded$/
|
55 |
+
*/
|
56 |
+
public function chargeShouldBeRefunded()
|
57 |
+
{
|
58 |
+
$chargeToBeRefunded = new Paymentwall_Charge($this->chargeId);
|
59 |
+
if (!$chargeToBeRefunded->refund()->isRefunded()) {
|
60 |
+
throw new Exception($chargeToBeRefunded->getPublicData());
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @Then /^I see this error message "([^"]*)"$/
|
66 |
+
*/
|
67 |
+
public function iSeeThisErrorMessage($errorMessage = '')
|
68 |
+
{
|
69 |
+
$charge = $this->getChargeObject();
|
70 |
+
$errors = json_decode($charge->getPublicData(), TRUE);
|
71 |
+
if (strpos($errorMessage, $errors['error']['message']) === FALSE) {
|
72 |
+
throw new Exception($charge->getPublicData());
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
protected function getChargeObject()
|
77 |
+
{
|
78 |
+
$chargeModel = new Paymentwall_Charge();
|
79 |
+
return $chargeModel->create($this->getTestDetailsForCharge());
|
80 |
+
}
|
81 |
+
|
82 |
+
protected function getTestDetailsForCharge()
|
83 |
+
{
|
84 |
+
return array(
|
85 |
+
'token' => $this->token,
|
86 |
+
'email' => 'test@user.com',
|
87 |
+
'currency' => 'USD',
|
88 |
+
'amount' => 9.99,
|
89 |
+
'browser_domain' => 'https://www.paymentwall.com',
|
90 |
+
'browser_ip' => '72.229.28.185',
|
91 |
+
'description' => 'Test Charge'
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function getTestDetailsForOneTimeToken()
|
96 |
+
{
|
97 |
+
return array_merge(
|
98 |
+
array('public_key' => Paymentwall_Config::getInstance()->getPublicKey()),
|
99 |
+
$this->getTestCardDetails()
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
protected function getTestCardDetails()
|
104 |
+
{
|
105 |
+
return array(
|
106 |
+
'card[number]' => '4242424242424242',
|
107 |
+
'card[exp_month]' => '11',
|
108 |
+
'card[exp_year]' => '19',
|
109 |
+
'card[cvv]' => $this->cvv
|
110 |
+
);
|
111 |
+
}
|
112 |
+
}
|
lib/paymentwall-php/features/bootstrap/FeatureContext.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use Behat\Behat\Context\ClosuredContextInterface,
|
4 |
+
Behat\Behat\Context\TranslatedContextInterface,
|
5 |
+
Behat\Behat\Context\BehatContext,
|
6 |
+
Behat\Behat\Exception\PendingException;
|
7 |
+
use Behat\Gherkin\Node\PyStringNode,
|
8 |
+
Behat\Gherkin\Node\TableNode;
|
9 |
+
|
10 |
+
require_once('lib/paymentwall.php');
|
11 |
+
|
12 |
+
//
|
13 |
+
// Require 3rd-party libraries here:
|
14 |
+
//
|
15 |
+
// require_once 'PHPUnit/Autoload.php';
|
16 |
+
// require_once 'PHPUnit/Framework/Assert/Functions.php';
|
17 |
+
//
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Features context.
|
21 |
+
*/
|
22 |
+
class FeatureContext extends BehatContext
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* Initializes context.
|
26 |
+
* Every scenario gets it's own context object.
|
27 |
+
*
|
28 |
+
* @param array $parameters context parameters (set them up through behat.yml)
|
29 |
+
*/
|
30 |
+
public function __construct(array $parameters)
|
31 |
+
{
|
32 |
+
$this->useContext('pingback', new PingbackContext(array()));
|
33 |
+
$this->useContext('widget', new WidgetContext(array()));
|
34 |
+
$this->useContext('charge', new ChargeContext(array()));
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @Given /^Public key "([^"]*)"$/
|
39 |
+
*/
|
40 |
+
public function publicKey($publicKey)
|
41 |
+
{
|
42 |
+
Paymentwall_Base::setAppKey($publicKey);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @Given /^Secret key "([^"]*)"$/
|
47 |
+
*/
|
48 |
+
public function secretKey($secretKey)
|
49 |
+
{
|
50 |
+
Paymentwall_Base::setSecretKey($secretKey);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @Given /^Private key "([^"]*)"$/
|
55 |
+
*/
|
56 |
+
public function privateKey($privateKey)
|
57 |
+
{
|
58 |
+
Paymentwall_Config::getInstance()->set(array(
|
59 |
+
'private_key' => $privateKey
|
60 |
+
));
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @Given /^API type "([^"]*)"$/
|
65 |
+
*/
|
66 |
+
public function apiType($apiType)
|
67 |
+
{
|
68 |
+
Paymentwall_Base::setApiType($apiType);
|
69 |
+
$this->apiType = $apiType;
|
70 |
+
}
|
71 |
+
}
|
lib/paymentwall-php/features/bootstrap/PingbackContext.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use Behat\Behat\Context\BehatContext;
|
4 |
+
|
5 |
+
class PingbackContext extends BehatContext
|
6 |
+
{
|
7 |
+
public function __construct(array $parameters)
|
8 |
+
{
|
9 |
+
$this->pingbackParameters = null;
|
10 |
+
$this->pingbackIpAddress = null;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @Given /^Pingback GET parameters "([^"]*)"$/
|
15 |
+
*/
|
16 |
+
public function pingbackGetParameters($parameters)
|
17 |
+
{
|
18 |
+
parse_str($parameters, $this->pingbackParameters);
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @Given /^Pingback IP address "([^"]*)"$/
|
23 |
+
*/
|
24 |
+
public function pingbackIpAddress($ipAddress)
|
25 |
+
{
|
26 |
+
$this->pingbackIpAddress = $ipAddress;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @When /^Pingback is constructed$/
|
31 |
+
*/
|
32 |
+
public function pingbackIsConstructed()
|
33 |
+
{
|
34 |
+
$this->pingback = new Paymentwall_Pingback($this->pingbackParameters, $this->pingbackIpAddress);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @Then /^Pingback validation result should be "([^"]*)"$/
|
39 |
+
*/
|
40 |
+
public function pingbackValidationResultShouldBe($value)
|
41 |
+
{
|
42 |
+
$validate = $this->pingback->validate();
|
43 |
+
if ($validate !== $value) {
|
44 |
+
throw new Exception(
|
45 |
+
'Pingback Validation returns ' . var_export($validate, true) . (!$validate ? ("\r\nErrors:" . $this->pingback->getErrorSummary()) : '')
|
46 |
+
);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @Given /^Pingback method "([^"]*)" should return "([^"]*)"$/
|
52 |
+
*/
|
53 |
+
public function pingbackMethodShouldReturn($method, $value)
|
54 |
+
{
|
55 |
+
if ($this->pingback->$method() !== $value) {
|
56 |
+
throw new Exception(
|
57 |
+
'Pingback method ' . $method . ' returned ' . var_export($value, true)
|
58 |
+
);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @Transform /^(true|false)$/
|
64 |
+
*/
|
65 |
+
public function castStringToBoolean($string)
|
66 |
+
{
|
67 |
+
return filter_var($string, FILTER_VALIDATE_BOOLEAN);
|
68 |
+
}
|
69 |
+
}
|
lib/paymentwall-php/features/bootstrap/WidgetContext.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use Behat\Behat\Context\BehatContext;
|
4 |
+
|
5 |
+
class WidgetContext extends BehatContext
|
6 |
+
{
|
7 |
+
public function __construct(array $parameters)
|
8 |
+
{
|
9 |
+
// Initialize your context here
|
10 |
+
$this->productName = 'Test Default Product Name';
|
11 |
+
$this->widgetSignatureVersion = null;
|
12 |
+
$this->widgetCode = 'p10';
|
13 |
+
$this->languageCode = null;
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function getWidgetSignatureVersion() {
|
17 |
+
return $this->widgetSignatureVersion;
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function getUserId() {
|
21 |
+
return 'test_user';
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function getWidgetCode() {
|
25 |
+
return $this->widgetCode;
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function getLanguageCode() {
|
29 |
+
return $this->languageCode;
|
30 |
+
}
|
31 |
+
|
32 |
+
protected function getProduct() {
|
33 |
+
switch ($this->getMainContext()->apiType) {
|
34 |
+
case (Paymentwall_Base::API_GOODS):
|
35 |
+
/**
|
36 |
+
* @todo implement subscriptions, trial, no product
|
37 |
+
*/
|
38 |
+
return array(
|
39 |
+
new Paymentwall_Product(
|
40 |
+
'product301',
|
41 |
+
9.99,
|
42 |
+
'USD',
|
43 |
+
$this->productName,
|
44 |
+
Paymentwall_Product::TYPE_FIXED
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
case (Paymentwall_Base::API_VC):
|
49 |
+
return array();
|
50 |
+
|
51 |
+
case (Paymentwall_Base::API_CART):
|
52 |
+
/**
|
53 |
+
* @todo implement custom IDs and prices
|
54 |
+
*/
|
55 |
+
return array();
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @Given /^Widget signature version "([^"]*)"$/
|
61 |
+
*/
|
62 |
+
public function widgetSignatureVersion($signatureVersion)
|
63 |
+
{
|
64 |
+
$this->widgetSignatureVersion = $signatureVersion;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @Given /^Widget code "([^"]*)"$/
|
69 |
+
*/
|
70 |
+
public function widgetCode($widgetCode)
|
71 |
+
{
|
72 |
+
$this->widgetCode = $widgetCode;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @Given /^Language code "([^"]*)"$/
|
77 |
+
*/
|
78 |
+
public function languageCode($languageCode)
|
79 |
+
{
|
80 |
+
$this->languageCode = $languageCode;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @Given /^Product name "([^"]*)"$/
|
85 |
+
*/
|
86 |
+
public function productName($productName)
|
87 |
+
{
|
88 |
+
$this->productName = $productName;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @When /^Widget is constructed$/
|
93 |
+
*/
|
94 |
+
public function widgetIsConstructed()
|
95 |
+
{
|
96 |
+
$this->widget = new Paymentwall_Widget(
|
97 |
+
$this->getUserId(),
|
98 |
+
$this->getWidgetCode(),
|
99 |
+
$this->getProduct(),
|
100 |
+
array(
|
101 |
+
'email' => 'user@hostname.com',
|
102 |
+
'sign_version' => $this->getWidgetSignatureVersion(),
|
103 |
+
'lang' => $this->getLanguageCode()
|
104 |
+
)
|
105 |
+
);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @When /^Widget HTML content is loaded$/
|
110 |
+
*/
|
111 |
+
public function widgetHtmlContentIsLoaded()
|
112 |
+
{
|
113 |
+
$this->widgetHtmlContent = file_get_contents($this->widget->getUrl());
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @Then /^Widget HTML content should not contain "([^"]*)"$/
|
118 |
+
*/
|
119 |
+
public function widgetHtmlContentShouldNotContain($phrase)
|
120 |
+
{
|
121 |
+
if (strpos($this->widgetHtmlContent, $phrase) !== false) {
|
122 |
+
throw new Exception(
|
123 |
+
'Widget HTML content contains "' . $phrase . '"'
|
124 |
+
);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @Then /^Widget HTML content should contain "([^"]*)"$/
|
130 |
+
*/
|
131 |
+
public function widgetHtmlContentShouldContain($phrase)
|
132 |
+
{
|
133 |
+
if (strpos($this->widgetHtmlContent, $phrase) === false) {
|
134 |
+
throw new Exception(
|
135 |
+
'Widget HTML content doesn\'t contain "' . $phrase . '" (URL: ' . $this->widget->getUrl() .')'
|
136 |
+
);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @Then /^Widget URL should not contain "([^"]*)"$/
|
142 |
+
*/
|
143 |
+
public function widgetUrlShouldNotContain($phrase)
|
144 |
+
{
|
145 |
+
if (strpos($this->widget->getUrl(), $phrase) !== false) {
|
146 |
+
throw new Exception(
|
147 |
+
'Widget URL contains "' . $phrase . '"'
|
148 |
+
);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @Then /^Widget URL should contain "([^"]*)"$/
|
154 |
+
*/
|
155 |
+
public function widgetUrlShouldContain($phrase)
|
156 |
+
{
|
157 |
+
if (strpos($this->widget->getUrl(), $phrase) === false) {
|
158 |
+
throw new Exception(
|
159 |
+
'Widget URL doesn\'t contain "' . $phrase . '" (URL: ' . $this->widget->getUrl() .')'
|
160 |
+
);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
lib/paymentwall-php/features/charge.feature
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Feature: Charge
|
2 |
+
In order to let users make payments on my website
|
3 |
+
As a developer
|
4 |
+
I want to be able to perform a charge using Brick
|
5 |
+
|
6 |
+
Scenario: Should be able to create a test charge
|
7 |
+
Given Public key "t_33c1806e0daf60fc31f2167f0e4d59"
|
8 |
+
And Private key "t_85c66c2d7461e8885805f92dfd171c"
|
9 |
+
When test token is retrieved
|
10 |
+
Then charge should be successful
|
11 |
+
|
12 |
+
Scenario: Should be able to refund a test charge
|
13 |
+
Given Public key "t_33c1806e0daf60fc31f2167f0e4d59"
|
14 |
+
And Private key "t_85c66c2d7461e8885805f92dfd171c"
|
15 |
+
And charge ID "9557984691424639727_test"
|
16 |
+
Then charge should be refunded
|
17 |
+
|
18 |
+
Scenario: Should not be able to create a test charge with wrong CVV code
|
19 |
+
Given Public key "t_33c1806e0daf60fc31f2167f0e4d59"
|
20 |
+
And Private key "t_85c66c2d7461e8885805f92dfd171c"
|
21 |
+
And CVV code "333"
|
22 |
+
When test token is retrieved
|
23 |
+
Then I see this error message "Please contact your credit card company to approve your payment"
|
lib/paymentwall-php/features/pingback.feature
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Feature: Pingback
|
2 |
+
In order to account for Paymentwall payments on my website
|
3 |
+
As a developer
|
4 |
+
I want to be able to validate Paymentwall pingbacks
|
5 |
+
|
6 |
+
|
7 |
+
Scenario: check Digital Goods pingback signature v2 with correct signature and correct IP
|
8 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
9 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
10 |
+
And API type "2"
|
11 |
+
And Pingback GET parameters "uid=test_user&goodsid=test_product&slength=5&speriod=month&type=0&ref=t123&is_test=1&sign_version=2&sig=754cff93c0eb859f6054bef143ad253c"
|
12 |
+
And Pingback IP address "174.36.92.186"
|
13 |
+
When Pingback is constructed
|
14 |
+
Then Pingback validation result should be "true"
|
15 |
+
And Pingback method "getUserId" should return "test_user"
|
16 |
+
And Pingback method "getProductId" should return "test_product"
|
17 |
+
And Pingback method "getProductPeriodLength" should return "5"
|
18 |
+
And Pingback method "getProductPeriodType" should return "month"
|
19 |
+
And Pingback method "getReferenceId" should return "t123"
|
20 |
+
And Pingback method "isDeliverable" should return "true"
|
21 |
+
And Pingback method "isCancelable" should return "false"
|
22 |
+
|
23 |
+
|
24 |
+
Scenario: check Digital Goods pingback signature v2 with correct signature and wrong IP
|
25 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
26 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
27 |
+
And API type "2"
|
28 |
+
And Pingback GET parameters "uid=test_user&goodsid=test_product&slength=5&speriod=month&type=0&ref=t123&is_test=1&sign_version=2&sig=754cff93c0eb859f6054bef143ad253c"
|
29 |
+
And Pingback IP address "1.2.3.4"
|
30 |
+
When Pingback is constructed
|
31 |
+
Then Pingback validation result should be "false"
|
32 |
+
|
33 |
+
|
34 |
+
Scenario: check Digital Goods pingback signature v2 with wrong signature and correct IP
|
35 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
36 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
37 |
+
And API type "2"
|
38 |
+
And Pingback GET parameters "uid=test_user&goodsid=test_product&slength=5&speriod=month&type=0&ref=t123&is_test=1&sign_version=2&sig=754cff93c0eb859f6054bef143ad253cfoo"
|
39 |
+
And Pingback IP address "174.36.92.186"
|
40 |
+
When Pingback is constructed
|
41 |
+
Then Pingback validation result should be "false"
|
42 |
+
|
43 |
+
|
44 |
+
Scenario: check Digital Goods negative pingback signature v3 with correct signature and correct IP
|
45 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
46 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
47 |
+
And API type "2"
|
48 |
+
And Pingback GET parameters "uid=test_user&goodsid=test_product&slength=-5&speriod=month&type=2&ref=t123&is_test=1&reason=9&sign_version=3&sig=2f67209c3e581313a70de9425efef49f35a74c0cdb7f93051b47e3c097011a71"
|
49 |
+
And Pingback IP address "174.36.92.186"
|
50 |
+
When Pingback is constructed
|
51 |
+
Then Pingback validation result should be "true"
|
52 |
+
And Pingback method "getProductPeriodLength" should return "-5"
|
53 |
+
And Pingback method "getProductPeriodType" should return "month"
|
54 |
+
And Pingback method "isDeliverable" should return "false"
|
55 |
+
And Pingback method "isCancelable" should return "true"
|
56 |
+
|
57 |
+
|
58 |
+
Scenario: check Digital Goods negative pingback signature v1 with correct signature
|
59 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
60 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
61 |
+
And API type "2"
|
62 |
+
And Pingback GET parameters "uid=test_user&goodsid=test_product&slength=-5&speriod=month&type=2&ref=t123&is_test=1&reason=9&sig=e7b2ff07bc0734c83ee14f32552b1c88"
|
63 |
+
And Pingback IP address "174.36.92.186"
|
64 |
+
When Pingback is constructed
|
65 |
+
Then Pingback validation result should be "true"
|
66 |
+
|
67 |
+
|
68 |
+
Scenario: check Digital Goods pingback signature v1 with correct signature
|
69 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
70 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
71 |
+
And API type "1"
|
72 |
+
And Pingback GET parameters "uid=test_user¤cy=1000&type=0&ref=t555&is_test=1&sig=efaacb488ab8ee19321ad513b6908574"
|
73 |
+
And Pingback IP address "174.36.92.186"
|
74 |
+
When Pingback is constructed
|
75 |
+
Then Pingback validation result should be "true"
|
76 |
+
And Pingback method "getVirtualCurrencyAmount" should return "1000"
|
77 |
+
|
78 |
+
|
79 |
+
Scenario: check Virtual Currency pingback signature v1 with wrong signature
|
80 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
81 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
82 |
+
And API type "1"
|
83 |
+
And Pingback GET parameters "uid=test_user¤cy=1000&type=0&ref=t555&is_test=1&sig=efaacb488ab8ee19321ad513b6908574foo"
|
84 |
+
And Pingback IP address "174.36.92.186"
|
85 |
+
When Pingback is constructed
|
86 |
+
Then Pingback validation result should be "false"
|
87 |
+
|
88 |
+
Scenario: check Digital Goods pingback signature v2 with correct signature
|
89 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
90 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
91 |
+
And API type "1"
|
92 |
+
And Pingback GET parameters "uid=test_user¤cy=1000&type=0&ref=t555&is_test=1&sign_version=2&sig=5057977f881bed13592bec928f062b31"
|
93 |
+
And Pingback IP address "174.36.92.186"
|
94 |
+
When Pingback is constructed
|
95 |
+
Then Pingback validation result should be "true"
|
96 |
+
And Pingback method "getVirtualCurrencyAmount" should return "1000"
|
97 |
+
|
98 |
+
|
99 |
+
Scenario: check Virtual Currency pingback signature v2 with wrong signature
|
100 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
101 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
102 |
+
And API type "1"
|
103 |
+
And Pingback GET parameters "uid=test_user¤cy=1000&type=0&ref=t555&is_test=1&sign_version=2&sig=5057977f881bed13592bec928f062b31foo"
|
104 |
+
And Pingback IP address "174.36.92.186"
|
105 |
+
When Pingback is constructed
|
106 |
+
Then Pingback validation result should be "false"
|
107 |
+
|
108 |
+
|
109 |
+
Scenario: check Digital Goods pingback signature v3 with correct signature
|
110 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
111 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
112 |
+
And API type "1"
|
113 |
+
And Pingback GET parameters "uid=test_user¤cy=1000&type=0&ref=t555&is_test=1&sign_version=3&sig=a2932c360010e613166ae95ede5a3fa45bfcac10e1dd93715d21b00d684eb0fb"
|
114 |
+
And Pingback IP address "174.36.92.186"
|
115 |
+
When Pingback is constructed
|
116 |
+
Then Pingback validation result should be "true"
|
117 |
+
And Pingback method "getVirtualCurrencyAmount" should return "1000"
|
118 |
+
|
119 |
+
|
120 |
+
Scenario: check Virtual Currency pingback signature v3 with wrong signature
|
121 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
122 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
123 |
+
And API type "1"
|
124 |
+
And Pingback GET parameters "uid=test_user¤cy=1000&type=0&ref=t555&is_test=1&sign_version=3&sig=a2932c360010e613166ae95ede5a3fa45bfcac10e1dd93715d21b00d684eb0fbfoo"
|
125 |
+
And Pingback IP address "174.36.92.186"
|
126 |
+
When Pingback is constructed
|
127 |
+
Then Pingback validation result should be "false"
|
128 |
+
|
lib/paymentwall-php/features/widget.feature
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Feature: Widget
|
2 |
+
In order to let users make payments on my website
|
3 |
+
As a developer
|
4 |
+
I want to be able to generate HTML code of Paymentwall widgets
|
5 |
+
|
6 |
+
Scenario: check Digital Goods widget signature v2 with correct secret key
|
7 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
8 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
9 |
+
And API type "2"
|
10 |
+
And Widget signature version "2"
|
11 |
+
And Product name "Automatic Test Product Name"
|
12 |
+
When Widget is constructed
|
13 |
+
And Widget HTML content is loaded
|
14 |
+
Then Widget HTML content should not contain "It looks like you're not authorized to view this content."
|
15 |
+
And Widget HTML content should contain "Automatic Test Product Name"
|
16 |
+
|
17 |
+
Scenario: check Digital Goods widget signature v2 with wrong secret key
|
18 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
19 |
+
And Secret key "000"
|
20 |
+
And API type "2"
|
21 |
+
And Widget signature version "2"
|
22 |
+
When Widget is constructed
|
23 |
+
And Widget HTML content is loaded
|
24 |
+
Then Widget HTML content should contain "It looks like you're not authorized to view this content."
|
25 |
+
|
26 |
+
Scenario: check Digital Goods widget signature v1 with correct secret key
|
27 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
28 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
29 |
+
And API type "2"
|
30 |
+
And Widget signature version "1"
|
31 |
+
When Widget is constructed
|
32 |
+
And Widget HTML content is loaded
|
33 |
+
Then Widget HTML content should not contain "It looks like you're not authorized to view this content."
|
34 |
+
|
35 |
+
Scenario: check Digital Goods widget signature v1 with wrong secret key
|
36 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
37 |
+
And Secret key "000"
|
38 |
+
And API type "2"
|
39 |
+
And Widget signature version "1"
|
40 |
+
When Widget is constructed
|
41 |
+
And Widget HTML content is loaded
|
42 |
+
Then Widget HTML content should contain "It looks like you're not authorized to view this content."
|
43 |
+
|
44 |
+
Scenario: check Digital Goods widget signature v3 with correct secret key
|
45 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
46 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
47 |
+
And API type "2"
|
48 |
+
And Widget signature version "3"
|
49 |
+
When Widget is constructed
|
50 |
+
And Widget HTML content is loaded
|
51 |
+
Then Widget HTML content should not contain "It looks like you're not authorized to view this content."
|
52 |
+
|
53 |
+
Scenario: check Digital Goods widget signature v3 with wrong secret key
|
54 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
55 |
+
And Secret key "000"
|
56 |
+
And API type "2"
|
57 |
+
And Widget signature version "3"
|
58 |
+
When Widget is constructed
|
59 |
+
And Widget HTML content is loaded
|
60 |
+
Then Widget HTML content should contain "It looks like you're not authorized to view this content."
|
61 |
+
|
62 |
+
Scenario: check Digital Goods widget signature v3 with wrong secret key
|
63 |
+
Given Public key "c22f895840bf2391f67a40da64bfed26"
|
64 |
+
And Secret key "a7408723eaf4bfa2e3ac49b3cb695046"
|
65 |
+
And API type "2"
|
66 |
+
And Widget signature version "3"
|
67 |
+
And Product name "Automatic Test Product Name"
|
68 |
+
When Widget is constructed
|
69 |
+
And Widget HTML content is loaded
|
70 |
+
Then Widget HTML content should not contain "It looks like you're not authorized to view this content."
|
71 |
+
And Widget HTML content should contain "Automatic Test Product Name"
|
72 |
+
|
73 |
+
Scenario: check Virtual Currency offer widget signature v2 with correct secret key
|
74 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
75 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
76 |
+
And API type "1"
|
77 |
+
And Widget signature version "2"
|
78 |
+
And Widget code "w1"
|
79 |
+
And Language code "en"
|
80 |
+
When Widget is constructed
|
81 |
+
And Widget HTML content is loaded
|
82 |
+
Then Widget URL should contain "/api/?"
|
83 |
+
And Widget HTML content should not contain "It looks like you're not authorized to view this content."
|
84 |
+
And Widget HTML content should contain "by completing offers below"
|
85 |
+
|
86 |
+
Scenario: check Virtual Currency payment widget signature v2 with correct secret key
|
87 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
88 |
+
And Secret key "6274def95b105f1c92d341a8d3bc2e77"
|
89 |
+
And API type "1"
|
90 |
+
And Widget signature version "2"
|
91 |
+
And Widget code "p10"
|
92 |
+
And Language code "en"
|
93 |
+
When Widget is constructed
|
94 |
+
And Widget HTML content is loaded
|
95 |
+
Then Widget URL should contain "/api/ps?"
|
96 |
+
And Widget HTML content should not contain "It looks like you're not authorized to view this content."
|
97 |
+
And Widget HTML content should contain "Select payment method"
|
98 |
+
|
99 |
+
|
100 |
+
Scenario: check Virtual Currency widget signature v2 with wrong secret key
|
101 |
+
Given Public key "c10c60d07a2f4549a17902d683eb0b11"
|
102 |
+
And Secret key "000"
|
103 |
+
And API type "1"
|
104 |
+
And Widget signature version "2"
|
105 |
+
When Widget is constructed
|
106 |
+
And Widget HTML content is loaded
|
107 |
+
Then Widget HTML content should contain "It looks like you're not authorized to view this content."
|
lib/paymentwall-php/lib/Paymentwall/ApiObject.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Paymentwall_ApiObject extends Paymentwall_Instance
|
4 |
+
{
|
5 |
+
const API_OBJECT_CHARGE = 'charge';
|
6 |
+
const API_OBJECT_SUBSCRIPTION = 'subscription';
|
7 |
+
const API_OBJECT_ONE_TIME_TOKEN = 'token';
|
8 |
+
|
9 |
+
protected $properties = array();
|
10 |
+
protected $_id;
|
11 |
+
protected $_rawResponse = '';
|
12 |
+
|
13 |
+
abstract function getEndpointName();
|
14 |
+
|
15 |
+
public function __construct($id = '')
|
16 |
+
{
|
17 |
+
if (!empty($id)) {
|
18 |
+
$this->_id = $id;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
public final function create($params = array())
|
23 |
+
{
|
24 |
+
$httpAction = new Paymentwall_HttpAction($this, $params, array(
|
25 |
+
$this->getApiBaseHeader()
|
26 |
+
));
|
27 |
+
$this->setPropertiesFromResponse($httpAction->run());
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function __get($property)
|
32 |
+
{
|
33 |
+
return isset($this->properties[$property]) ? $this->properties[$property] : null;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getApiUrl()
|
37 |
+
{
|
38 |
+
if ($this->getEndpointName() === self::API_OBJECT_ONE_TIME_TOKEN && !$this->getConfig()->isTest()) {
|
39 |
+
return Paymentwall_OneTimeToken::GATEWAY_TOKENIZATION_URL;
|
40 |
+
} else {
|
41 |
+
return $this->getApiBaseUrl() . '/brick/' . $this->getEndpointName();
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getPublicData()
|
46 |
+
{
|
47 |
+
$responseModel = Paymentwall_Response_Factory::get($this->getPropertiesFromResponse());
|
48 |
+
return $responseModel instanceof Paymentwall_Response_Interface ? $responseModel->process() : '';
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getProperties() {
|
52 |
+
return $this->properties;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getRawResponseData()
|
56 |
+
{
|
57 |
+
return $this->_rawResponse;
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function setPropertiesFromResponse($response = '')
|
61 |
+
{
|
62 |
+
if (!empty($response)) {
|
63 |
+
$this->_rawResponse = $response;
|
64 |
+
$this->properties = (array) $this->preparePropertiesFromResponse($response);
|
65 |
+
} else {
|
66 |
+
throw new Exception('Empty response');
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function getPropertiesFromResponse()
|
71 |
+
{
|
72 |
+
return $this->properties;
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function preparePropertiesFromResponse($string = '')
|
76 |
+
{
|
77 |
+
return json_decode($string, false);
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function getApiBaseHeader()
|
81 |
+
{
|
82 |
+
return 'X-ApiKey: ' . $this->getPrivateKey();
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function doApiAction($action = '', $method = 'post')
|
86 |
+
{
|
87 |
+
$actionUrl = $this->getApiUrl() . '/' . $this->_id . '/' . $action;
|
88 |
+
$httpAction = new Paymentwall_HttpAction($this, array('id' => $this->_id), array(
|
89 |
+
$this->getApiBaseHeader()
|
90 |
+
));
|
91 |
+
$this->setPropertiesFromResponse(
|
92 |
+
$method == 'get' ? $httpAction->get($actionUrl) : $httpAction->post($actionUrl)
|
93 |
+
);
|
94 |
+
return $this;
|
95 |
+
}
|
96 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/ApiObjectInterface.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
interface Paymentwall_ApiObjectInterface
|
4 |
+
{
|
5 |
+
public function getCard();
|
6 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Base.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Paymentwall_Base
|
4 |
+
* @deprecated
|
5 |
+
*/
|
6 |
+
class Paymentwall_Base extends Paymentwall_Config
|
7 |
+
{
|
8 |
+
public static function setApiType($apiType = 0)
|
9 |
+
{
|
10 |
+
return self::getInstance()->setLocalApiType($apiType);
|
11 |
+
}
|
12 |
+
|
13 |
+
public static function setAppKey($appKey = '')
|
14 |
+
{
|
15 |
+
return self::getInstance()->setPublicKey($appKey);
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function setSecretKey($secretKey = '')
|
19 |
+
{
|
20 |
+
return self::getInstance()->setPrivateKey($secretKey);
|
21 |
+
}
|
22 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Card.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Card
|
4 |
+
{
|
5 |
+
protected $fields = array();
|
6 |
+
|
7 |
+
public function __construct($details = array())
|
8 |
+
{
|
9 |
+
$this->fields = (array) $details;
|
10 |
+
}
|
11 |
+
|
12 |
+
public function __get($property)
|
13 |
+
{
|
14 |
+
return isset($this->fields[$property]) ? $this->fields[$property] : null;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getToken()
|
18 |
+
{
|
19 |
+
return $this->token;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getType()
|
23 |
+
{
|
24 |
+
return $this->type;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getAlias()
|
28 |
+
{
|
29 |
+
return $this->last4;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getMonthExpirationDate()
|
33 |
+
{
|
34 |
+
return $this->exp_month;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getYearExpirationDate()
|
38 |
+
{
|
39 |
+
return $this->exp_year;
|
40 |
+
}
|
41 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Charge.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Charge extends Paymentwall_ApiObject implements Paymentwall_ApiObjectInterface
|
4 |
+
{
|
5 |
+
public function getId()
|
6 |
+
{
|
7 |
+
return $this->id;
|
8 |
+
}
|
9 |
+
|
10 |
+
public function isTest()
|
11 |
+
{
|
12 |
+
return $this->test;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function isSuccessful()
|
16 |
+
{
|
17 |
+
return $this->object == self::API_OBJECT_CHARGE;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function isCaptured()
|
21 |
+
{
|
22 |
+
return $this->captured;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function isUnderReview()
|
26 |
+
{
|
27 |
+
return $this->risk == 'pending';
|
28 |
+
}
|
29 |
+
|
30 |
+
public function isRefunded()
|
31 |
+
{
|
32 |
+
return $this->refunded;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function setPropertiesFromResponse($response = '') {
|
36 |
+
parent::setPropertiesFromResponse($response);
|
37 |
+
$this->card = new Paymentwall_Card($this->card);
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getEndpointName()
|
41 |
+
{
|
42 |
+
return self::API_OBJECT_CHARGE;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getCard()
|
46 |
+
{
|
47 |
+
return new Paymentwall_Card($this->card);
|
48 |
+
}
|
49 |
+
|
50 |
+
public function get()
|
51 |
+
{
|
52 |
+
return $this->doApiAction('', 'get');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function refund()
|
56 |
+
{
|
57 |
+
return $this->doApiAction('refund');
|
58 |
+
}
|
59 |
+
|
60 |
+
public function capture()
|
61 |
+
{
|
62 |
+
return $this->doApiAction('capture');
|
63 |
+
}
|
64 |
+
|
65 |
+
public function void()
|
66 |
+
{
|
67 |
+
return $this->doApiAction('void');
|
68 |
+
}
|
69 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Config.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Config
|
4 |
+
{
|
5 |
+
const VERSION = '2.0.0';
|
6 |
+
|
7 |
+
const API_BASE_URL = 'https://api.paymentwall.com/api';
|
8 |
+
|
9 |
+
const API_VC = 1;
|
10 |
+
const API_GOODS = 2;
|
11 |
+
const API_CART = 3;
|
12 |
+
|
13 |
+
protected $apiType = self::API_GOODS;
|
14 |
+
protected $publicKey;
|
15 |
+
protected $privateKey;
|
16 |
+
protected $apiBaseUrl = self::API_BASE_URL;
|
17 |
+
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
public function getApiBaseUrl()
|
21 |
+
{
|
22 |
+
return $this->apiBaseUrl;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function setApiBaseUrl($url = '')
|
26 |
+
{
|
27 |
+
$this->apiBaseUrl = $url;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getLocalApiType()
|
31 |
+
{
|
32 |
+
return $this->apiType;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function setLocalApiType($apiType = 0)
|
36 |
+
{
|
37 |
+
$this->apiType = $apiType;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getPublicKey()
|
41 |
+
{
|
42 |
+
return $this->publicKey;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function setPublicKey($key = '')
|
46 |
+
{
|
47 |
+
$this->publicKey = $key;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getPrivateKey()
|
51 |
+
{
|
52 |
+
return $this->privateKey;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function setPrivateKey($key = '')
|
56 |
+
{
|
57 |
+
$this->privateKey = $key;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getVersion()
|
61 |
+
{
|
62 |
+
return self::VERSION;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function isTest()
|
66 |
+
{
|
67 |
+
return strpos($this->getPublicKey(), 't_') === 0;
|
68 |
+
}
|
69 |
+
|
70 |
+
public function set($config = array())
|
71 |
+
{
|
72 |
+
if (isset($config['api_base_url'])) {
|
73 |
+
$this->setApiBaseUrl($config['api_base_url']);
|
74 |
+
}
|
75 |
+
if (isset($config['api_type'])) {
|
76 |
+
$this->setLocalApiType($config['api_type']);
|
77 |
+
}
|
78 |
+
if (isset($config['public_key'])) {
|
79 |
+
$this->setPublicKey($config['public_key']);
|
80 |
+
}
|
81 |
+
if (isset($config['private_key'])) {
|
82 |
+
$this->setPrivateKey($config['private_key']);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
public static function getInstance()
|
87 |
+
{
|
88 |
+
if (!isset(self::$instance)) {
|
89 |
+
$className = __CLASS__;
|
90 |
+
self::$instance = new $className;
|
91 |
+
}
|
92 |
+
return self::$instance;
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function __construct()
|
96 |
+
{
|
97 |
+
}
|
98 |
+
|
99 |
+
private function __clone()
|
100 |
+
{
|
101 |
+
}
|
102 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/HttpAction.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_HttpAction extends Paymentwall_Instance
|
4 |
+
{
|
5 |
+
protected $apiObject;
|
6 |
+
protected $apiParams = array();
|
7 |
+
protected $apiHeaders = array();
|
8 |
+
|
9 |
+
public function __construct($object, $params = array(), $headers = array())
|
10 |
+
{
|
11 |
+
$this->setApiObject($object);
|
12 |
+
$this->setApiParams($params);
|
13 |
+
$this->setApiHeaders($headers);
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getApiObject()
|
17 |
+
{
|
18 |
+
return $this->apiObject;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function setApiObject(Paymentwall_ApiObject $apiObject)
|
22 |
+
{
|
23 |
+
$this->apiObject = $apiObject;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getApiParams()
|
27 |
+
{
|
28 |
+
return $this->apiParams;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function setApiParams($params = array())
|
32 |
+
{
|
33 |
+
$this->apiParams = $params;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getApiHeaders()
|
37 |
+
{
|
38 |
+
return $this->apiHeaders;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function setApiHeaders($headers = array())
|
42 |
+
{
|
43 |
+
$this->apiHeaders = $headers;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function run()
|
47 |
+
{
|
48 |
+
$result = null;
|
49 |
+
|
50 |
+
if ($this->getApiObject() instanceof Paymentwall_ApiObject) {
|
51 |
+
$result = $this->apiObjectPostRequest($this->getApiObject());
|
52 |
+
}
|
53 |
+
|
54 |
+
return $result;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function apiObjectPostRequest(Paymentwall_ApiObject $object)
|
58 |
+
{
|
59 |
+
return $this->request('POST', $object->getApiUrl(), $this->getApiParams(), $this->getApiHeaders());
|
60 |
+
}
|
61 |
+
|
62 |
+
public function post($url = '')
|
63 |
+
{
|
64 |
+
return $this->request('POST', $url, $this->getApiParams(), $this->getApiHeaders());
|
65 |
+
}
|
66 |
+
|
67 |
+
public function get($url = '')
|
68 |
+
{
|
69 |
+
return $this->request('GET', $url, $this->getApiParams(), $this->getApiHeaders());
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function request($httpVerb = '', $url = '', $params = array(), $customHeaders = array())
|
73 |
+
{
|
74 |
+
$curl = curl_init();
|
75 |
+
|
76 |
+
$headers = array(
|
77 |
+
$this->getLibraryDefaultRequestHeader()
|
78 |
+
);
|
79 |
+
|
80 |
+
if (!empty($customHeaders)) {
|
81 |
+
$headers = array_merge($headers, $customHeaders);
|
82 |
+
}
|
83 |
+
|
84 |
+
if (!empty($params)) {
|
85 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
|
86 |
+
}
|
87 |
+
|
88 |
+
// CURL_SSLVERSION_TLSv1_2 is defined in libcurl version 7.34 or later
|
89 |
+
// but unless PHP has been compiled with the correct libcurl headers it
|
90 |
+
// won't be defined in your PHP instance. PHP > 5.5.19 or > 5.6.3
|
91 |
+
if (! defined('CURL_SSLVERSION_TLSv1_2')) {
|
92 |
+
define('CURL_SSLVERSION_TLSv1_2', 6);
|
93 |
+
}
|
94 |
+
|
95 |
+
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
|
96 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
|
97 |
+
curl_setopt($curl, CURLOPT_URL, $url);
|
98 |
+
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
|
99 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
100 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
101 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
102 |
+
|
103 |
+
$response = curl_exec($curl);
|
104 |
+
|
105 |
+
curl_close($curl);
|
106 |
+
|
107 |
+
return $this->prepareResponse($response);
|
108 |
+
}
|
109 |
+
|
110 |
+
protected function getLibraryDefaultRequestHeader()
|
111 |
+
{
|
112 |
+
return 'User-Agent: Paymentwall PHP Library v. ' . $this->getConfig()->getVersion();
|
113 |
+
}
|
114 |
+
|
115 |
+
protected function prepareResponse($string = '')
|
116 |
+
{
|
117 |
+
return preg_replace('/\x{FEFF}/u', '', $string);
|
118 |
+
}
|
119 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Instance.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Paymentwall_Instance
|
4 |
+
{
|
5 |
+
protected $config;
|
6 |
+
protected $errors = array();
|
7 |
+
|
8 |
+
public function getErrorSummary()
|
9 |
+
{
|
10 |
+
return implode("\n", $this->getErrors());
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function getConfig()
|
14 |
+
{
|
15 |
+
if (!isset($this->config)) {
|
16 |
+
$this->config = Paymentwall_Config::getInstance();
|
17 |
+
}
|
18 |
+
return $this->config;
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function getApiBaseUrl()
|
22 |
+
{
|
23 |
+
return $this->getConfig()->getApiBaseUrl();
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function getApiType()
|
27 |
+
{
|
28 |
+
return $this->getConfig()->getLocalApiType();
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function getPublicKey()
|
32 |
+
{
|
33 |
+
return $this->getConfig()->getPublicKey();
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function getPrivateKey()
|
37 |
+
{
|
38 |
+
return $this->getConfig()->getPrivateKey();
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function appendToErrors($error = '')
|
42 |
+
{
|
43 |
+
$this->errors[] = $error;
|
44 |
+
}
|
45 |
+
|
46 |
+
protected function getErrors()
|
47 |
+
{
|
48 |
+
return $this->errors;
|
49 |
+
}
|
50 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/OneTimeToken.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_OneTimeToken extends Paymentwall_ApiObject
|
4 |
+
{
|
5 |
+
const GATEWAY_TOKENIZATION_URL = 'https://pwgateway.com/api/token';
|
6 |
+
|
7 |
+
public function getToken()
|
8 |
+
{
|
9 |
+
return $this->token;
|
10 |
+
}
|
11 |
+
|
12 |
+
public function isTest()
|
13 |
+
{
|
14 |
+
return $this->test;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function isActive()
|
18 |
+
{
|
19 |
+
return $this->active;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getExpirationTime()
|
23 |
+
{
|
24 |
+
return $this->expires_in;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getEndpointName()
|
28 |
+
{
|
29 |
+
return self::API_OBJECT_ONE_TIME_TOKEN;
|
30 |
+
}
|
31 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Pingback.php
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Pingback extends Paymentwall_Instance
|
4 |
+
{
|
5 |
+
const PINGBACK_TYPE_REGULAR = 0;
|
6 |
+
const PINGBACK_TYPE_GOODWILL = 1;
|
7 |
+
const PINGBACK_TYPE_NEGATIVE = 2;
|
8 |
+
|
9 |
+
const PINGBACK_TYPE_RISK_UNDER_REVIEW = 200;
|
10 |
+
const PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED = 201;
|
11 |
+
const PINGBACK_TYPE_RISK_REVIEWED_DECLINED = 202;
|
12 |
+
|
13 |
+
const PINGBACK_TYPE_SUBSCRIPTION_CANCELLATION = 12;
|
14 |
+
const PINGBACK_TYPE_SUBSCRIPTION_EXPIRED = 13;
|
15 |
+
const PINGBACK_TYPE_SUBSCRIPTION_PAYMENT_FAILED = 14;
|
16 |
+
|
17 |
+
protected $parameters;
|
18 |
+
protected $ipAddress;
|
19 |
+
|
20 |
+
public function __construct(array $parameters, $ipAddress)
|
21 |
+
{
|
22 |
+
$this->parameters = $parameters;
|
23 |
+
$this->ipAddress = $ipAddress;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function validate($skipIpWhitelistCheck = false)
|
27 |
+
{
|
28 |
+
$validated = false;
|
29 |
+
|
30 |
+
if ($this->isParametersValid()) {
|
31 |
+
|
32 |
+
if ($this->isIpAddressValid() || $skipIpWhitelistCheck) {
|
33 |
+
|
34 |
+
if ($this->isSignatureValid()) {
|
35 |
+
|
36 |
+
$validated = true;
|
37 |
+
|
38 |
+
} else {
|
39 |
+
$this->appendToErrors('Wrong signature');
|
40 |
+
}
|
41 |
+
|
42 |
+
} else {
|
43 |
+
$this->appendToErrors('IP address is not whitelisted');
|
44 |
+
}
|
45 |
+
|
46 |
+
} else {
|
47 |
+
$this->appendToErrors('Missing parameters');
|
48 |
+
}
|
49 |
+
|
50 |
+
return $validated;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function isSignatureValid()
|
54 |
+
{
|
55 |
+
$signatureParamsToSign = array();
|
56 |
+
|
57 |
+
if ($this->getApiType() == Paymentwall_Config::API_VC) {
|
58 |
+
|
59 |
+
$signatureParams = array('uid', 'currency', 'type', 'ref');
|
60 |
+
|
61 |
+
} else if ($this->getApiType() == Paymentwall_Config::API_GOODS) {
|
62 |
+
|
63 |
+
$signatureParams = array('uid', 'goodsid', 'slength', 'speriod', 'type', 'ref');
|
64 |
+
|
65 |
+
} else { // API_CART
|
66 |
+
|
67 |
+
$signatureParams = array('uid', 'goodsid', 'type', 'ref');
|
68 |
+
|
69 |
+
$this->parameters['sign_version'] = Paymentwall_Signature_Abstract::VERSION_TWO;
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
if (empty($this->parameters['sign_version']) || $this->parameters['sign_version'] == Paymentwall_Signature_Abstract::VERSION_ONE) {
|
74 |
+
|
75 |
+
foreach ($signatureParams as $field) {
|
76 |
+
$signatureParamsToSign[$field] = isset($this->parameters[$field]) ? $this->parameters[$field] : null;
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->parameters['sign_version'] = Paymentwall_Signature_Abstract::VERSION_ONE;
|
80 |
+
|
81 |
+
} else {
|
82 |
+
$signatureParamsToSign = $this->parameters;
|
83 |
+
}
|
84 |
+
|
85 |
+
$pingbackSignatureModel = new Paymentwall_Signature_Pingback();
|
86 |
+
$signatureCalculated = $pingbackSignatureModel->calculate(
|
87 |
+
$signatureParamsToSign,
|
88 |
+
$this->parameters['sign_version']
|
89 |
+
);
|
90 |
+
|
91 |
+
$signature = isset($this->parameters['sig']) ? $this->parameters['sig'] : null;
|
92 |
+
|
93 |
+
return $signature == $signatureCalculated;
|
94 |
+
}
|
95 |
+
|
96 |
+
public function isIpAddressValid()
|
97 |
+
{
|
98 |
+
$ipsWhitelist = array(
|
99 |
+
'174.36.92.186',
|
100 |
+
'174.36.96.66',
|
101 |
+
'174.36.92.187',
|
102 |
+
'174.36.92.192',
|
103 |
+
'174.37.14.28'
|
104 |
+
);
|
105 |
+
|
106 |
+
return in_array($this->ipAddress, $ipsWhitelist);
|
107 |
+
}
|
108 |
+
|
109 |
+
public function isParametersValid()
|
110 |
+
{
|
111 |
+
$errorsNumber = 0;
|
112 |
+
|
113 |
+
if ($this->getApiType() == Paymentwall_Config::API_VC) {
|
114 |
+
$requiredParams = array('uid', 'currency', 'type', 'ref', 'sig');
|
115 |
+
} else if ($this->getApiType() == Paymentwall_Config::API_GOODS) {
|
116 |
+
$requiredParams = array('uid', 'goodsid', 'type', 'ref', 'sig');
|
117 |
+
} else { // Cart API
|
118 |
+
$requiredParams = array('uid', 'goodsid', 'type', 'ref', 'sig');
|
119 |
+
}
|
120 |
+
|
121 |
+
foreach ($requiredParams as $field) {
|
122 |
+
if (!isset($this->parameters[$field]) || $this->parameters[$field] === '') {
|
123 |
+
$this->appendToErrors('Parameter ' . $field . ' is missing');
|
124 |
+
$errorsNumber++;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
return $errorsNumber == 0;
|
129 |
+
}
|
130 |
+
|
131 |
+
public function getParameter($param)
|
132 |
+
{
|
133 |
+
return isset($this->parameters[$param]) ? $this->parameters[$param] : null;
|
134 |
+
}
|
135 |
+
|
136 |
+
public function getType()
|
137 |
+
{
|
138 |
+
return isset($this->parameters['type']) ? intval($this->parameters['type']) : null;
|
139 |
+
}
|
140 |
+
|
141 |
+
public function getTypeVerbal() {
|
142 |
+
$typeVerbal = '';
|
143 |
+
$pingbackTypes = array(
|
144 |
+
self::PINGBACK_TYPE_SUBSCRIPTION_CANCELLATION => 'user_subscription_cancellation',
|
145 |
+
self::PINGBACK_TYPE_SUBSCRIPTION_EXPIRED => 'user_subscription_expired',
|
146 |
+
self::PINGBACK_TYPE_SUBSCRIPTION_PAYMENT_FAILED => 'user_subscription_payment_failed'
|
147 |
+
);
|
148 |
+
|
149 |
+
if (!empty($this->parameters['type'])) {
|
150 |
+
if (array_key_exists($this->parameters['type'], $pingbackTypes)) {
|
151 |
+
$typeVerbal = $pingbackTypes[$this->parameters['type']];
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
return $typeVerbal;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function getUserId()
|
159 |
+
{
|
160 |
+
return $this->getParameter('uid');
|
161 |
+
}
|
162 |
+
|
163 |
+
public function getVirtualCurrencyAmount()
|
164 |
+
{
|
165 |
+
return $this->getParameter('currency');
|
166 |
+
}
|
167 |
+
|
168 |
+
public function getProductId()
|
169 |
+
{
|
170 |
+
return $this->getParameter('goodsid');
|
171 |
+
}
|
172 |
+
|
173 |
+
public function getProductPeriodLength()
|
174 |
+
{
|
175 |
+
return $this->getParameter('slength');
|
176 |
+
}
|
177 |
+
|
178 |
+
public function getProductPeriodType()
|
179 |
+
{
|
180 |
+
return $this->getParameter('speriod');
|
181 |
+
}
|
182 |
+
|
183 |
+
public function getProduct() {
|
184 |
+
return new Paymentwall_Product(
|
185 |
+
$this->getProductId(),
|
186 |
+
0,
|
187 |
+
null,
|
188 |
+
null,
|
189 |
+
$this->getProductPeriodLength() > 0 ? Paymentwall_Product::TYPE_SUBSCRIPTION : Paymentwall_Product::TYPE_FIXED,
|
190 |
+
$this->getProductPeriodLength(),
|
191 |
+
$this->getProductPeriodType()
|
192 |
+
);
|
193 |
+
}
|
194 |
+
|
195 |
+
public function getProducts() {
|
196 |
+
$result = array();
|
197 |
+
$productIds = $this->getParameter('goodsid');
|
198 |
+
|
199 |
+
if (!empty($productIds)) {
|
200 |
+
foreach ($productIds as $Id) {
|
201 |
+
$result[] = new Paymentwall_Product($Id);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
return $result;
|
206 |
+
}
|
207 |
+
|
208 |
+
public function getReferenceId()
|
209 |
+
{
|
210 |
+
return $this->getParameter('ref');
|
211 |
+
}
|
212 |
+
|
213 |
+
public function getPingbackUniqueId()
|
214 |
+
{
|
215 |
+
return $this->getReferenceId() . '_' . $this->getType();
|
216 |
+
}
|
217 |
+
|
218 |
+
public function isDeliverable()
|
219 |
+
{
|
220 |
+
return (
|
221 |
+
$this->getType() === self::PINGBACK_TYPE_REGULAR ||
|
222 |
+
$this->getType() === self::PINGBACK_TYPE_GOODWILL ||
|
223 |
+
$this->getType() === self::PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED
|
224 |
+
);
|
225 |
+
}
|
226 |
+
|
227 |
+
public function isCancelable()
|
228 |
+
{
|
229 |
+
return (
|
230 |
+
$this->getType() === self::PINGBACK_TYPE_NEGATIVE
|
231 |
+
|| $this->getType() === self::PINGBACK_TYPE_RISK_REVIEWED_DECLINED
|
232 |
+
);
|
233 |
+
}
|
234 |
+
|
235 |
+
public function isUnderReview() {
|
236 |
+
return $this->getType() === self::PINGBACK_TYPE_RISK_UNDER_REVIEW;
|
237 |
+
}
|
238 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Product.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Product
|
4 |
+
{
|
5 |
+
const TYPE_SUBSCRIPTION = 'subscription';
|
6 |
+
const TYPE_FIXED = 'fixed';
|
7 |
+
|
8 |
+
const PERIOD_TYPE_DAY = 'day';
|
9 |
+
const PERIOD_TYPE_WEEK = 'week';
|
10 |
+
const PERIOD_TYPE_MONTH = 'month';
|
11 |
+
const PERIOD_TYPE_YEAR = 'year';
|
12 |
+
|
13 |
+
public function __construct($productId, $amount = 0.0, $currencyCode = null, $name = null, $productType = self::TYPE_FIXED, $periodLength = 0, $periodType = null, $recurring = false, Paymentwall_Product $trialProduct = null)
|
14 |
+
{
|
15 |
+
$this->productId = $productId;
|
16 |
+
$this->amount = round($amount, 2);
|
17 |
+
$this->currencyCode = $currencyCode;
|
18 |
+
$this->name = $name;
|
19 |
+
$this->productType = $productType;
|
20 |
+
$this->periodLength = $periodLength;
|
21 |
+
$this->periodType = $periodType;
|
22 |
+
$this->recurring = $recurring;
|
23 |
+
$this->trialProduct = ($productType == Paymentwall_Product::TYPE_SUBSCRIPTION && $recurring) ? $trialProduct : null;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getId()
|
27 |
+
{
|
28 |
+
return $this->productId;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getAmount()
|
32 |
+
{
|
33 |
+
return $this->amount;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getCurrencyCode()
|
37 |
+
{
|
38 |
+
return $this->currencyCode;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getName()
|
42 |
+
{
|
43 |
+
return $this->name;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getType()
|
47 |
+
{
|
48 |
+
return $this->productType;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getPeriodType()
|
52 |
+
{
|
53 |
+
return $this->periodType;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getPeriodLength()
|
57 |
+
{
|
58 |
+
return $this->periodLength;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function isRecurring()
|
62 |
+
{
|
63 |
+
return $this->recurring;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function getTrialProduct()
|
67 |
+
{
|
68 |
+
return $this->trialProduct;
|
69 |
+
}
|
70 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Response/Abstract.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Paymentwall_Response_Abstract
|
4 |
+
{
|
5 |
+
protected $response;
|
6 |
+
|
7 |
+
public function __construct($response = array())
|
8 |
+
{
|
9 |
+
$this->response = $response;
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function wrapInternalError()
|
13 |
+
{
|
14 |
+
$response = array(
|
15 |
+
'success' => 0,
|
16 |
+
'error' => array(
|
17 |
+
'message' => 'Internal error'
|
18 |
+
)
|
19 |
+
);
|
20 |
+
return json_encode($response);
|
21 |
+
}
|
22 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Response/Error.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Response_Error extends Paymentwall_Response_Abstract implements Paymentwall_Response_Interface
|
4 |
+
{
|
5 |
+
|
6 |
+
public function process()
|
7 |
+
{
|
8 |
+
if (!isset($this->response)) {
|
9 |
+
return $this->wrapInternalError();
|
10 |
+
}
|
11 |
+
|
12 |
+
$response = array(
|
13 |
+
'success' => 0,
|
14 |
+
'error' => $this->getErrorMessageAndCode($this->response)
|
15 |
+
);
|
16 |
+
|
17 |
+
return json_encode($response);
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getErrorMessageAndCode($response)
|
21 |
+
{
|
22 |
+
return array(
|
23 |
+
'message' => $response['error'],
|
24 |
+
'code' => $response['code']
|
25 |
+
);
|
26 |
+
}
|
27 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Response/Factory.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Response_Factory
|
4 |
+
{
|
5 |
+
const CLASS_NAME_PREFIX = 'Paymentwall_Response_';
|
6 |
+
|
7 |
+
const RESPONSE_SUCCESS = 'success';
|
8 |
+
const RESPONSE_ERROR = 'error';
|
9 |
+
|
10 |
+
public static function get($response = array())
|
11 |
+
{
|
12 |
+
$responseModel = null;
|
13 |
+
|
14 |
+
$responseModel = self::getClassName($response);
|
15 |
+
|
16 |
+
return new $responseModel($response);
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function getClassName($response = array()) {
|
20 |
+
$responseType = (isset($response['type']) && $response['type'] == 'Error') ? self::RESPONSE_ERROR : self::RESPONSE_SUCCESS;
|
21 |
+
return self::CLASS_NAME_PREFIX . ucfirst($responseType);
|
22 |
+
}
|
23 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Response/Interface.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
interface Paymentwall_Response_Interface
|
4 |
+
{
|
5 |
+
public function process();
|
6 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Response/Success.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Response_Success extends Paymentwall_Response_Abstract implements Paymentwall_Response_Interface
|
4 |
+
{
|
5 |
+
public function process()
|
6 |
+
{
|
7 |
+
if (!isset($this->response)) {
|
8 |
+
return $this->wrapInternalError();
|
9 |
+
}
|
10 |
+
|
11 |
+
$response = array(
|
12 |
+
'success' => 1
|
13 |
+
);
|
14 |
+
|
15 |
+
return json_encode($response);
|
16 |
+
}
|
17 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Signature/Abstract.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Paymentwall_Signature_Abstract extends Paymentwall_Instance
|
4 |
+
{
|
5 |
+
const VERSION_ONE = 1;
|
6 |
+
const VERSION_TWO = 2;
|
7 |
+
const VERSION_THREE = 3;
|
8 |
+
const DEFAULT_VERSION = 3;
|
9 |
+
|
10 |
+
abstract function process($params = array(), $version = 0);
|
11 |
+
|
12 |
+
abstract function prepareParams($params = array(), $baseString = '');
|
13 |
+
|
14 |
+
public final function calculate($params = array(), $version = 0)
|
15 |
+
{
|
16 |
+
return $this->process($params, $version);
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function ksortMultiDimensional(&$params = array())
|
20 |
+
{
|
21 |
+
if (is_array($params)) {
|
22 |
+
ksort($params);
|
23 |
+
foreach ($params as &$p) {
|
24 |
+
if (is_array($p)) {
|
25 |
+
ksort($p);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Signature/Pingback.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Signature_Pingback extends Paymentwall_Signature_Abstract
|
4 |
+
{
|
5 |
+
public function process($params = array(), $version = 0)
|
6 |
+
{
|
7 |
+
$baseString = '';
|
8 |
+
|
9 |
+
unset($params['sig']);
|
10 |
+
|
11 |
+
if ($version == self::VERSION_TWO || $version == self::VERSION_THREE) {
|
12 |
+
self::ksortMultiDimensional($params);
|
13 |
+
}
|
14 |
+
|
15 |
+
$baseString = $this->prepareParams($params, $baseString);
|
16 |
+
|
17 |
+
$baseString .= $this->getConfig()->getPrivateKey();
|
18 |
+
|
19 |
+
if ($version == self::VERSION_THREE) {
|
20 |
+
return hash('sha256', $baseString);
|
21 |
+
}
|
22 |
+
|
23 |
+
return md5($baseString);
|
24 |
+
}
|
25 |
+
|
26 |
+
public function prepareParams($params = array(), $baseString = '')
|
27 |
+
{
|
28 |
+
foreach ($params as $key => $value) {
|
29 |
+
if (is_array($value)) {
|
30 |
+
foreach ($value as $k => $v) {
|
31 |
+
$baseString .= $key . '[' . $k . ']' . '=' . $v;
|
32 |
+
}
|
33 |
+
} else {
|
34 |
+
$baseString .= $key . '=' . $value;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
return $baseString;
|
38 |
+
}
|
39 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Signature/Widget.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Signature_Widget extends Paymentwall_Signature_Abstract
|
4 |
+
{
|
5 |
+
public function process($params = array(), $version = 0)
|
6 |
+
{
|
7 |
+
$baseString = '';
|
8 |
+
|
9 |
+
if ($version == self::VERSION_ONE) {
|
10 |
+
|
11 |
+
$baseString .= isset($params['uid']) ? $params['uid'] : '';
|
12 |
+
$baseString .= $this->getConfig()->getPrivateKey();
|
13 |
+
|
14 |
+
return md5($baseString);
|
15 |
+
|
16 |
+
} else {
|
17 |
+
|
18 |
+
self::ksortMultiDimensional($params);
|
19 |
+
|
20 |
+
$baseString = $this->prepareParams($params, $baseString);
|
21 |
+
|
22 |
+
$baseString .= $this->getConfig()->getPrivateKey();
|
23 |
+
|
24 |
+
if ($version == self::VERSION_TWO) {
|
25 |
+
return md5($baseString);
|
26 |
+
}
|
27 |
+
|
28 |
+
return hash('sha256', $baseString);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
public function prepareParams($params = array(), $baseString = '')
|
33 |
+
{
|
34 |
+
foreach ($params as $key => $value) {
|
35 |
+
if (!isset($value)) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
if (is_array($value)) {
|
39 |
+
foreach ($value as $k => $v) {
|
40 |
+
$baseString .= $key . '[' . $k . ']' . '=' . ($v === false ? '0' : $v);
|
41 |
+
}
|
42 |
+
} else {
|
43 |
+
$baseString .= $key . '=' . ($value === false ? '0' : $value);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
return $baseString;
|
47 |
+
}
|
48 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Subscription.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Subscription extends Paymentwall_ApiObject
|
4 |
+
{
|
5 |
+
public function getId()
|
6 |
+
{
|
7 |
+
return $this->id;
|
8 |
+
}
|
9 |
+
|
10 |
+
public function isTrial()
|
11 |
+
{
|
12 |
+
return $this->is_trial;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function isActive()
|
16 |
+
{
|
17 |
+
return $this->active;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function isSuccessful()
|
21 |
+
{
|
22 |
+
return $this->object == self::API_OBJECT_SUBSCRIPTION;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function isExpired()
|
26 |
+
{
|
27 |
+
return $this->expired;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getEndpointName()
|
31 |
+
{
|
32 |
+
return self::API_OBJECT_SUBSCRIPTION;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function get()
|
36 |
+
{
|
37 |
+
return $this->doApiAction('', 'get');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function cancel()
|
41 |
+
{
|
42 |
+
return $this->doApiAction('cancel');
|
43 |
+
}
|
44 |
+
}
|
lib/paymentwall-php/lib/Paymentwall/Widget.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_Widget extends Paymentwall_Instance
|
4 |
+
{
|
5 |
+
const CONTROLLER_PAYMENT_VIRTUAL_CURRENCY = 'ps';
|
6 |
+
const CONTROLLER_PAYMENT_DIGITAL_GOODS = 'subscription';
|
7 |
+
const CONTROLLER_PAYMENT_CART = 'cart';
|
8 |
+
|
9 |
+
protected $userId;
|
10 |
+
protected $widgetCode;
|
11 |
+
protected $products;
|
12 |
+
protected $extraParams;
|
13 |
+
|
14 |
+
public function __construct($userId, $widgetCode = '', $products = array(), $extraParams = array()) {
|
15 |
+
$this->userId = $userId;
|
16 |
+
$this->widgetCode = $widgetCode;
|
17 |
+
$this->products = $products;
|
18 |
+
$this->extraParams = $extraParams;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getUrl()
|
22 |
+
{
|
23 |
+
$params = array(
|
24 |
+
'key' => $this->getPublicKey(),
|
25 |
+
'uid' => $this->userId,
|
26 |
+
'widget' => $this->widgetCode
|
27 |
+
);
|
28 |
+
|
29 |
+
$productsNumber = count($this->products);
|
30 |
+
|
31 |
+
if ($this->getApiType() == Paymentwall_Config::API_GOODS) {
|
32 |
+
|
33 |
+
if (!empty($this->products)) {
|
34 |
+
|
35 |
+
if ($productsNumber == 1) {
|
36 |
+
|
37 |
+
$product = current($this->products);
|
38 |
+
|
39 |
+
if ($product->getTrialProduct() instanceof Paymentwall_Product) {
|
40 |
+
$postTrialProduct = $product;
|
41 |
+
$product = $product->getTrialProduct();
|
42 |
+
}
|
43 |
+
|
44 |
+
$params['amount'] = $product->getAmount();
|
45 |
+
$params['currencyCode'] = $product->getCurrencyCode();
|
46 |
+
$params['ag_name'] = $product->getName();
|
47 |
+
$params['ag_external_id'] = $product->getId();
|
48 |
+
$params['ag_type'] = $product->getType();
|
49 |
+
|
50 |
+
if ($product->getType() == Paymentwall_Product::TYPE_SUBSCRIPTION) {
|
51 |
+
$params['ag_period_length'] = $product->getPeriodLength();
|
52 |
+
$params['ag_period_type'] = $product->getPeriodType();
|
53 |
+
if ($product->isRecurring()) {
|
54 |
+
|
55 |
+
$params['ag_recurring'] = intval($product->isRecurring());
|
56 |
+
|
57 |
+
if (isset($postTrialProduct)) {
|
58 |
+
$params['ag_trial'] = 1;
|
59 |
+
$params['ag_post_trial_external_id'] = $postTrialProduct->getId();
|
60 |
+
$params['ag_post_trial_period_length'] = $postTrialProduct->getPeriodLength();
|
61 |
+
$params['ag_post_trial_period_type'] = $postTrialProduct->getPeriodType();
|
62 |
+
$params['ag_post_trial_name'] = $postTrialProduct->getName();
|
63 |
+
$params['post_trial_amount'] = $postTrialProduct->getAmount();
|
64 |
+
$params['post_trial_currencyCode'] = $postTrialProduct->getCurrencyCode();
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
} else {
|
71 |
+
//TODO: $this->appendToErrors('Only 1 product is allowed in flexible widget call');
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
} else if ($this->getApiType() == Paymentwall_Config::API_CART) {
|
77 |
+
|
78 |
+
$index = 0;
|
79 |
+
foreach ($this->products as $product) {
|
80 |
+
$params['external_ids[' . $index . ']'] = $product->getId();
|
81 |
+
|
82 |
+
if (isset($product->amount)) {
|
83 |
+
$params['prices[' . $index . ']'] = $product->getAmount();
|
84 |
+
}
|
85 |
+
if (isset($product->currencyCode)) {
|
86 |
+
$params['currencies[' . $index . ']'] = $product->getCurrencyCode();
|
87 |
+
}
|
88 |
+
|
89 |
+
$index++;
|
90 |
+
}
|
91 |
+
unset($index);
|
92 |
+
}
|
93 |
+
|
94 |
+
$params['sign_version'] = $signatureVersion = $this->getDefaultSignatureVersion();
|
95 |
+
|
96 |
+
if (!empty($this->extraParams['sign_version'])) {
|
97 |
+
$signatureVersion = $params['sign_version'] = $this->extraParams['sign_version'];
|
98 |
+
}
|
99 |
+
|
100 |
+
$params = array_merge($params, $this->extraParams);
|
101 |
+
|
102 |
+
$widgetSignatureModel = new Paymentwall_Signature_Widget();
|
103 |
+
$params['sign'] = $widgetSignatureModel->calculate(
|
104 |
+
$params,
|
105 |
+
$signatureVersion
|
106 |
+
);
|
107 |
+
|
108 |
+
return $this->getApiBaseUrl() . '/' . $this->buildController($this->widgetCode) . '?' . http_build_query($params);
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getHtmlCode($attributes = array())
|
112 |
+
{
|
113 |
+
$defaultAttributes = array(
|
114 |
+
'frameborder' => '0',
|
115 |
+
'width' => '750',
|
116 |
+
'height' => '800'
|
117 |
+
);
|
118 |
+
|
119 |
+
$attributes = array_merge($defaultAttributes, $attributes);
|
120 |
+
|
121 |
+
$attributesQuery = '';
|
122 |
+
foreach ($attributes as $attr => $value) {
|
123 |
+
$attributesQuery .= ' ' . $attr . '="' . $value . '"';
|
124 |
+
}
|
125 |
+
|
126 |
+
return '<iframe src="' . $this->getUrl() . '" ' . $attributesQuery . '></iframe>';
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
protected function getDefaultSignatureVersion() {
|
131 |
+
return $this->getApiType() != Paymentwall_Config::API_CART ? Paymentwall_Signature_Abstract::DEFAULT_VERSION : Paymentwall_Signature_Abstract::VERSION_TWO;
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function buildController($widget = '')
|
135 |
+
{
|
136 |
+
$controller = null;
|
137 |
+
$isPaymentWidget = !preg_match('/^w|s|mw/', $widget);
|
138 |
+
|
139 |
+
if ($this->getApiType()== Paymentwall_Config::API_VC) {
|
140 |
+
if ($isPaymentWidget) {
|
141 |
+
$controller = self::CONTROLLER_PAYMENT_VIRTUAL_CURRENCY;
|
142 |
+
}
|
143 |
+
} else if ($this->getApiType() == Paymentwall_Config::API_GOODS) {
|
144 |
+
/**
|
145 |
+
* @todo cover case with offer widget for digital goods for non-flexible widget call
|
146 |
+
*/
|
147 |
+
$controller = self::CONTROLLER_PAYMENT_DIGITAL_GOODS;
|
148 |
+
} else {
|
149 |
+
$controller = self::CONTROLLER_PAYMENT_CART;
|
150 |
+
}
|
151 |
+
|
152 |
+
return $controller;
|
153 |
+
}
|
154 |
+
}
|
lib/paymentwall-php/lib/paymentwall.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!function_exists('curl_init')) {
|
4 |
+
throw new Exception('CURL PHP extension is required');
|
5 |
+
}
|
6 |
+
|
7 |
+
if (!function_exists('json_decode')) {
|
8 |
+
throw new Exception('JSON PHP extension is required');
|
9 |
+
}
|
10 |
+
|
11 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Instance.php');
|
12 |
+
|
13 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Config.php');
|
14 |
+
|
15 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Base.php');
|
16 |
+
|
17 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Product.php');
|
18 |
+
|
19 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Widget.php');
|
20 |
+
|
21 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Pingback.php');
|
22 |
+
|
23 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Card.php');
|
24 |
+
|
25 |
+
require_once(dirname(__FILE__) . '/Paymentwall/ApiObject.php');
|
26 |
+
|
27 |
+
require_once(dirname(__FILE__) . '/Paymentwall/ApiObjectInterface.php');
|
28 |
+
|
29 |
+
require_once (dirname(__FILE__) . '/Paymentwall/OneTimeToken.php');
|
30 |
+
|
31 |
+
require_once (dirname(__FILE__) . '/Paymentwall/Charge.php');
|
32 |
+
|
33 |
+
require_once (dirname(__FILE__) . '/Paymentwall/Subscription.php');
|
34 |
+
|
35 |
+
require_once(dirname(__FILE__) . '/Paymentwall/HttpAction.php');
|
36 |
+
|
37 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Signature/Abstract.php');
|
38 |
+
|
39 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Signature/Widget.php');
|
40 |
+
|
41 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Signature/Pingback.php');
|
42 |
+
|
43 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Response/Factory.php');
|
44 |
+
|
45 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Response/Abstract.php');
|
46 |
+
|
47 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Response/Interface.php');
|
48 |
+
|
49 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Response/Success.php');
|
50 |
+
|
51 |
+
require_once(dirname(__FILE__) . '/Paymentwall/Response/Error.php');
|
package.xml
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>paymentwall_magento_module</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
-
<license
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Paymentwall payment extension for Magento. 120+ payment methods in more than 200 countries.</summary>
|
10 |
<description>Paymentwall payment extension for Magento. 120+ payment methods in more than 200 countries.
|
11 |
-
|
12 |
-
<notes>
|
13 |
-
<authors><author><name>
|
14 |
-
<date>
|
15 |
-
<time>
|
16 |
-
<contents><target name="
|
17 |
<compatible/>
|
18 |
-
<dependencies><required><php><min>5.
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>paymentwall_magento_module</name>
|
4 |
+
<version>1.1.2</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license>MITL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Paymentwall payment extension for Magento. 120+ payment methods in more than 200 countries.</summary>
|
10 |
<description>Paymentwall payment extension for Magento. 120+ payment methods in more than 200 countries.
|
11 |
+
</description>
|
12 |
+
<notes>version 1.1.2</notes>
|
13 |
+
<authors><author><name>Paymentwall</name><user>platforms</user><email>platforms@paymentwall.com</email></author></authors>
|
14 |
+
<date>2015-07-29</date>
|
15 |
+
<time>07:57:17</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Paymentwall"><dir name="Paymentwall"><dir name="Block"><dir name="Checkout"><dir name="Form"><dir name="Method"><file name="Abstract.php" hash="de9bfa933a6e1757c3bab53768ec4d62"/><file name="Pwbrick.php" hash="c01cabde8670bdff801534fe283b0534"/><file name="Pwlocal.php" hash="2d4a1fb4fdfcaaf5d7cf72eae4231965"/></dir></dir><dir name="Info"><dir name="Method"><file name="Pwbrick.php" hash="4d8bc2a37e04c180896a708dabf9cfa7"/><file name="Pwlocal.php" hash="52d3d7580cbdcc8bf0f98834b9a9e5a0"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4270b082a8264e63f6a82228b3e2c1d2"/></dir><dir name="Model"><dir name="Method"><file name="Abstract.php" hash="25ab2e01f2d88c883e0b4923ed66fe2e"/><file name="Pwbrick.php" hash="4a942085fcf47ed79997cd111c2ca5ef"/><file name="Pwlocal.php" hash="0080900a8f0bb52011b59cf4f8f2850b"/></dir><file name="Pingback.php" hash="c969c2dd6282f40dfefab136ad02c944"/></dir><dir name="controllers"><file name="PaymentController.php" hash="968e141ae56e9b44b480861e272ad1fb"/></dir><dir name="etc"><file name="config.xml" hash="a1d366df16f0754c21d42dffd5908879"/><file name="system.xml" hash="bfcc8a3c6c5d6836016a572999872c91"/></dir></dir></dir></target><target name="magelib"><dir name="paymentwall-php"><file name="LICENSE" hash="001561189374b83bcd6bc7f962daee8a"/><file name="README.md" hash="094753cc8aed5d682e40ae82de375ad1"/><file name="composer.json" hash="87fd93ee0a600f718e34403acd6e05f5"/><dir name="features"><dir name="bootstrap"><file name="ChargeContext.php" hash="f1d0604f2fc16dd5932535f9c24995a3"/><file name="FeatureContext.php" hash="146d6e79c6704cfb24ee6f2a7b7fba5a"/><file name="PingbackContext.php" hash="b6c86d8f3c9caa21435f47ddb2d5add1"/><file name="WidgetContext.php" hash="70c8d608eb407e346467c2a8f7162732"/></dir><file name="charge.feature" hash="04258fc641535794c48c6c55aad7f94f"/><file name="pingback.feature" hash="05869da8a3e36b6bec0293a22c1a9235"/><file name="widget.feature" hash="198999d8bf357de175f3268cc88337f6"/></dir><dir name="lib"><dir name="Paymentwall"><file name="ApiObject.php" hash="ce506a90666727844479b04a956f0ee9"/><file name="ApiObjectInterface.php" hash="4922ff334356aac33a5b159f8d001b93"/><file name="Base.php" hash="9bdae1c385327dadbd0ca5c9bbbe6107"/><file name="Card.php" hash="d8aa72a3e8ea0cdd132867164c8352c1"/><file name="Charge.php" hash="0ca04683046e9abdf3968f495db625c4"/><file name="Config.php" hash="9253f2afd5523653dd9e5fce2afc15c4"/><file name="HttpAction.php" hash="66bc684bf7476bd21ed6f3275c3ed758"/><file name="Instance.php" hash="86422afa5d43aac945021ef694b9bbc1"/><file name="OneTimeToken.php" hash="e3b9c56c34920c9b5ea53609d95acb3b"/><file name="Pingback.php" hash="fefcc3b656ab048d1f136c2b6896562a"/><file name="Product.php" hash="8b382cb28b68f77c9784e5dbc40512cb"/><dir name="Response"><file name="Abstract.php" hash="f59033acb9e14fa7a90cc2f812b6970c"/><file name="Error.php" hash="4554a0b337a2748221fb7dfae2daa8c2"/><file name="Factory.php" hash="7036d21f4682b505d5b1ff04ec79e355"/><file name="Interface.php" hash="e75f22329b3c8cbdf389aee8366ceaf3"/><file name="Success.php" hash="1f3c6c58b4273eadff5ef4b482b65187"/></dir><dir name="Signature"><file name="Abstract.php" hash="dea8f9c03b02db7462d276e3611a3a98"/><file name="Pingback.php" hash="1ab1e00037d395f9bc55bea929397927"/><file name="Widget.php" hash="2e1e2a712a0eca4f54f834838df51a59"/></dir><file name="Subscription.php" hash="7110f0292dbe01e4bc1517b5cc206ed2"/><file name="Widget.php" hash="6a91e8c0f4fe930facde52c2750824da"/></dir><file name="paymentwall.php" hash="1f3be3cc3145b4e23ad051bca926a9b8"/></dir><file name=".git" hash="0954c63dae646ef899522917f34f8484"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="paymentwall.css" hash="408b3eb269441b27d262c3abc6da78f3"/></dir><dir name="js"><file name="paymentwall.js" hash="cd7c024937af425dc35fcfdc772caf9f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="paymentwall.xml" hash="15713872f2239c9b3cb615291b36e54b"/></dir><dir name="template"><dir name="paymentwall"><dir name="checkout"><dir name="form"><dir name="method"><file name="pwbrick.phtml" hash="6413a19e7fd7ec011c09ee7d2be73489"/><file name="pwlocal.phtml" hash="b964770e54bb91fca23a49951e3c744c"/></dir></dir><dir name="info"><dir name="method"><file name="pwbrick.phtml" hash="02d1fd8185430bb1f8d0946df1391ccd"/></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
skin/frontend/base/default/css/paymentwall.css
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.paymentwall-widget{
|
2 |
+
width: 100%;
|
3 |
+
}
|
4 |
+
#paymentwall_pwbrick_expiration, #paymentwall_pwbrick_expiration_yr{
|
5 |
+
width: 60px;
|
6 |
+
}
|
skin/frontend/base/default/js/paymentwall.js
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var PW = {
|
2 |
+
"initPwBrick": function (publicKey) {
|
3 |
+
return new Brick({
|
4 |
+
public_key: publicKey,
|
5 |
+
form: {formatter: false}
|
6 |
+
}, 'custom');
|
7 |
+
},
|
8 |
+
"prepareBrickData": function () {
|
9 |
+
return {
|
10 |
+
card_number: $('paymentwall_pwbrick_cc_number').value,
|
11 |
+
card_expiration_month: $('paymentwall_pwbrick_expiration').value,
|
12 |
+
card_expiration_year: $('paymentwall_pwbrick_expiration_yr').value,
|
13 |
+
card_cvv: $('paymentwall_pwbrick_cc_cid').value
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"ajaxPwLocalListener": function (pwlocalUrl, stopintervalcallback) {
|
17 |
+
return new Ajax.Request(pwlocalUrl, {
|
18 |
+
method: 'post',
|
19 |
+
onSuccess: function (transport) {
|
20 |
+
try {
|
21 |
+
if (transport.responseText.isJSON()) {
|
22 |
+
var response = transport.responseText.evalJSON();
|
23 |
+
switch (response.status) {
|
24 |
+
case 1: // Payment processed
|
25 |
+
$$('.paymentwall-widget')[0].innerHTML = response.message;
|
26 |
+
if (stopintervalcallback) {
|
27 |
+
stopintervalcallback();
|
28 |
+
}
|
29 |
+
// Redirect to success page after x seconds
|
30 |
+
if (response.url) {
|
31 |
+
window.setTimeout(function () {
|
32 |
+
window.location.href = response.url;
|
33 |
+
}, 3000);
|
34 |
+
}
|
35 |
+
break;
|
36 |
+
case 2: // Payment fail or error
|
37 |
+
$$('.paymentwall-widget').innerHTML = response.message;
|
38 |
+
default :
|
39 |
+
break;
|
40 |
+
}
|
41 |
+
} else {
|
42 |
+
alert(transport.responseText);
|
43 |
+
if (stopintervalcallback) {
|
44 |
+
stopintervalcallback();
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
catch (e) {
|
49 |
+
alert(transport.responseText);
|
50 |
+
if (stopintervalcallback) {
|
51 |
+
stopintervalcallback();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
});
|
56 |
+
},
|
57 |
+
"rewriteSavePayment": function (brick) {
|
58 |
+
|
59 |
+
Payment.prototype.save = Payment.prototype.save.wrap(function (origin_save) {
|
60 |
+
if ($('p_method_paymentwall_pwbrick').checked) {
|
61 |
+
// Check payment method selected
|
62 |
+
var validator = new Validation(this.form);
|
63 |
+
if (this.validate() && validator.validate()) {
|
64 |
+
brick.tokenizeCard(
|
65 |
+
PW.prepareBrickData(),
|
66 |
+
function (response) {
|
67 |
+
// handle errors
|
68 |
+
if (response.type == 'Error') {
|
69 |
+
alert("Brick Error:\nCode [" + response.code + "]: " + response.error);
|
70 |
+
return false;
|
71 |
+
} else {
|
72 |
+
$('paymentwall_pwbrick_token').value = response.token;
|
73 |
+
$('paymentwall_pwbrick_fingerprint').value = Brick.getFingerprint();
|
74 |
+
// Call origin function
|
75 |
+
origin_save();
|
76 |
+
return true;
|
77 |
+
}
|
78 |
+
});
|
79 |
+
}
|
80 |
+
} else {
|
81 |
+
// Call origin function
|
82 |
+
origin_save();
|
83 |
+
}
|
84 |
+
});
|
85 |
+
}
|
86 |
+
};
|