Version Notes
* Update latest library.
* Add Recurring Profile support
Download this release
Release Info
Developer | Paymentwall |
Extension | paymentwall_magento_module |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.6 to 1.2.0
- app/code/community/Paymentwall/Paymentwall/Model/Method/Abstract.php +10 -46
- app/code/community/Paymentwall/Paymentwall/Model/Method/Pwbrick.php +166 -4
- app/code/community/Paymentwall/Paymentwall/Model/Method/Pwlocal.php +4 -8
- app/code/community/Paymentwall/Paymentwall/Model/Pingback.php +3 -6
- app/code/community/Paymentwall/Paymentwall/etc/config.xml +1 -1
- lib/paymentwall-php/README.md +67 -28
- lib/paymentwall-php/lib/Paymentwall/ApiObject.php +10 -0
- lib/paymentwall-php/lib/Paymentwall/HttpAction.php +17 -1
- lib/paymentwall-php/lib/Paymentwall/Pingback.php +1 -1
- package.xml +6 -5
- skin/frontend/base/default/js/paymentwall.js +2 -1
app/code/community/Paymentwall/Paymentwall/Model/Method/Abstract.php
CHANGED
@@ -11,16 +11,15 @@ if (!class_exists('Paymentwall_Config'))
|
|
11 |
/**
|
12 |
* Class Paymentwall_Paymentwall_Model_Method_Abstract
|
13 |
*/
|
14 |
-
class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_Method_Abstract
|
15 |
-
|
16 |
protected $_code;
|
17 |
protected $_logFile = 'paymentwall.log';
|
18 |
|
19 |
/**
|
20 |
* @param string $code
|
21 |
*/
|
22 |
-
public function __construct($code = '')
|
23 |
-
{
|
24 |
if ($code) {
|
25 |
$this->_code = 'paymentwall_' . $code;
|
26 |
}
|
@@ -30,39 +29,10 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
30 |
$this->setData('original_code', $code);
|
31 |
}
|
32 |
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Process pending payment
|
36 |
-
* @param Paymentwall_Pingback $pingback
|
37 |
-
* @throws Exception
|
38 |
-
* @return void
|
39 |
-
*/
|
40 |
-
public function processPendingPayment(Paymentwall_Pingback $pingback)
|
41 |
-
{
|
42 |
-
$order = $this->getCurrentOrder();
|
43 |
-
if ($order->getState() === Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW || $order->getState() === Mage_Sales_Model_Order::STATE_NEW) {
|
44 |
-
if ($pingback->isDeliverable()) {
|
45 |
-
$this->callDeliveryApi($pingback->getReferenceId());
|
46 |
-
$this->makeInvoice();
|
47 |
-
} elseif ($pingback->isCancelable()) {
|
48 |
-
$reason = $pingback->getParameter('reason');
|
49 |
-
$order->setState(
|
50 |
-
Mage_Sales_Model_Order::STATE_CANCELED,
|
51 |
-
$reason == self::REASON_ORDER_FRAUD || $reason == self::REASON_CC_FRAUD ? Mage_Sales_Model_Order::STATUS_FRAUD : true
|
52 |
-
);
|
53 |
-
$order->save();
|
54 |
-
}
|
55 |
-
} else {
|
56 |
-
$incrementId = $order->getIncrementId();
|
57 |
-
throw new Exception("This order {$incrementId} is not put in PENDING REVIEW STATE", 1);
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
/**
|
62 |
* Init paymentwall configs
|
63 |
*/
|
64 |
-
public function initPaymentwallConfig()
|
65 |
-
{
|
66 |
Paymentwall_Config::getInstance()->set(array(
|
67 |
'api_type' => Paymentwall_Config::API_GOODS,
|
68 |
'public_key' => $this->getConfigData('paymentwall_public_key'),
|
@@ -70,8 +40,7 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
70 |
));
|
71 |
}
|
72 |
|
73 |
-
public function getMethodCode()
|
74 |
-
{
|
75 |
return $this->_code;
|
76 |
}
|
77 |
|
@@ -79,8 +48,7 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
79 |
* @param $order
|
80 |
* @return array
|
81 |
*/
|
82 |
-
protected function prepareUserProfile(Mage_Sales_Model_Order $order)
|
83 |
-
{
|
84 |
$billing = $order->getBillingAddress();
|
85 |
$data = array(
|
86 |
'customer[city]' => $billing->getCity(),
|
@@ -115,8 +83,7 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
115 |
return $data;
|
116 |
}
|
117 |
|
118 |
-
public function callDeliveryApi($ref)
|
119 |
-
{
|
120 |
$this->initPaymentwallConfig();
|
121 |
if ($this->getConfigData('paymentwall_delivery')) {
|
122 |
$delivery = new Paymentwall_GenerericApiObject('delivery');
|
@@ -129,8 +96,7 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
129 |
* @param $ref
|
130 |
* @return array
|
131 |
*/
|
132 |
-
private function prepareDeliveryData(Mage_Sales_Model_Order $order, $ref)
|
133 |
-
{
|
134 |
$billing = $order->getBillingAddress();
|
135 |
$shipping = $order->getShippingAddress();
|
136 |
|
@@ -160,8 +126,7 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
160 |
* Make invoice for paid order
|
161 |
* @return void
|
162 |
*/
|
163 |
-
|
164 |
-
{
|
165 |
$order = $this->getCurrentOrder();
|
166 |
if ($order) {
|
167 |
$invoice = $order->prepareInvoice()
|
@@ -182,8 +147,7 @@ class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_M
|
|
182 |
* Log Function
|
183 |
* @param $message
|
184 |
*/
|
185 |
-
public function log($message, $section = '')
|
186 |
-
{
|
187 |
if ($this->getConfigData('debug_mode')) {
|
188 |
if (!is_string($message)) {
|
189 |
$message = var_export($message, true);
|
11 |
/**
|
12 |
* Class Paymentwall_Paymentwall_Model_Method_Abstract
|
13 |
*/
|
14 |
+
class Paymentwall_Paymentwall_Model_Method_Abstract extends Mage_Payment_Model_Method_Abstract {
|
15 |
+
|
16 |
protected $_code;
|
17 |
protected $_logFile = 'paymentwall.log';
|
18 |
|
19 |
/**
|
20 |
* @param string $code
|
21 |
*/
|
22 |
+
public function __construct($code = '') {
|
|
|
23 |
if ($code) {
|
24 |
$this->_code = 'paymentwall_' . $code;
|
25 |
}
|
29 |
$this->setData('original_code', $code);
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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'),
|
40 |
));
|
41 |
}
|
42 |
|
43 |
+
public function getMethodCode() {
|
|
|
44 |
return $this->_code;
|
45 |
}
|
46 |
|
48 |
* @param $order
|
49 |
* @return array
|
50 |
*/
|
51 |
+
protected function prepareUserProfile(Mage_Sales_Model_Order $order) {
|
|
|
52 |
$billing = $order->getBillingAddress();
|
53 |
$data = array(
|
54 |
'customer[city]' => $billing->getCity(),
|
83 |
return $data;
|
84 |
}
|
85 |
|
86 |
+
public function callDeliveryApi($ref) {
|
|
|
87 |
$this->initPaymentwallConfig();
|
88 |
if ($this->getConfigData('paymentwall_delivery')) {
|
89 |
$delivery = new Paymentwall_GenerericApiObject('delivery');
|
96 |
* @param $ref
|
97 |
* @return array
|
98 |
*/
|
99 |
+
private function prepareDeliveryData(Mage_Sales_Model_Order $order, $ref) {
|
|
|
100 |
$billing = $order->getBillingAddress();
|
101 |
$shipping = $order->getShippingAddress();
|
102 |
|
126 |
* Make invoice for paid order
|
127 |
* @return void
|
128 |
*/
|
129 |
+
public function makeInvoice() {
|
|
|
130 |
$order = $this->getCurrentOrder();
|
131 |
if ($order) {
|
132 |
$invoice = $order->prepareInvoice()
|
147 |
* Log Function
|
148 |
* @param $message
|
149 |
*/
|
150 |
+
public function log($message, $section = '') {
|
|
|
151 |
if ($this->getConfigData('debug_mode')) {
|
152 |
if (!is_string($message)) {
|
153 |
$message = var_export($message, true);
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Pwbrick.php
CHANGED
@@ -6,7 +6,9 @@
|
|
6 |
*
|
7 |
* Class Paymentwall_Paymentwall_Model_Method_Pwbrick
|
8 |
*/
|
9 |
-
class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwall_Model_Method_Abstract {
|
|
|
|
|
10 |
|
11 |
protected $_isInitializeNeeded = false;
|
12 |
protected $_canUseInternal = false;
|
@@ -25,7 +27,7 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
25 |
/**
|
26 |
* Prepare data for payment
|
27 |
* @param $payment
|
28 |
-
* @return
|
29 |
*/
|
30 |
public function prepareCardInfo($payment) {
|
31 |
$order = $payment->getOrder();
|
@@ -50,20 +52,24 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
50 |
if (!($data instanceof Varien_Object)) {
|
51 |
$data = new Varien_Object($data);
|
52 |
}
|
|
|
53 |
$info = $this->getInfoInstance();
|
54 |
$info->setAdditionalInformation('brick_token', $data->getBrickToken())
|
55 |
->setAdditionalInformation('brick_fingerprint', $data->getBrickFingerprint());
|
|
|
56 |
return $this;
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
* @param $payment
|
61 |
-
* @param
|
62 |
* @return Mage_Payment_Model_Abstract|void
|
63 |
* @throws Mage_Core_Exception
|
64 |
*/
|
65 |
public function capture(Varien_Object $payment, $amount) {
|
|
|
66 |
$this->initPaymentwallConfig();
|
|
|
67 |
$charge = new Paymentwall_Charge();
|
68 |
$charge->create(array_merge(
|
69 |
$this->prepareUserProfile($payment->getOrder()), // for User Profile API
|
@@ -73,6 +79,7 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
73 |
|
74 |
// Debug
|
75 |
$this->log($response, 'Charge response');
|
|
|
76 |
if ($charge->isSuccessful()) {
|
77 |
if ($charge->isCaptured()) {
|
78 |
// deliver a product
|
@@ -89,4 +96,159 @@ class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwa
|
|
89 |
Mage::throwException($strErrors);
|
90 |
}
|
91 |
}
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*
|
7 |
* Class Paymentwall_Paymentwall_Model_Method_Pwbrick
|
8 |
*/
|
9 |
+
class Paymentwall_Paymentwall_Model_Method_Pwbrick extends Paymentwall_Paymentwall_Model_Method_Abstract implements Mage_Payment_Model_Recurring_Profile_MethodInterface {
|
10 |
+
|
11 |
+
const MAX_LENGTH_OF_INTERNAL_REFERENCE_ID = 127;
|
12 |
|
13 |
protected $_isInitializeNeeded = false;
|
14 |
protected $_canUseInternal = false;
|
27 |
/**
|
28 |
* Prepare data for payment
|
29 |
* @param $payment
|
30 |
+
* @return array
|
31 |
*/
|
32 |
public function prepareCardInfo($payment) {
|
33 |
$order = $payment->getOrder();
|
52 |
if (!($data instanceof Varien_Object)) {
|
53 |
$data = new Varien_Object($data);
|
54 |
}
|
55 |
+
|
56 |
$info = $this->getInfoInstance();
|
57 |
$info->setAdditionalInformation('brick_token', $data->getBrickToken())
|
58 |
->setAdditionalInformation('brick_fingerprint', $data->getBrickFingerprint());
|
59 |
+
|
60 |
return $this;
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
* @param $payment
|
65 |
+
* @param $amount
|
66 |
* @return Mage_Payment_Model_Abstract|void
|
67 |
* @throws Mage_Core_Exception
|
68 |
*/
|
69 |
public function capture(Varien_Object $payment, $amount) {
|
70 |
+
|
71 |
$this->initPaymentwallConfig();
|
72 |
+
|
73 |
$charge = new Paymentwall_Charge();
|
74 |
$charge->create(array_merge(
|
75 |
$this->prepareUserProfile($payment->getOrder()), // for User Profile API
|
79 |
|
80 |
// Debug
|
81 |
$this->log($response, 'Charge response');
|
82 |
+
|
83 |
if ($charge->isSuccessful()) {
|
84 |
if ($charge->isCaptured()) {
|
85 |
// deliver a product
|
96 |
Mage::throwException($strErrors);
|
97 |
}
|
98 |
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Validate data
|
102 |
+
*
|
103 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
104 |
+
* @throws Mage_Core_Exception
|
105 |
+
*/
|
106 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile) {
|
107 |
+
$errors = array();
|
108 |
+
$refId = $profile->getInternalReferenceId(); // up to 127 single-byte alphanumeric
|
109 |
+
|
110 |
+
if (strlen($refId) > self::MAX_LENGTH_OF_INTERNAL_REFERENCE_ID) { // || !preg_match('/^[a-z\d\s]+$/i', $refId)
|
111 |
+
$errors[] = Mage::helper('paymentwall')->__('Merchant reference ID format is not supported.');
|
112 |
+
}
|
113 |
+
|
114 |
+
if ($errors) {
|
115 |
+
Mage::throwException(implode(' ', $errors));
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Submit to the gateway
|
121 |
+
*
|
122 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
123 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
124 |
+
*/
|
125 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo) {
|
126 |
+
|
127 |
+
$this->initPaymentwallConfig();
|
128 |
+
|
129 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
130 |
+
|
131 |
+
$subscriptionData = $this->prepareSubscriptionData($profile, $quote);
|
132 |
+
|
133 |
+
$paymentwallSubscription = new Paymentwall_Subscription();
|
134 |
+
|
135 |
+
$paymentwallSubscription->create($subscriptionData);
|
136 |
+
|
137 |
+
$response = json_decode($paymentwallSubscription->GetRawResponseData());
|
138 |
+
|
139 |
+
$this->log($response, 'Subscription Response Data');
|
140 |
+
|
141 |
+
if ($paymentwallSubscription->isSuccessful() && $response->object == 'subscription') {
|
142 |
+
$profile->setReferenceId($response->id);
|
143 |
+
|
144 |
+
if ($response->active) {
|
145 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
146 |
+
} else {
|
147 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_PENDING);
|
148 |
+
}
|
149 |
+
} else {
|
150 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN);
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
157 |
+
* @param $quote
|
158 |
+
* @return array
|
159 |
+
*/
|
160 |
+
protected function prepareSubscriptionData(Mage_Payment_Model_Recurring_Profile $profile, $quote) {
|
161 |
+
|
162 |
+
$post = Mage::app()->getRequest()->getPost('payment');
|
163 |
+
|
164 |
+
return array_merge(
|
165 |
+
array(
|
166 |
+
'token' => $post['brick_token'],
|
167 |
+
'amount' => $profile->getBillingAmount(),
|
168 |
+
'currency' => $profile->getCurrencyCode(),
|
169 |
+
'email' => $quote->getBillingAddress()->getEmail(),
|
170 |
+
'fingerprint' => $post['brick_fingerprint'],
|
171 |
+
'description' => $profile->getScheduleDescription(),
|
172 |
+
'plan' => $profile->getInternalReferenceId(),
|
173 |
+
'period' => $profile->getPeriodUnit(),
|
174 |
+
'period_duration' => $profile->getPeriodFrequency(),
|
175 |
+
),
|
176 |
+
$this->prepareTrialData($profile)
|
177 |
+
);
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
182 |
+
* @return array
|
183 |
+
*/
|
184 |
+
protected function prepareTrialData(Mage_Payment_Model_Recurring_Profile $profile) {
|
185 |
+
|
186 |
+
if (!$profile->getTrialPeriodFrequency()) {
|
187 |
+
return array();
|
188 |
+
}
|
189 |
+
|
190 |
+
return array(
|
191 |
+
'trial[amount]' => $profile->getInitAmount(),
|
192 |
+
'trial[currency]' => $profile->getCurrencyCode(),
|
193 |
+
'trial[period]' => $profile->getTrialPeriodUnit(),
|
194 |
+
'trial[period_duration]' => $profile->getTrialPeriodFrequency(),
|
195 |
+
);
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Fetch details
|
200 |
+
*
|
201 |
+
* @param string $referenceId
|
202 |
+
* @param Varien_Object $result
|
203 |
+
* @return Varien_Object
|
204 |
+
*/
|
205 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result) {
|
206 |
+
|
207 |
+
$this->initPaymentwallConfig();
|
208 |
+
|
209 |
+
$paymentwallSubscription = new Paymentwall_Subscription($referenceId);
|
210 |
+
$paymentwallSubscription->get();
|
211 |
+
|
212 |
+
$subscriptionData = json_decode($paymentwallSubscription->GetRawResponseData());
|
213 |
+
$result->setData($subscriptionData);
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Check whether can get recurring profile details
|
219 |
+
*
|
220 |
+
* @return bool
|
221 |
+
*/
|
222 |
+
public function canGetRecurringProfileDetails() {
|
223 |
+
return true;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Update data
|
228 |
+
*
|
229 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
230 |
+
*/
|
231 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile) {
|
232 |
+
// TODO: Implement updateRecurringProfile() method.
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Manage status
|
237 |
+
*
|
238 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
239 |
+
*/
|
240 |
+
/**
|
241 |
+
* Manage status
|
242 |
+
*
|
243 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
244 |
+
*/
|
245 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile) {
|
246 |
+
$this->initPaymentwallConfig();
|
247 |
+
|
248 |
+
$paymentwallSubscription = new Paymentwall_Subscription($profile->getReferenceId());
|
249 |
+
|
250 |
+
if ($profile->getNewState() == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED) {
|
251 |
+
$paymentwallSubscription->cancel();
|
252 |
+
}
|
253 |
+
}
|
254 |
+
}
|
app/code/community/Paymentwall/Paymentwall/Model/Method/Pwlocal.php
CHANGED
@@ -4,8 +4,7 @@
|
|
4 |
* @author Paymentwall Inc <devsupport@paymentwall.com>
|
5 |
* @package Paymentwall\ThirdpartyIntegration\Magento\Model\Method
|
6 |
*/
|
7 |
-
class Paymentwall_Paymentwall_Model_Method_Pwlocal extends Paymentwall_Paymentwall_Model_Method_Abstract
|
8 |
-
{
|
9 |
protected $_isGateway = true;
|
10 |
protected $_canUseInternal = false;
|
11 |
protected $_canUseForMultishipping = false;
|
@@ -14,13 +13,11 @@ class Paymentwall_Paymentwall_Model_Method_Pwlocal extends Paymentwall_Paymentwa
|
|
14 |
* Constructor method.
|
15 |
* Set some internal properties
|
16 |
*/
|
17 |
-
public function __construct()
|
18 |
-
{
|
19 |
parent::__construct('pwlocal');
|
20 |
}
|
21 |
|
22 |
-
public function getOrderPlaceRedirectUrl()
|
23 |
-
{
|
24 |
return Mage::getUrl('paymentwall/payment/pwlocal', array('_secure' => true));
|
25 |
}
|
26 |
|
@@ -29,8 +26,7 @@ class Paymentwall_Paymentwall_Model_Method_Pwlocal extends Paymentwall_Paymentwa
|
|
29 |
* @param $order
|
30 |
* @return Paymentwall_Widget
|
31 |
*/
|
32 |
-
public function getPaymentWidget(Mage_Sales_Model_Order $order)
|
33 |
-
{
|
34 |
$this->initPaymentwallConfig();
|
35 |
|
36 |
$widget = new Paymentwall_Widget(
|
4 |
* @author Paymentwall Inc <devsupport@paymentwall.com>
|
5 |
* @package Paymentwall\ThirdpartyIntegration\Magento\Model\Method
|
6 |
*/
|
7 |
+
class Paymentwall_Paymentwall_Model_Method_Pwlocal extends Paymentwall_Paymentwall_Model_Method_Abstract {
|
|
|
8 |
protected $_isGateway = true;
|
9 |
protected $_canUseInternal = false;
|
10 |
protected $_canUseForMultishipping = false;
|
13 |
* Constructor method.
|
14 |
* Set some internal properties
|
15 |
*/
|
16 |
+
public function __construct() {
|
|
|
17 |
parent::__construct('pwlocal');
|
18 |
}
|
19 |
|
20 |
+
public function getOrderPlaceRedirectUrl() {
|
|
|
21 |
return Mage::getUrl('paymentwall/payment/pwlocal', array('_secure' => true));
|
22 |
}
|
23 |
|
26 |
* @param $order
|
27 |
* @return Paymentwall_Widget
|
28 |
*/
|
29 |
+
public function getPaymentWidget(Mage_Sales_Model_Order $order) {
|
|
|
30 |
$this->initPaymentwallConfig();
|
31 |
|
32 |
$widget = new Paymentwall_Widget(
|
app/code/community/Paymentwall/Paymentwall/Model/Pingback.php
CHANGED
@@ -71,21 +71,18 @@ class Paymentwall_Paymentwall_Model_Pingback extends Mage_Core_Model_Abstract {
|
|
71 |
if ($order->getId()) {
|
72 |
try {
|
73 |
if ($pingback->isDeliverable()) {
|
74 |
-
|
75 |
$paymentModel = $order->getPayment()->getMethodInstance();
|
76 |
-
$paymentModel->setCurrentOrder($order)
|
77 |
-
|
78 |
|
79 |
-
return self::DEFAULT_PINGBACK_RESPONSE;
|
80 |
} elseif ($pingback->isCancelable()) {
|
81 |
$order->registerCancellation(Mage::helper('sales')->__('Order marked as cancelled by Paymentwall.'))
|
82 |
->save();
|
83 |
-
return Mage::helper('sales')->__('Order marked as cancelled by Paymentwall.');
|
84 |
} elseif ($pingback->isUnderReview()) {
|
85 |
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true)
|
86 |
->save();
|
87 |
}
|
88 |
-
|
89 |
} catch (Exception $e) {
|
90 |
Mage::log($e->getMessage());
|
91 |
$result = 'Internal server error';
|
71 |
if ($order->getId()) {
|
72 |
try {
|
73 |
if ($pingback->isDeliverable()) {
|
|
|
74 |
$paymentModel = $order->getPayment()->getMethodInstance();
|
75 |
+
$paymentModel->setCurrentOrder($order)->callDeliveryApi($pingback->getReferenceId());
|
76 |
+
$paymentModel->makeInvoice();
|
77 |
|
|
|
78 |
} elseif ($pingback->isCancelable()) {
|
79 |
$order->registerCancellation(Mage::helper('sales')->__('Order marked as cancelled by Paymentwall.'))
|
80 |
->save();
|
|
|
81 |
} elseif ($pingback->isUnderReview()) {
|
82 |
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true)
|
83 |
->save();
|
84 |
}
|
85 |
+
return self::DEFAULT_PINGBACK_RESPONSE;
|
86 |
} catch (Exception $e) {
|
87 |
Mage::log($e->getMessage());
|
88 |
$result = 'Internal server error';
|
app/code/community/Paymentwall/Paymentwall/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Paymentwall_Paymentwall>
|
5 |
-
<version>1.
|
6 |
</Paymentwall_Paymentwall>
|
7 |
</modules>
|
8 |
<frontend>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Paymentwall_Paymentwall>
|
5 |
+
<version>1.2.0</version>
|
6 |
</Paymentwall_Paymentwall>
|
7 |
</modules>
|
8 |
<frontend>
|
lib/paymentwall-php/README.md
CHANGED
@@ -46,7 +46,8 @@ Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentw
|
|
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 |
-
|
|
|
50 |
'user40012', // id of the end-user who's making the payment
|
51 |
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
52 |
array( // product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty
|
@@ -64,12 +65,17 @@ The widget is a payment page hosted by Paymentwall that embeds the entire paymen
|
|
64 |
array('email' => 'user@hostname.com') // additional parameters
|
65 |
);
|
66 |
echo $widget->getHtmlCode();
|
67 |
-
|
68 |
|
69 |
####Pingback Processing
|
70 |
|
71 |
The Pingback is a webhook notifying about a payment being made. Pingbacks are sent via HTTP/HTTPS to your servers. To process pingbacks use the following code:
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
if ($pingback->validate()) {
|
74 |
$productId = $pingback->getProduct()->getId();
|
75 |
if ($pingback->isDeliverable()) {
|
@@ -80,7 +86,8 @@ if ($pingback->validate()) {
|
|
80 |
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
81 |
} else {
|
82 |
echo $pingback->getErrorSummary();
|
83 |
-
}
|
|
|
84 |
|
85 |
##Virtual Currency API
|
86 |
|
@@ -103,18 +110,24 @@ Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentw
|
|
103 |
```
|
104 |
|
105 |
####Widget Call
|
106 |
-
|
|
|
107 |
'user40012', // id of the end-user who's making the payment
|
108 |
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account
|
109 |
array(), // array of products - leave blank for Virtual Currency API
|
110 |
array('email' => 'user@hostname.com') // additional parameters
|
111 |
);
|
112 |
echo $widget->getHtmlCode();
|
113 |
-
|
114 |
|
115 |
####Pingback Processing
|
116 |
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
118 |
if ($pingback->validate()) {
|
119 |
$virtualCurrency = $pingback->getVirtualCurrencyAmount();
|
120 |
if ($pingback->isDeliverable()) {
|
@@ -125,7 +138,8 @@ if ($pingback->validate()) {
|
|
125 |
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
126 |
} else {
|
127 |
echo $pingback->getErrorSummary();
|
128 |
-
}
|
|
|
129 |
|
130 |
##Cart API
|
131 |
|
@@ -148,7 +162,8 @@ Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentw
|
|
148 |
```
|
149 |
|
150 |
####Widget Call
|
151 |
-
|
|
|
152 |
'user40012', // id of the end-user who's making the payment
|
153 |
'p1_1', // widget code, e.g. p1; can be picked inside of your merchant account,
|
154 |
array(
|
@@ -157,11 +172,17 @@ Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentw
|
|
157 |
),
|
158 |
array('email' => 'user@hostname.com') // additional params
|
159 |
);
|
160 |
-
echo $widget->getHtmlCode()
|
|
|
161 |
|
162 |
####Pingback Processing
|
163 |
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
165 |
if ($pingback->validate()) {
|
166 |
$products = $pingback->getProducts();
|
167 |
if ($pingback->isDeliverable()) {
|
@@ -172,28 +193,35 @@ if ($pingback->validate()) {
|
|
172 |
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
|
173 |
} else {
|
174 |
echo $pingback->getErrorSummary();
|
175 |
-
}
|
|
|
176 |
|
177 |
##Brick
|
178 |
|
179 |
####Initializing Paymentwall
|
180 |
-
|
|
|
181 |
'public_key' => 'YOUR_PUBLIC_KEY',
|
182 |
'private_key' => 'YOUR_PRIVATE_KEY'
|
183 |
-
))
|
|
|
184 |
|
185 |
####Create a one-time token
|
186 |
-
|
|
|
187 |
$token = $tokenModel->create(array(
|
188 |
'public_key' => Paymentwall_Config::getInstance()->getPublicKey(),
|
189 |
'card[number]' => '4242424242424242',
|
190 |
'card[exp_month]' => '11',
|
191 |
'card[exp_year]' => '19',
|
192 |
'card[cvv]' => '123'
|
193 |
-
))
|
|
|
|
|
194 |
|
195 |
####Charge
|
196 |
-
|
|
|
197 |
$charge->create(array(
|
198 |
// if generated via backend
|
199 |
//'token' => $token->getToken(),
|
@@ -220,18 +248,22 @@ if ($charge->isSuccessful()) {
|
|
220 |
echo $errors['error']['message'];
|
221 |
}
|
222 |
|
223 |
-
echo $response; // need for JS communication
|
|
|
224 |
|
225 |
####Charge - refund
|
226 |
|
227 |
-
|
|
|
228 |
$charge->refund();
|
229 |
|
230 |
-
echo $charge->isRefunded()
|
|
|
231 |
|
232 |
####Subscription
|
233 |
|
234 |
-
|
|
|
235 |
$subscription->create(array(
|
236 |
// if generated via backend
|
237 |
//'token' => $token->getToken(),
|
@@ -247,27 +279,34 @@ $subscription->create(array(
|
|
247 |
'period_duration' => 2
|
248 |
));
|
249 |
|
250 |
-
echo $subscription->getId()
|
|
|
251 |
|
252 |
####Subscription - cancel
|
253 |
|
254 |
-
|
|
|
255 |
$subscription->cancel();
|
256 |
|
257 |
-
echo $subscription->isActive()
|
|
|
258 |
|
259 |
###Signature calculation - Widget
|
260 |
|
261 |
-
|
|
|
262 |
echo $widgetSignatureModel->calculate(
|
263 |
array(), // widget params
|
264 |
2 // signature version
|
265 |
-
)
|
|
|
266 |
|
267 |
###Singature calculation - Pingback
|
268 |
|
269 |
-
|
|
|
270 |
echo $pingbackSignatureModel->calculate(
|
271 |
array(), // pingback params
|
272 |
1 // signature version
|
273 |
-
)
|
|
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
|
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()) {
|
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 |
|
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()) {
|
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 |
|
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(
|
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()) {
|
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(),
|
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(),
|
279 |
'period_duration' => 2
|
280 |
));
|
281 |
|
282 |
+
echo $subscription->getId();
|
283 |
+
```
|
284 |
|
285 |
####Subscription - cancel
|
286 |
|
287 |
+
```php
|
288 |
+
$subscription = new Paymentwall_Subscription('SUBSCRIPTION_ID');
|
289 |
$subscription->cancel();
|
290 |
|
291 |
+
echo $subscription->isActive();
|
292 |
+
```
|
293 |
|
294 |
###Signature calculation - Widget
|
295 |
|
296 |
+
```php
|
297 |
+
$widgetSignatureModel = new Paymentwall_Signature_Widget();
|
298 |
echo $widgetSignatureModel->calculate(
|
299 |
array(), // widget params
|
300 |
2 // signature version
|
301 |
+
);
|
302 |
+
```
|
303 |
|
304 |
###Singature calculation - Pingback
|
305 |
|
306 |
+
```php
|
307 |
+
$pingbackSignatureModel = new Paymentwall_Signature_Pingback();
|
308 |
echo $pingbackSignatureModel->calculate(
|
309 |
array(), // pingback params
|
310 |
1 // signature version
|
311 |
+
);
|
312 |
+
```
|
lib/paymentwall-php/lib/Paymentwall/ApiObject.php
CHANGED
@@ -10,6 +10,7 @@ abstract class Paymentwall_ApiObject extends Paymentwall_Instance
|
|
10 |
protected $properties = array();
|
11 |
protected $_id;
|
12 |
protected $_rawResponse = '';
|
|
|
13 |
protected $brickSubEndpoints = array(
|
14 |
self::API_OBJECT_CHARGE, self::API_OBJECT_SUBSCRIPTION, self::API_OBJECT_ONE_TIME_TOKEN
|
15 |
);
|
@@ -99,9 +100,18 @@ abstract class Paymentwall_ApiObject extends Paymentwall_Instance
|
|
99 |
$httpAction = new Paymentwall_HttpAction($this, array('id' => $this->_id), array(
|
100 |
$this->getApiBaseHeader()
|
101 |
));
|
|
|
102 |
$this->setPropertiesFromResponse(
|
103 |
$method == 'get' ? $httpAction->get($actionUrl) : $httpAction->post($actionUrl)
|
104 |
);
|
|
|
105 |
return $this;
|
106 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
10 |
protected $properties = array();
|
11 |
protected $_id;
|
12 |
protected $_rawResponse = '';
|
13 |
+
protected $_responseLogInformation = array();
|
14 |
protected $brickSubEndpoints = array(
|
15 |
self::API_OBJECT_CHARGE, self::API_OBJECT_SUBSCRIPTION, self::API_OBJECT_ONE_TIME_TOKEN
|
16 |
);
|
100 |
$httpAction = new Paymentwall_HttpAction($this, array('id' => $this->_id), array(
|
101 |
$this->getApiBaseHeader()
|
102 |
));
|
103 |
+
$this->_responseLogInformation = $httpAction->getResponseLogInformation();
|
104 |
$this->setPropertiesFromResponse(
|
105 |
$method == 'get' ? $httpAction->get($actionUrl) : $httpAction->post($actionUrl)
|
106 |
);
|
107 |
+
|
108 |
return $this;
|
109 |
}
|
110 |
+
|
111 |
+
public function getResponseLogInformation()
|
112 |
+
{
|
113 |
+
return $this->_responseLogInformation;
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
}
|
lib/paymentwall-php/lib/Paymentwall/HttpAction.php
CHANGED
@@ -5,6 +5,7 @@ class Paymentwall_HttpAction extends Paymentwall_Instance
|
|
5 |
protected $apiObject;
|
6 |
protected $apiParams = array();
|
7 |
protected $apiHeaders = array();
|
|
|
8 |
|
9 |
public function __construct($object, $params = array(), $headers = array())
|
10 |
{
|
@@ -99,12 +100,23 @@ class Paymentwall_HttpAction extends Paymentwall_Instance
|
|
99 |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
100 |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
101 |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
|
102 |
|
103 |
$response = curl_exec($curl);
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
curl_close($curl);
|
106 |
|
107 |
-
return $this->prepareResponse($
|
108 |
}
|
109 |
|
110 |
protected function getLibraryDefaultRequestHeader()
|
@@ -116,4 +128,8 @@ class Paymentwall_HttpAction extends Paymentwall_Instance
|
|
116 |
{
|
117 |
return preg_replace('/\x{FEFF}/u', '', $string);
|
118 |
}
|
|
|
|
|
|
|
|
|
119 |
}
|
5 |
protected $apiObject;
|
6 |
protected $apiParams = array();
|
7 |
protected $apiHeaders = array();
|
8 |
+
protected $responseLogInformation = array();
|
9 |
|
10 |
public function __construct($object, $params = array(), $headers = array())
|
11 |
{
|
100 |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
101 |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
102 |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
103 |
+
curl_setopt($curl, CURLOPT_HEADER, true);
|
104 |
|
105 |
$response = curl_exec($curl);
|
106 |
|
107 |
+
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
108 |
+
$header = substr($response, 0, $headerSize);
|
109 |
+
$body = substr($response, $headerSize);
|
110 |
+
|
111 |
+
$this->responseLogInformation = array(
|
112 |
+
'header' => $header,
|
113 |
+
'body' => $body,
|
114 |
+
'status' => curl_getinfo($curl, CURLINFO_HTTP_CODE)
|
115 |
+
);
|
116 |
+
|
117 |
curl_close($curl);
|
118 |
|
119 |
+
return $this->prepareResponse($body);
|
120 |
}
|
121 |
|
122 |
protected function getLibraryDefaultRequestHeader()
|
128 |
{
|
129 |
return preg_replace('/\x{FEFF}/u', '', $string);
|
130 |
}
|
131 |
+
|
132 |
+
public function getResponseLogInformation() {
|
133 |
+
return $this->responseLogInformation;
|
134 |
+
}
|
135 |
}
|
lib/paymentwall-php/lib/Paymentwall/Pingback.php
CHANGED
@@ -196,7 +196,7 @@ class Paymentwall_Pingback extends Paymentwall_Instance
|
|
196 |
$result = array();
|
197 |
$productIds = $this->getParameter('goodsid');
|
198 |
|
199 |
-
if (!empty($productIds)) {
|
200 |
foreach ($productIds as $Id) {
|
201 |
$result[] = new Paymentwall_Product($Id);
|
202 |
}
|
196 |
$result = array();
|
197 |
$productIds = $this->getParameter('goodsid');
|
198 |
|
199 |
+
if (!empty($productIds) && is_array($productIds)) {
|
200 |
foreach ($productIds as $Id) {
|
201 |
$result[] = new Paymentwall_Product($Id);
|
202 |
}
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>paymentwall_magento_module</name>
|
4 |
-
<version>1.
|
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>2015-
|
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="de9bfa933a6e1757c3bab53768ec4d62"/><file name="Pwbrick.php" hash="c01cabde8670bdff801534fe283b0534"/><file name="Pwlocal.php" hash="2d4a1fb4fdfcaaf5d7cf72eae4231965"/></dir></dir><dir name="Info"><dir name="Method"><file name="Pwbrick.php" hash="4d8bc2a37e04c180896a708dabf9cfa7"/><file name="Pwlocal.php" hash="52d3d7580cbdcc8bf0f98834b9a9e5a0"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4270b082a8264e63f6a82228b3e2c1d2"/></dir><dir name="Model"><dir name="Method"><file name="Abstract.php" hash="
|
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.0</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 latest library.
|
13 |
+
* Add Recurring Profile support</notes>
|
14 |
<authors><author><name>Paymentwall</name><user>platforms</user><email>platforms@paymentwall.com</email></author></authors>
|
15 |
+
<date>2015-12-04</date>
|
16 |
+
<time>08:02:23</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="de9bfa933a6e1757c3bab53768ec4d62"/><file name="Pwbrick.php" hash="c01cabde8670bdff801534fe283b0534"/><file name="Pwlocal.php" hash="2d4a1fb4fdfcaaf5d7cf72eae4231965"/></dir></dir><dir name="Info"><dir name="Method"><file name="Pwbrick.php" hash="4d8bc2a37e04c180896a708dabf9cfa7"/><file name="Pwlocal.php" hash="52d3d7580cbdcc8bf0f98834b9a9e5a0"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4270b082a8264e63f6a82228b3e2c1d2"/></dir><dir name="Model"><dir name="Method"><file name="Abstract.php" hash="9eecab8a827575d3b0ab149d0ab72d46"/><file name="Pwbrick.php" hash="7d0c589cf2b3ffdcd61b2c423c20d631"/><file name="Pwlocal.php" hash="1caba151445220b8cfa8ff17e149b525"/></dir><file name="Pingback.php" hash="ee609fd506ff00241c91191341fc2464"/></dir><dir name="controllers"><file name="PaymentController.php" hash="6d576fabeef93bc1e36a1dad97a26f9c"/></dir><dir name="etc"><file name="config.xml" hash="2a8c907edd7a48db8143da469a258046"/><file name="system.xml" hash="82abac90b5d8edf1b47e72135245b2ea"/></dir></dir></dir></target><target name="magelib"><dir name="paymentwall-php"><file name="LICENSE" hash="001561189374b83bcd6bc7f962daee8a"/><file name="README.md" hash="04122bf55fe20b9954feb14817435da2"/><file name="composer.json" hash="4e7035c64f2d74ba0a5f5cf80effe45e"/><dir name="features"><dir name="bootstrap"><file name="ChargeContext.php" hash="f1d0604f2fc16dd5932535f9c24995a3"/><file name="FeatureContext.php" hash="146d6e79c6704cfb24ee6f2a7b7fba5a"/><file name="PingbackContext.php" hash="b6c86d8f3c9caa21435f47ddb2d5add1"/><file name="WidgetContext.php" hash="70c8d608eb407e346467c2a8f7162732"/></dir><file name="charge.feature" hash="04258fc641535794c48c6c55aad7f94f"/><file name="pingback.feature" hash="05869da8a3e36b6bec0293a22c1a9235"/><file name="widget.feature" hash="198999d8bf357de175f3268cc88337f6"/></dir><dir name="lib"><dir name="Paymentwall"><file name="ApiObject.php" hash="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="6016e500c2c6736048c2f27ae8924a1c"/><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="d22fe2936066c576100994c62f32761e"/></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="d10a03a2130a5cdb87106a3eaa0cd30a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="paymentwall.xml" hash="15713872f2239c9b3cb615291b36e54b"/></dir><dir name="template"><dir name="paymentwall"><dir name="checkout"><dir name="form"><dir name="method"><file name="pwbrick.phtml" hash="95f073505e84b3c75607ff52538c01c7"/><file name="pwlocal.phtml" hash="b964770e54bb91fca23a49951e3c744c"/></dir></dir><dir name="info"><dir name="method"><file name="pwbrick.phtml" hash="b23472e15332c427456e9d92619eecff"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Paymentwall_Paymentwall.xml" hash="a5ef063119f4c0d274cc2f7a72699538"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
skin/frontend/base/default/js/paymentwall.js
CHANGED
@@ -57,6 +57,7 @@ var PW = {
|
|
57 |
},
|
58 |
"rewriteSavePayment": function (brick) {
|
59 |
|
|
|
60 |
if (this.rewritePayment) {
|
61 |
return false;
|
62 |
}
|
@@ -74,7 +75,7 @@ var PW = {
|
|
74 |
function (response) {
|
75 |
// handle errors
|
76 |
if (response.type == 'Error') {
|
77 |
-
alert("Brick Error:\nCode [" + response.code + "]: " + response.error);
|
78 |
return false;
|
79 |
} else {
|
80 |
$('paymentwall_pwbrick_token').value = response.token;
|
57 |
},
|
58 |
"rewriteSavePayment": function (brick) {
|
59 |
|
60 |
+
// Check second load
|
61 |
if (this.rewritePayment) {
|
62 |
return false;
|
63 |
}
|
75 |
function (response) {
|
76 |
// handle errors
|
77 |
if (response.type == 'Error') {
|
78 |
+
alert("Brick Error(s):\nCode [" + response.code + "]: " + response.error);
|
79 |
return false;
|
80 |
} else {
|
81 |
$('paymentwall_pwbrick_token').value = response.token;
|