Version Notes
- Update order status by following 3Ds rule
- Fix minor bugs regarding Brick pingback
Download this release
Release Info
Developer | Paymentwall |
Extension | paymentwall_magento_module |
Version | 1.2.6 |
Comparing to | |
See all releases |
Code changes from version 1.2.5 to 1.2.6
- app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Pwlocaluni.php +68 -0
- app/code/community/Paymentwall/Paymentwall/Block/Checkout/Info/Method/Pwlocaluni.php +15 -0
- app/code/community/Paymentwall/Paymentwall/Model/Method/Abstract.php +7 -1
- app/code/community/Paymentwall/Paymentwall/Model/Method/Pwbrick.php +6 -12
- app/code/community/Paymentwall/Paymentwall/Model/Method/Pwlocaluni.php +73 -0
- app/code/community/Paymentwall/Paymentwall/Model/Pingback.php +14 -4
- app/code/community/Paymentwall/Paymentwall/etc/config.xml +1 -1
- lib/paymentwall-php/.gitignore +14 -14
- lib/paymentwall-php/LICENSE +20 -20
- lib/paymentwall-php/README.md +317 -312
- lib/paymentwall-php/composer.json +40 -40
- lib/paymentwall-php/features/bootstrap/ChargeContext.php +111 -111
- lib/paymentwall-php/features/bootstrap/FeatureContext.php +71 -71
- lib/paymentwall-php/features/bootstrap/PingbackContext.php +68 -68
- lib/paymentwall-php/features/bootstrap/WidgetContext.php +162 -162
- lib/paymentwall-php/features/charge.feature +22 -22
- lib/paymentwall-php/features/pingback.feature +128 -128
- lib/paymentwall-php/features/widget.feature +106 -106
- lib/paymentwall-php/lib/Paymentwall/GenerericApiObject.php +56 -56
- package.xml +6 -5
app/code/community/Paymentwall/Paymentwall/Block/Checkout/Form/Method/Pwlocaluni.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_Pwlocaluni 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('pwlocaluni');
|
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/Pwlocaluni.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_Pwlocaluni extends Mage_Payment_Block_Info
|
10 |
+
{
|
11 |
+
protected function _construct()
|
12 |
+
{
|
13 |
+
parent::_construct();
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Abstract.php
CHANGED
@@ -32,12 +32,18 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
32 |
/**
|
33 |
* Init paymentwall configs
|
34 |
*/
|
35 |
-
public function initPaymentwallConfig() {
|
36 |
Paymentwall_Config::getInstance()->set(array(
|
37 |
'api_type' => Paymentwall_Config::API_GOODS,
|
38 |
'public_key' => $this->getConfigData('paymentwall_public_key'),
|
39 |
'private_key' => $this->getConfigData('paymentwall_private_key')
|
40 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
public function getMethodCode() {
|
32 |
/**
|
33 |
* Init paymentwall configs
|
34 |
*/
|
35 |
+
public function initPaymentwallConfig($pingback = false) {
|
36 |
Paymentwall_Config::getInstance()->set(array(
|
37 |
'api_type' => Paymentwall_Config::API_GOODS,
|
38 |
'public_key' => $this->getConfigData('paymentwall_public_key'),
|
39 |
'private_key' => $this->getConfigData('paymentwall_private_key')
|
40 |
));
|
41 |
+
if ($pingback) {
|
42 |
+
$pwlocalModel = Mage::getModel('paymentwall/method_pwlocal');
|
43 |
+
Paymentwall_Config::getInstance()->setPrivateKey(
|
44 |
+
$pwlocalModel->getConfigData('paymentwall_private_key')
|
45 |
+
);
|
46 |
+
}
|
47 |
}
|
48 |
|
49 |
public function getMethodCode() {
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Pwbrick.php
CHANGED
@@ -106,17 +106,9 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
106 |
|
107 |
if ($charge->isSuccessful() && empty($rawResponse['secure'])) {
|
108 |
if ($charge->isCaptured()) {
|
109 |
-
|
110 |
-
$payment->setTransactionId($charge->getId());
|
111 |
-
$payment->setIsTransactionClosed(0);
|
112 |
-
|
113 |
-
// store token data
|
114 |
$payment->setTransactionAdditionalInfo('saved_token', Mage::helper('core')->encrypt($charge->getCard()->getToken()));
|
115 |
-
} elseif ($charge->isUnderReview()) {
|
116 |
-
$payment->setIsTransactionPending(true);
|
117 |
}
|
118 |
} elseif (!empty($rawResponse['secure'])) {
|
119 |
-
$payment->setIsTransactionPending(true);
|
120 |
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
121 |
'pending_payment', '3D Secure Auth Now Taking Place')->save();
|
122 |
Mage::getModel('core/session')
|
@@ -127,8 +119,7 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
127 |
->setChargeOrderId($order->getIncrementId())
|
128 |
->setChargeData(json_encode($chargeData));
|
129 |
} else {
|
130 |
-
$payment->
|
131 |
-
->setIsFraudDetected(true);
|
132 |
$errors = json_decode($response, true);
|
133 |
$this->log($errors, 'Charge error response');
|
134 |
$strErrors = Mage::helper('paymentwall')->__("Brick error(s):");
|
@@ -136,6 +127,7 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
136 |
Mage::throwException($strErrors);
|
137 |
}
|
138 |
|
|
|
139 |
return $this;
|
140 |
}
|
141 |
|
@@ -349,13 +341,15 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
349 |
->setSecureFormHtml(null)
|
350 |
->setChargeOrderId(null)
|
351 |
->setChargeData(null);
|
352 |
-
|
353 |
-
$this->log($response, 'Charge success');
|
354 |
return true;
|
355 |
} else {
|
356 |
$order->getPayment()
|
357 |
->setIsTransactionPending(true)
|
358 |
->setIsFraudDetected(true);
|
|
|
|
|
|
|
359 |
$errors = json_decode($response, true);
|
360 |
$this->log($errors, 'Charge error response');
|
361 |
$strErrors = Mage::helper('paymentwall')->__("Brick error(s):");
|
106 |
|
107 |
if ($charge->isSuccessful() && empty($rawResponse['secure'])) {
|
108 |
if ($charge->isCaptured()) {
|
|
|
|
|
|
|
|
|
|
|
109 |
$payment->setTransactionAdditionalInfo('saved_token', Mage::helper('core')->encrypt($charge->getCard()->getToken()));
|
|
|
|
|
110 |
}
|
111 |
} elseif (!empty($rawResponse['secure'])) {
|
|
|
112 |
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
113 |
'pending_payment', '3D Secure Auth Now Taking Place')->save();
|
114 |
Mage::getModel('core/session')
|
119 |
->setChargeOrderId($order->getIncrementId())
|
120 |
->setChargeData(json_encode($chargeData));
|
121 |
} else {
|
122 |
+
$payment->setIsFraudDetected(true);
|
|
|
123 |
$errors = json_decode($response, true);
|
124 |
$this->log($errors, 'Charge error response');
|
125 |
$strErrors = Mage::helper('paymentwall')->__("Brick error(s):");
|
127 |
Mage::throwException($strErrors);
|
128 |
}
|
129 |
|
130 |
+
$payment->setIsTransactionPending(true);
|
131 |
return $this;
|
132 |
}
|
133 |
|
341 |
->setSecureFormHtml(null)
|
342 |
->setChargeOrderId(null)
|
343 |
->setChargeData(null);
|
344 |
+
|
|
|
345 |
return true;
|
346 |
} else {
|
347 |
$order->getPayment()
|
348 |
->setIsTransactionPending(true)
|
349 |
->setIsFraudDetected(true);
|
350 |
+
|
351 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
|
352 |
+
|
353 |
$errors = json_decode($response, true);
|
354 |
$this->log($errors, 'Charge error response');
|
355 |
$strErrors = Mage::helper('paymentwall')->__("Brick error(s):");
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Pwlocaluni.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Pwlocaluni extends Paymentwall_Paymentwall_Model_Method_Abstract {
|
8 |
+
|
9 |
+
protected $_isInitializeNeeded = false;
|
10 |
+
protected $_canUseInternal = false;
|
11 |
+
protected $_canUseForMultishipping = false;
|
12 |
+
protected $_canCapture = true;
|
13 |
+
protected $_canAuthorize = true;
|
14 |
+
protected $_canVoid = false;
|
15 |
+
protected $_canReviewPayment = false;
|
16 |
+
protected $_canCreateBillingAgreement = false;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Constructor method.
|
20 |
+
* Set some internal properties
|
21 |
+
*/
|
22 |
+
public function __construct() {
|
23 |
+
parent::__construct('pwlocaluni');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getOrderPlaceRedirectUrl() {
|
27 |
+
return Mage::getUrl('paymentwall/payment/pwlocaluni', array('_secure' => true));
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Generate Paymentwall Widget
|
32 |
+
* @param $order
|
33 |
+
* @return Paymentwall_Widget
|
34 |
+
*/
|
35 |
+
public function getPaymentWidget(Mage_Sales_Model_Order $order) {
|
36 |
+
$this->initPaymentwallConfig();
|
37 |
+
|
38 |
+
$customerId = $_SERVER['REMOTE_ADDR'];
|
39 |
+
|
40 |
+
if(Mage::getSingleton('customer/session')->isLoggedIn()){
|
41 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
42 |
+
$customerId = $customer->getId();
|
43 |
+
}
|
44 |
+
|
45 |
+
$widget = new Paymentwall_Widget(
|
46 |
+
$customerId,
|
47 |
+
$this->getConfigData('paymentwall_widget_code'),
|
48 |
+
array(
|
49 |
+
new Paymentwall_Product(
|
50 |
+
$order->getIncrementId(),
|
51 |
+
$order->getGrandTotal(),
|
52 |
+
$order->getOrderCurrencyCode(),
|
53 |
+
'Order id #' . $order->getIncrementId(),
|
54 |
+
Paymentwall_Product::TYPE_FIXED
|
55 |
+
)
|
56 |
+
),
|
57 |
+
array_merge(
|
58 |
+
array(
|
59 |
+
'email' => $order->getCustomerEmail(),
|
60 |
+
'success_url' => $this->getConfigData('paymentwall_url'),
|
61 |
+
'test_mode' => (int)$this->getConfigData('paymentwall_istest'),
|
62 |
+
'integration_module' => 'magento',
|
63 |
+
'ps' => ('1' == $this->getConfigData('paymentwall_istest')) ? 'test' : 'cc',
|
64 |
+
'pingback_url' => Mage::getBaseUrl().'paymentwall/payment/ipnuni',
|
65 |
+
'custom' => 'uni_widget',
|
66 |
+
),
|
67 |
+
$this->prepareUserProfile($order) // for User Profile API
|
68 |
+
)
|
69 |
+
);
|
70 |
+
|
71 |
+
return $widget;
|
72 |
+
}
|
73 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Model/Pingback.php
CHANGED
@@ -10,18 +10,28 @@ if (!class_exists('Paymentwall_Config'))
|
|
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()) {
|
26 |
|
27 |
if ($this->isRecurring($pingback)) {
|
10 |
class Paymentwall_Paymentwall_Model_Pingback extends Mage_Core_Model_Abstract
|
11 |
{
|
12 |
const DEFAULT_PINGBACK_RESPONSE = 'OK';
|
13 |
+
const BRICK_METHOD = 'paymentwall_pwbrick';
|
14 |
+
|
15 |
/**
|
16 |
* Handle pingback
|
17 |
* @return string
|
18 |
*/
|
19 |
public function handlePingback()
|
20 |
{
|
|
|
|
|
|
|
21 |
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
22 |
|
23 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($pingback->getProductId());
|
24 |
+
if (empty($order)) {
|
25 |
+
die("Order invalid");
|
26 |
+
}
|
27 |
+
|
28 |
+
// Load paymentwall configs
|
29 |
+
if ($order->getPayment()->getMethod() == self::BRICK_METHOD) {
|
30 |
+
Mage::getModel('paymentwall/method_pwbrick')->initPaymentwallConfig(true);
|
31 |
+
} else {
|
32 |
+
Mage::getModel('paymentwall/method_pwlocal')->initPaymentwallConfig();
|
33 |
+
}
|
34 |
+
|
35 |
if ($pingback->validate()) {
|
36 |
|
37 |
if ($this->isRecurring($pingback)) {
|
app/code/community/Paymentwall/Paymentwall/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Paymentwall_Paymentwall>
|
5 |
-
<version>1.2.
|
6 |
</Paymentwall_Paymentwall>
|
7 |
</modules>
|
8 |
<frontend>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Paymentwall_Paymentwall>
|
5 |
+
<version>1.2.6</version>
|
6 |
</Paymentwall_Paymentwall>
|
7 |
</modules>
|
8 |
<frontend>
|
lib/paymentwall-php/.gitignore
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
# Vagrant
|
2 |
-
.vagrant/*
|
3 |
-
Vagrantfile
|
4 |
-
|
5 |
-
# SublimeText
|
6 |
-
*.sublime-project
|
7 |
-
*.sublime-workspace
|
8 |
-
|
9 |
-
# Composer
|
10 |
-
composer.phar
|
11 |
-
vendor/
|
12 |
-
composer.lock
|
13 |
-
|
14 |
-
# Behat
|
15 |
behat*
|
1 |
+
# Vagrant
|
2 |
+
.vagrant/*
|
3 |
+
Vagrantfile
|
4 |
+
|
5 |
+
# SublimeText
|
6 |
+
*.sublime-project
|
7 |
+
*.sublime-workspace
|
8 |
+
|
9 |
+
# Composer
|
10 |
+
composer.phar
|
11 |
+
vendor/
|
12 |
+
composer.lock
|
13 |
+
|
14 |
+
# Behat
|
15 |
behat*
|
lib/paymentwall-php/LICENSE
CHANGED
@@ -1,20 +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.
|
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
CHANGED
@@ -1,312 +1,317 @@
|
|
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 |
-
```php
|
50 |
-
$widget = new Paymentwall_Widget(
|
51 |
-
'user40012', // id of the end-user who's making the payment
|
52 |
-
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
53 |
-
array( // product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty
|
54 |
-
new Paymentwall_Product(
|
55 |
-
'product301', // id of the product in your system
|
56 |
-
9.99, // price
|
57 |
-
'USD', // currency code
|
58 |
-
'Gold Membership', // product name
|
59 |
-
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
|
60 |
-
1, // duration is 1
|
61 |
-
Paymentwall_Product::PERIOD_TYPE_MONTH, // month
|
62 |
-
true // recurring
|
63 |
-
)
|
64 |
-
),
|
65 |
-
array('email' => 'user@hostname.com') // additional parameters
|
66 |
-
);
|
67 |
-
echo $widget->getHtmlCode();
|
68 |
-
```
|
69 |
-
|
70 |
-
####Pingback Processing
|
71 |
-
|
72 |
-
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:
|
73 |
-
```php
|
74 |
-
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
75 |
-
Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
|
76 |
-
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
77 |
-
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
78 |
-
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
79 |
-
if ($pingback->validate()) {
|
80 |
-
$productId = $pingback->getProduct()->getId();
|
81 |
-
if ($pingback->isDeliverable()) {
|
82 |
-
// deliver the product
|
83 |
-
} else if ($pingback->isCancelable()) {
|
84 |
-
// withdraw the product
|
85 |
-
}
|
86 |
-
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
87 |
-
} else {
|
88 |
-
echo $pingback->getErrorSummary();
|
89 |
-
}
|
90 |
-
```
|
91 |
-
|
92 |
-
##Virtual Currency API
|
93 |
-
|
94 |
-
####Initializing Paymentwall
|
95 |
-
Using Paymentwall PHP Library v2:
|
96 |
-
```php
|
97 |
-
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
98 |
-
Paymentwall_Config::getInstance()->set(array(
|
99 |
-
'api_type' => Paymentwall_Config::API_VC,
|
100 |
-
'public_key' => 'YOUR_PUBLIC_KEY',
|
101 |
-
'private_key' => 'YOUR_PRIVATE_KEY'
|
102 |
-
));
|
103 |
-
```
|
104 |
-
Using Paymentwall PHP Library v1 (deprecated in v2):
|
105 |
-
```php
|
106 |
-
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
107 |
-
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
|
108 |
-
Paymentwall_Base::setAppKey('
|
109 |
-
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
110 |
-
```
|
111 |
-
|
112 |
-
####Widget Call
|
113 |
-
```php
|
114 |
-
$widget = new Paymentwall_Widget(
|
115 |
-
'user40012', // id of the end-user who's making the payment
|
116 |
-
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
117 |
-
array(), // array of products - leave blank for Virtual Currency API
|
118 |
-
array('email' => 'user@hostname.com') // additional parameters
|
119 |
-
);
|
120 |
-
echo $widget->getHtmlCode();
|
121 |
-
```
|
122 |
-
|
123 |
-
####Pingback Processing
|
124 |
-
|
125 |
-
```php
|
126 |
-
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
127 |
-
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
|
128 |
-
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
129 |
-
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
130 |
-
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
131 |
-
if ($pingback->validate()) {
|
132 |
-
$virtualCurrency = $pingback->getVirtualCurrencyAmount();
|
133 |
-
if ($pingback->isDeliverable()) {
|
134 |
-
// deliver the virtual currency
|
135 |
-
} else if ($pingback->isCancelable()) {
|
136 |
-
// withdraw the virual currency
|
137 |
-
}
|
138 |
-
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
139 |
-
} else {
|
140 |
-
echo $pingback->getErrorSummary();
|
141 |
-
}
|
142 |
-
```
|
143 |
-
|
144 |
-
##Cart API
|
145 |
-
|
146 |
-
####Initializing Paymentwall
|
147 |
-
Using Paymentwall PHP Library v2:
|
148 |
-
```php
|
149 |
-
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
150 |
-
Paymentwall_Config::getInstance()->set(array(
|
151 |
-
'api_type' => Paymentwall_Config::API_CART,
|
152 |
-
'public_key' => 'YOUR_PUBLIC_KEY',
|
153 |
-
'private_key' => 'YOUR_PRIVATE_KEY'
|
154 |
-
));
|
155 |
-
```
|
156 |
-
Using Paymentwall PHP Library v1 (deprecated in v2):
|
157 |
-
```php
|
158 |
-
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
159 |
-
Paymentwall_Base::setApiType(Paymentwall_Base::API_CART);
|
160 |
-
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
161 |
-
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
162 |
-
```
|
163 |
-
|
164 |
-
####Widget Call
|
165 |
-
```php
|
166 |
-
$widget = new Paymentwall_Widget(
|
167 |
-
'user40012', // id of the end-user who's making the payment
|
168 |
-
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account,
|
169 |
-
array(
|
170 |
-
new Paymentwall_Product('product301', 3.33, 'EUR'), // first product in cart
|
171 |
-
new Paymentwall_Product('product607', 7.77, 'EUR') // second product in cart
|
172 |
-
),
|
173 |
-
array('email' => 'user@hostname.com') // additional params
|
174 |
-
);
|
175 |
-
echo $widget->getHtmlCode();
|
176 |
-
```
|
177 |
-
|
178 |
-
####Pingback Processing
|
179 |
-
|
180 |
-
```php
|
181 |
-
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
182 |
-
Paymentwall_Base::setApiType(Paymentwall_Base::API_CART);
|
183 |
-
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
184 |
-
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
185 |
-
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
186 |
-
if ($pingback->validate()) {
|
187 |
-
$products = $pingback->getProducts();
|
188 |
-
if ($pingback->isDeliverable()) {
|
189 |
-
// deliver products from the cart
|
190 |
-
} else if ($pingback->isCancelable()) {
|
191 |
-
// withdraw products from the cart
|
192 |
-
}
|
193 |
-
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
194 |
-
} else {
|
195 |
-
echo $pingback->getErrorSummary();
|
196 |
-
}
|
197 |
-
```
|
198 |
-
|
199 |
-
##Brick
|
200 |
-
|
201 |
-
####Initializing Paymentwall
|
202 |
-
```php
|
203 |
-
Paymentwall_Config::getInstance()->set(array(
|
204 |
-
'public_key' => 'YOUR_PUBLIC_KEY',
|
205 |
-
'private_key' => 'YOUR_PRIVATE_KEY'
|
206 |
-
));
|
207 |
-
```
|
208 |
-
|
209 |
-
####Create a one-time token
|
210 |
-
```php
|
211 |
-
$tokenModel = new Paymentwall_OneTimeToken();
|
212 |
-
$token = $tokenModel->create(array(
|
213 |
-
'public_key' => Paymentwall_Config::getInstance()->getPublicKey(),
|
214 |
-
'card[number]' => '4242424242424242',
|
215 |
-
'card[exp_month]' => '11',
|
216 |
-
'card[exp_year]' => '19',
|
217 |
-
'card[cvv]' => '123'
|
218 |
-
));
|
219 |
-
// send token to charge via $token->getToken();
|
220 |
-
```
|
221 |
-
|
222 |
-
####Charge
|
223 |
-
```php
|
224 |
-
$charge = new Paymentwall_Charge();
|
225 |
-
$charge->create(array(
|
226 |
-
// if generated via backend
|
227 |
-
//'token' => $token->getToken(),
|
228 |
-
// if generated via brick.js
|
229 |
-
'token' => $_POST['brick_token'],
|
230 |
-
'email' => $_POST['email'],
|
231 |
-
'currency' => 'USD',
|
232 |
-
'amount' => 10,
|
233 |
-
'fingerprint' => $_POST['brick_fingerprint'],
|
234 |
-
'description' => 'Order #123'
|
235 |
-
));
|
236 |
-
|
237 |
-
$response = $charge->getPublicData();
|
238 |
-
|
239 |
-
if ($charge->isSuccessful()) {
|
240 |
-
if ($charge->isCaptured()) {
|
241 |
-
// deliver s product
|
242 |
-
} elseif ($charge->isUnderReview()) {
|
243 |
-
// decide on risk charge
|
244 |
-
}
|
245 |
-
} else {
|
246 |
-
$errors = json_decode($response, true);
|
247 |
-
echo $errors['error']['code'];
|
248 |
-
echo $errors['error']['message'];
|
249 |
-
}
|
250 |
-
|
251 |
-
echo $response; // need for JS communication
|
252 |
-
```
|
253 |
-
|
254 |
-
####Charge - refund
|
255 |
-
|
256 |
-
```php
|
257 |
-
$charge = new Paymentwall_Charge('CHARGE_ID');
|
258 |
-
$charge->refund();
|
259 |
-
|
260 |
-
echo $charge->isRefunded();
|
261 |
-
```
|
262 |
-
|
263 |
-
####Subscription
|
264 |
-
|
265 |
-
```php
|
266 |
-
$subscription = new Paymentwall_Subscription();
|
267 |
-
$subscription->create(array(
|
268 |
-
// if generated via backend
|
269 |
-
//'token' => $token->getToken(),
|
270 |
-
// if generated via brick.js
|
271 |
-
'token' => $_POST['brick_token'],
|
272 |
-
'email' => $_POST['email'],
|
273 |
-
'currency' => 'USD',
|
274 |
-
'amount' => 10,
|
275 |
-
'fingerprint' => $_POST['brick_fingerprint'],
|
276 |
-
'plan' => 'product_123',
|
277 |
-
'description' => 'Order #123',
|
278 |
-
'period' => 'week',
|
279 |
-
'period_duration' => 2
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
```
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
|
|
|
|
|
|
|
|
|
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 |
+
```php
|
50 |
+
$widget = new Paymentwall_Widget(
|
51 |
+
'user40012', // id of the end-user who's making the payment
|
52 |
+
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
53 |
+
array( // product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty
|
54 |
+
new Paymentwall_Product(
|
55 |
+
'product301', // id of the product in your system
|
56 |
+
9.99, // price
|
57 |
+
'USD', // currency code
|
58 |
+
'Gold Membership', // product name
|
59 |
+
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
|
60 |
+
1, // duration is 1
|
61 |
+
Paymentwall_Product::PERIOD_TYPE_MONTH, // month
|
62 |
+
true // recurring
|
63 |
+
)
|
64 |
+
),
|
65 |
+
array('email' => 'user@hostname.com') // additional parameters
|
66 |
+
);
|
67 |
+
echo $widget->getHtmlCode();
|
68 |
+
```
|
69 |
+
|
70 |
+
####Pingback Processing
|
71 |
+
|
72 |
+
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:
|
73 |
+
```php
|
74 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
75 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
|
76 |
+
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
77 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
78 |
+
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
79 |
+
if ($pingback->validate()) {
|
80 |
+
$productId = $pingback->getProduct()->getId();
|
81 |
+
if ($pingback->isDeliverable()) {
|
82 |
+
// deliver the product
|
83 |
+
} else if ($pingback->isCancelable()) {
|
84 |
+
// withdraw the product
|
85 |
+
}
|
86 |
+
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
87 |
+
} else {
|
88 |
+
echo $pingback->getErrorSummary();
|
89 |
+
}
|
90 |
+
```
|
91 |
+
|
92 |
+
##Virtual Currency API
|
93 |
+
|
94 |
+
####Initializing Paymentwall
|
95 |
+
Using Paymentwall PHP Library v2:
|
96 |
+
```php
|
97 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
98 |
+
Paymentwall_Config::getInstance()->set(array(
|
99 |
+
'api_type' => Paymentwall_Config::API_VC,
|
100 |
+
'public_key' => 'YOUR_PUBLIC_KEY',
|
101 |
+
'private_key' => 'YOUR_PRIVATE_KEY'
|
102 |
+
));
|
103 |
+
```
|
104 |
+
Using Paymentwall PHP Library v1 (deprecated in v2):
|
105 |
+
```php
|
106 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
107 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
|
108 |
+
Paymentwall_Base::setAppKey('YOUR_PUBLIC_KEY'); // available in your Paymentwall merchant area
|
109 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
110 |
+
```
|
111 |
+
|
112 |
+
####Widget Call
|
113 |
+
```php
|
114 |
+
$widget = new Paymentwall_Widget(
|
115 |
+
'user40012', // id of the end-user who's making the payment
|
116 |
+
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
117 |
+
array(), // array of products - leave blank for Virtual Currency API
|
118 |
+
array('email' => 'user@hostname.com') // additional parameters
|
119 |
+
);
|
120 |
+
echo $widget->getHtmlCode();
|
121 |
+
```
|
122 |
+
|
123 |
+
####Pingback Processing
|
124 |
+
|
125 |
+
```php
|
126 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
127 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
|
128 |
+
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
129 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
130 |
+
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
131 |
+
if ($pingback->validate()) {
|
132 |
+
$virtualCurrency = $pingback->getVirtualCurrencyAmount();
|
133 |
+
if ($pingback->isDeliverable()) {
|
134 |
+
// deliver the virtual currency
|
135 |
+
} else if ($pingback->isCancelable()) {
|
136 |
+
// withdraw the virual currency
|
137 |
+
}
|
138 |
+
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
139 |
+
} else {
|
140 |
+
echo $pingback->getErrorSummary();
|
141 |
+
}
|
142 |
+
```
|
143 |
+
|
144 |
+
##Cart API
|
145 |
+
|
146 |
+
####Initializing Paymentwall
|
147 |
+
Using Paymentwall PHP Library v2:
|
148 |
+
```php
|
149 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
150 |
+
Paymentwall_Config::getInstance()->set(array(
|
151 |
+
'api_type' => Paymentwall_Config::API_CART,
|
152 |
+
'public_key' => 'YOUR_PUBLIC_KEY',
|
153 |
+
'private_key' => 'YOUR_PRIVATE_KEY'
|
154 |
+
));
|
155 |
+
```
|
156 |
+
Using Paymentwall PHP Library v1 (deprecated in v2):
|
157 |
+
```php
|
158 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
159 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_CART);
|
160 |
+
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
161 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
162 |
+
```
|
163 |
+
|
164 |
+
####Widget Call
|
165 |
+
```php
|
166 |
+
$widget = new Paymentwall_Widget(
|
167 |
+
'user40012', // id of the end-user who's making the payment
|
168 |
+
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account,
|
169 |
+
array(
|
170 |
+
new Paymentwall_Product('product301', 3.33, 'EUR'), // first product in cart
|
171 |
+
new Paymentwall_Product('product607', 7.77, 'EUR') // second product in cart
|
172 |
+
),
|
173 |
+
array('email' => 'user@hostname.com') // additional params
|
174 |
+
);
|
175 |
+
echo $widget->getHtmlCode();
|
176 |
+
```
|
177 |
+
|
178 |
+
####Pingback Processing
|
179 |
+
|
180 |
+
```php
|
181 |
+
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
|
182 |
+
Paymentwall_Base::setApiType(Paymentwall_Base::API_CART);
|
183 |
+
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
|
184 |
+
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
|
185 |
+
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
|
186 |
+
if ($pingback->validate()) {
|
187 |
+
$products = $pingback->getProducts();
|
188 |
+
if ($pingback->isDeliverable()) {
|
189 |
+
// deliver products from the cart
|
190 |
+
} else if ($pingback->isCancelable()) {
|
191 |
+
// withdraw products from the cart
|
192 |
+
}
|
193 |
+
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
194 |
+
} else {
|
195 |
+
echo $pingback->getErrorSummary();
|
196 |
+
}
|
197 |
+
```
|
198 |
+
|
199 |
+
##Brick
|
200 |
+
|
201 |
+
####Initializing Paymentwall
|
202 |
+
```php
|
203 |
+
Paymentwall_Config::getInstance()->set(array(
|
204 |
+
'public_key' => 'YOUR_PUBLIC_KEY',
|
205 |
+
'private_key' => 'YOUR_PRIVATE_KEY'
|
206 |
+
));
|
207 |
+
```
|
208 |
+
|
209 |
+
####Create a one-time token
|
210 |
+
```php
|
211 |
+
$tokenModel = new Paymentwall_OneTimeToken();
|
212 |
+
$token = $tokenModel->create(array(
|
213 |
+
'public_key' => Paymentwall_Config::getInstance()->getPublicKey(),
|
214 |
+
'card[number]' => '4242424242424242',
|
215 |
+
'card[exp_month]' => '11',
|
216 |
+
'card[exp_year]' => '19',
|
217 |
+
'card[cvv]' => '123'
|
218 |
+
));
|
219 |
+
// send token to charge via $token->getToken();
|
220 |
+
```
|
221 |
+
|
222 |
+
####Charge
|
223 |
+
```php
|
224 |
+
$charge = new Paymentwall_Charge();
|
225 |
+
$charge->create(array(
|
226 |
+
// if generated via backend
|
227 |
+
//'token' => $token->getToken(),
|
228 |
+
// if generated via brick.js
|
229 |
+
'token' => $_POST['brick_token'],
|
230 |
+
'email' => $_POST['email'],
|
231 |
+
'currency' => 'USD',
|
232 |
+
'amount' => 10,
|
233 |
+
'fingerprint' => $_POST['brick_fingerprint'],
|
234 |
+
'description' => 'Order #123'
|
235 |
+
));
|
236 |
+
|
237 |
+
$response = $charge->getPublicData();
|
238 |
+
|
239 |
+
if ($charge->isSuccessful()) {
|
240 |
+
if ($charge->isCaptured()) {
|
241 |
+
// deliver s product
|
242 |
+
} elseif ($charge->isUnderReview()) {
|
243 |
+
// decide on risk charge
|
244 |
+
}
|
245 |
+
} else {
|
246 |
+
$errors = json_decode($response, true);
|
247 |
+
echo $errors['error']['code'];
|
248 |
+
echo $errors['error']['message'];
|
249 |
+
}
|
250 |
+
|
251 |
+
echo $response; // need for JS communication
|
252 |
+
```
|
253 |
+
|
254 |
+
####Charge - refund
|
255 |
+
|
256 |
+
```php
|
257 |
+
$charge = new Paymentwall_Charge('CHARGE_ID');
|
258 |
+
$charge->refund();
|
259 |
+
|
260 |
+
echo $charge->isRefunded();
|
261 |
+
```
|
262 |
+
|
263 |
+
####Subscription
|
264 |
+
|
265 |
+
```php
|
266 |
+
$subscription = new Paymentwall_Subscription();
|
267 |
+
$subscription->create(array(
|
268 |
+
// if generated via backend
|
269 |
+
//'token' => $token->getToken(),
|
270 |
+
// if generated via brick.js
|
271 |
+
'token' => $_POST['brick_token'],
|
272 |
+
'email' => $_POST['email'],
|
273 |
+
'currency' => 'USD',
|
274 |
+
'amount' => 10,
|
275 |
+
'fingerprint' => $_POST['brick_fingerprint'],
|
276 |
+
'plan' => 'product_123',
|
277 |
+
'description' => 'Order #123',
|
278 |
+
'period' => 'week',
|
279 |
+
'period_duration' => 2,
|
280 |
+
// if trial, add following parameters
|
281 |
+
'trial[amount]' => 1,
|
282 |
+
'trial[currency]' => 'USD',
|
283 |
+
'trial[period]' => 'month',
|
284 |
+
'trial[period_duration]' => 1
|
285 |
+
));
|
286 |
+
|
287 |
+
echo $subscription->getId();
|
288 |
+
```
|
289 |
+
|
290 |
+
####Subscription - cancel
|
291 |
+
|
292 |
+
```php
|
293 |
+
$subscription = new Paymentwall_Subscription('SUBSCRIPTION_ID');
|
294 |
+
$subscription->cancel();
|
295 |
+
|
296 |
+
echo $subscription->isActive();
|
297 |
+
```
|
298 |
+
|
299 |
+
###Signature calculation - Widget
|
300 |
+
|
301 |
+
```php
|
302 |
+
$widgetSignatureModel = new Paymentwall_Signature_Widget();
|
303 |
+
echo $widgetSignatureModel->calculate(
|
304 |
+
array(), // widget params
|
305 |
+
2 // signature version
|
306 |
+
);
|
307 |
+
```
|
308 |
+
|
309 |
+
###Singature calculation - Pingback
|
310 |
+
|
311 |
+
```php
|
312 |
+
$pingbackSignatureModel = new Paymentwall_Signature_Pingback();
|
313 |
+
echo $pingbackSignatureModel->calculate(
|
314 |
+
array(), // pingback params
|
315 |
+
1 // signature version
|
316 |
+
);
|
317 |
+
```
|
lib/paymentwall-php/composer.json
CHANGED
@@ -1,40 +1,40 @@
|
|
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.1.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 |
-
"require-dev": {
|
31 |
-
"behat/behat": "2.4.*@stable"
|
32 |
-
},
|
33 |
-
"config": {
|
34 |
-
"bin-dir": "bin/"
|
35 |
-
},
|
36 |
-
"autoload": {
|
37 |
-
"classmap": ["lib/Paymentwall/"]
|
38 |
-
},
|
39 |
-
"minimum-stability": "dev"
|
40 |
-
}
|
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.1.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 |
+
"require-dev": {
|
31 |
+
"behat/behat": "2.4.*@stable"
|
32 |
+
},
|
33 |
+
"config": {
|
34 |
+
"bin-dir": "bin/"
|
35 |
+
},
|
36 |
+
"autoload": {
|
37 |
+
"classmap": ["lib/Paymentwall/"]
|
38 |
+
},
|
39 |
+
"minimum-stability": "dev"
|
40 |
+
}
|
lib/paymentwall-php/features/bootstrap/ChargeContext.php
CHANGED
@@ -1,112 +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 |
}
|
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
CHANGED
@@ -1,71 +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 |
-
}
|
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
CHANGED
@@ -1,69 +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 |
}
|
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
CHANGED
@@ -1,163 +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 |
}
|
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
CHANGED
@@ -1,23 +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"
|
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
CHANGED
@@ -1,128 +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 |
-
|
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
CHANGED
@@ -1,107 +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."
|
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/GenerericApiObject.php
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Paymentwall_GenerericApiObject extends Paymentwall_ApiObject
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* API type
|
7 |
-
*
|
8 |
-
* @var string
|
9 |
-
*/
|
10 |
-
protected $api;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Paymentwall_HttpAction object
|
14 |
-
*
|
15 |
-
* @var \Paymentwall_HttpAction
|
16 |
-
*/
|
17 |
-
protected $httpAction;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @see \Paymentwall_ApiObject
|
21 |
-
*/
|
22 |
-
public function getEndpointName()
|
23 |
-
{
|
24 |
-
return $this->api;
|
25 |
-
}
|
26 |
-
|
27 |
-
public function __construct($type)
|
28 |
-
{
|
29 |
-
$this->api = $type;
|
30 |
-
$this->httpAction = new Paymentwall_HttpAction($this);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Make post request
|
35 |
-
*
|
36 |
-
* @param array $params
|
37 |
-
* @param array $headers
|
38 |
-
*
|
39 |
-
* @return array
|
40 |
-
*/
|
41 |
-
public function post($params = array(), $headers = array())
|
42 |
-
{
|
43 |
-
if (empty($params)) {
|
44 |
-
return null;
|
45 |
-
}
|
46 |
-
|
47 |
-
$this->httpAction->setApiParams($params);
|
48 |
-
|
49 |
-
$this->httpAction->setApiHeaders(array_merge(array($this->getApiBaseHeader()), $headers));
|
50 |
-
|
51 |
-
return (array) $this->preparePropertiesFromResponse(
|
52 |
-
$this->httpAction->post(
|
53 |
-
$this->getApiUrl()
|
54 |
-
)
|
55 |
-
);
|
56 |
-
}
|
57 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Paymentwall_GenerericApiObject extends Paymentwall_ApiObject
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* API type
|
7 |
+
*
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $api;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Paymentwall_HttpAction object
|
14 |
+
*
|
15 |
+
* @var \Paymentwall_HttpAction
|
16 |
+
*/
|
17 |
+
protected $httpAction;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @see \Paymentwall_ApiObject
|
21 |
+
*/
|
22 |
+
public function getEndpointName()
|
23 |
+
{
|
24 |
+
return $this->api;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function __construct($type)
|
28 |
+
{
|
29 |
+
$this->api = $type;
|
30 |
+
$this->httpAction = new Paymentwall_HttpAction($this);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Make post request
|
35 |
+
*
|
36 |
+
* @param array $params
|
37 |
+
* @param array $headers
|
38 |
+
*
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function post($params = array(), $headers = array())
|
42 |
+
{
|
43 |
+
if (empty($params)) {
|
44 |
+
return null;
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->httpAction->setApiParams($params);
|
48 |
+
|
49 |
+
$this->httpAction->setApiHeaders(array_merge(array($this->getApiBaseHeader()), $headers));
|
50 |
+
|
51 |
+
return (array) $this->preparePropertiesFromResponse(
|
52 |
+
$this->httpAction->post(
|
53 |
+
$this->getApiUrl()
|
54 |
+
)
|
55 |
+
);
|
56 |
+
}
|
57 |
}
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>paymentwall_magento_module</name>
|
4 |
-
<version>1.2.
|
5 |
<stability>stable</stability>
|
6 |
<license>MITL</license>
|
7 |
<channel>community</channel>
|
@@ -9,11 +9,12 @@
|
|
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
|
|
|
13 |
<authors><author><name>Paymentwall</name><user>platforms</user><email>platforms@paymentwall.com</email></author></authors>
|
14 |
-
<date>2016-
|
15 |
-
<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="f2d6ab9e2d3fe8ad1659a3bff216a3d6"/><file name="Pwbrick.php" hash="1c160f01004150d68ce154b7a87066fc"/><file name="Pwlocal.php" hash="4ddb1e8c27fde7fa94e176f7c80e20d7"/></dir></dir><dir name="Info"><dir name="Method"><file name="Pwbrick.php" hash="8544bd6cd4a5cfc13d1cbd55cb069417"/><file name="Pwlocal.php" hash="94f0b0a8de67881ce7b1417473fd4857"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="228b69871c84dded1808aae3748b9f02"/></dir><dir name="Model"><dir name="Method"><file name="Abstract.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>paymentwall_magento_module</name>
|
4 |
+
<version>1.2.6</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>MITL</license>
|
7 |
<channel>community</channel>
|
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>- Update order status by following 3Ds rule
|
13 |
+
- Fix minor bugs regarding Brick pingback</notes>
|
14 |
<authors><author><name>Paymentwall</name><user>platforms</user><email>platforms@paymentwall.com</email></author></authors>
|
15 |
+
<date>2016-07-06</date>
|
16 |
+
<time>08:19:38</time>
|
17 |
+
<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="f2d6ab9e2d3fe8ad1659a3bff216a3d6"/><file name="Pwbrick.php" hash="1c160f01004150d68ce154b7a87066fc"/><file name="Pwlocal.php" hash="4ddb1e8c27fde7fa94e176f7c80e20d7"/><file name="Pwlocaluni.php" hash="9fa9a1aaed01588d6a08c47c0f6c14ca"/></dir></dir><dir name="Info"><dir name="Method"><file name="Pwbrick.php" hash="8544bd6cd4a5cfc13d1cbd55cb069417"/><file name="Pwlocal.php" hash="94f0b0a8de67881ce7b1417473fd4857"/><file name="Pwlocaluni.php" hash="80d1b026f1d77bd6566bce6f4e844544"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="228b69871c84dded1808aae3748b9f02"/></dir><dir name="Model"><dir name="Method"><file name="Abstract.php" hash="dee5f7827c2b5cefab9da2d20c54021a"/><file name="Pwbrick.php" hash="f90dc08ed3c6679a1f1af58752c3f4be"/><file name="Pwlocal.php" hash="4e6ba24d9c6c0d50d91b60f3b0a24c69"/><file name="Pwlocaluni.php" hash="bb457694babe10d8ad37d4cea406e058"/></dir><file name="Pingback.php" hash="b22e6719a65cdfc7518be2046249c59f"/></dir><dir name="controllers"><file name="PaymentController.php" hash="148947e19495e5b871d5ce51f6ebbeb6"/></dir><dir name="etc"><file name="config.xml" hash="cb138ea5c186ef23ab3730765462d0c8"/><file name="system.xml" hash="a0df3d99fa0de7fd297b408ce05c67c5"/></dir></dir></dir></target><target name="magelib"><dir name="paymentwall-php"><file name="LICENSE" hash="3ae8192027222d0db9ab17715aeb7766"/><file name="README.md" hash="6a3acb5fcca19fe73f88152da1da7b17"/><file name="composer.json" hash="194c333090f9b0a0ff36147a9e23f856"/><dir name="features"><dir name="bootstrap"><file name="ChargeContext.php" hash="c3317439b22ca64831c53c56a54db5ee"/><file name="FeatureContext.php" hash="210fb9f584538c2b9266691776cab185"/><file name="PingbackContext.php" hash="d99b01eaa9b812f5ec44d6771d5155c4"/><file name="WidgetContext.php" hash="df042f6420265fa6888f7da810fbe929"/></dir><file name="charge.feature" hash="cc471cd226d847cc247f6c7182736c54"/><file name="pingback.feature" hash="f0037b11100151a366a0e8ff2bad37ec"/><file name="widget.feature" hash="0a11515b0032733d56b15fecbaa67986"/></dir><dir name="lib"><dir name="Paymentwall"><file name="ApiObject.php" hash="e6ba4d0c3b93adf84ae5819fddecf26c"/><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="GenerericApiObject.php" hash="bb1728e3e0227845eecf7b62cd414df6"/><file name="HttpAction.php" hash="555295426227f26733b7736692345667"/><file name="Instance.php" hash="86422afa5d43aac945021ef694b9bbc1"/><file name="OneTimeToken.php" hash="e3b9c56c34920c9b5ea53609d95acb3b"/><file name="Pingback.php" hash="a77fb2f158a60ab48af4d9f420a22894"/><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="6f4ee78ffb0677d2a49d2417dae2c038"/></dir><file name=".git" hash="50da8e1bb8ed3a4d1e1413fe2d6c0d68"/><file name=".gitignore" hash="9a3d3b31ed48a71f44a4d2e5eda936e9"/></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="fbfb8183e3d3d807247a8e3676d17f7d"/></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="a491093acc23b6b143e47412cdfd462b"/></dir><dir name="template"><dir name="paymentwall"><dir name="checkout"><dir name="form"><dir name="method"><file name="pwbrick.phtml" hash="4cfde237be456528f8cd01c200f21957"/><file name="pwlocal.phtml" hash="b964770e54bb91fca23a49951e3c744c"/></dir></dir><dir name="info"><dir name="method"><file name="pwbrick.phtml" hash="39d5b2f270187162bcb467f6330ff33a"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Paymentwall_Paymentwall.xml" hash="38a35e1b2234d0f9cba7c240a8df21d5"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|