Version Notes
Minor bug fixes
Download this release
Release Info
Developer | Paystation |
Extension | Paystation_Magento_1_8_ModuleV5 |
Version | 0.0.13 |
Comparing to | |
See all releases |
Code changes from version 0.0.10 to 0.0.13
app/code/local/Mage/Paystation/Model/Standard.php
CHANGED
@@ -275,7 +275,7 @@ class Mage_Paystation_Model_Standard extends Mage_Payment_Model_Method_Abstract
|
|
275 |
$quote = Mage::getModel('sales/quote')->load($quoteID);
|
276 |
$reservedOrderId = $quote->getReservedOrderId();
|
277 |
|
278 |
-
$authenticationKey = Mage::getStoreConfig('payment/paystation_standard/hmac_key', Mage::app()->getStore());
|
279 |
$hmacWebserviceName = 'paystation';
|
280 |
$pstn_HMACTimestamp = time();
|
281 |
|
@@ -284,8 +284,8 @@ class Mage_Paystation_Model_Standard extends Mage_Payment_Model_Method_Abstract
|
|
284 |
$amount = ($checkoutfields['final_amount'] * 100);
|
285 |
$testMode = ($checkoutfields['testmode'] ? true : false);
|
286 |
$postback = Mage::getStoreConfig('payment/paystation_standard/postback', Mage::app()->getStore());
|
287 |
-
$pstn_pi = $checkoutfields['merchant_id']; //"607113"; //Paystation ID
|
288 |
-
$pstn_gi =
|
289 |
$site = ''; // site can be used to differentiate transactions from different websites in admin.
|
290 |
// $pstn_mr = urlencode('schlocalhost-' . time()); // merchant reference is optional, but is a great way to tie a transaction in with a customer (this is displayed in Paystation Administration when looking at transaction details). Max length is 64 char. Make sure you use it!
|
291 |
if ($testMode) $pstn_mr = urlencode($email.':test-mode:'.$reservedOrderId);
|
275 |
$quote = Mage::getModel('sales/quote')->load($quoteID);
|
276 |
$reservedOrderId = $quote->getReservedOrderId();
|
277 |
|
278 |
+
$authenticationKey = trim(Mage::getStoreConfig('payment/paystation_standard/hmac_key', Mage::app()->getStore()));
|
279 |
$hmacWebserviceName = 'paystation';
|
280 |
$pstn_HMACTimestamp = time();
|
281 |
|
284 |
$amount = ($checkoutfields['final_amount'] * 100);
|
285 |
$testMode = ($checkoutfields['testmode'] ? true : false);
|
286 |
$postback = Mage::getStoreConfig('payment/paystation_standard/postback', Mage::app()->getStore());
|
287 |
+
$pstn_pi = trim($checkoutfields['merchant_id']); //"607113"; //Paystation ID
|
288 |
+
$pstn_gi =trim($checkoutfields['gateway_id']); //"CARDPAY"; //Gateway ID
|
289 |
$site = ''; // site can be used to differentiate transactions from different websites in admin.
|
290 |
// $pstn_mr = urlencode('schlocalhost-' . time()); // merchant reference is optional, but is a great way to tie a transaction in with a customer (this is displayed in Paystation Administration when looking at transaction details). Max length is 64 char. Make sure you use it!
|
291 |
if ($testMode) $pstn_mr = urlencode($email.':test-mode:'.$reservedOrderId);
|
app/code/local/Mage/Paystation/controllers/PostbackController.php
CHANGED
@@ -58,11 +58,11 @@ class Mage_Paystation_PostbackController extends Mage_Core_Controller_Front_Acti
|
|
58 |
$xpl = explode(':', $merchant_ref);
|
59 |
$customer_email = $xpl[0];
|
60 |
$orderid = $xpl[1];
|
61 |
-
|
62 |
|
63 |
-
if ($orderid == "test-mode" && $testmode =="1") {
|
64 |
-
|
65 |
-
|
66 |
|
67 |
|
68 |
|
@@ -75,65 +75,63 @@ class Mage_Paystation_PostbackController extends Mage_Core_Controller_Front_Acti
|
|
75 |
if ($errorCode == 0) {
|
76 |
|
77 |
// transaction approved ...
|
|
|
78 |
|
79 |
-
|
80 |
|
81 |
-
$this->processOrder($order, $transactionId, $errorMessage);
|
82 |
-
|
83 |
$s = $order->getStatusLabel();
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
//var_dump ($s);
|
90 |
-
//var_dump ($order);
|
91 |
|
92 |
$success = true;
|
93 |
|
94 |
$msg = "Payment successful.\n<br />TnxID: " . $transactionId . ".\n<br />TnxSess: " . $merchantSession;
|
95 |
-
|
96 |
|
97 |
return; // this
|
98 |
} else {
|
99 |
if ($order->getId()) {
|
100 |
$order->addStatusToHistory(
|
101 |
-
$order->getStatus()
|
102 |
Mage_Sales_Model_Order::STATE_CANCELED, urldecode($errorMessage) . ' at PayStation', Mage::helper('paystation')->__($errorMessage . ' from PayStation')
|
103 |
);
|
104 |
-
|
105 |
$order->save();
|
106 |
|
107 |
-
|
108 |
}
|
109 |
}
|
110 |
}
|
111 |
}
|
112 |
|
113 |
-
function processOrder($order,
|
114 |
//$s = "dsffsdsd";//$order->getStatusLabel();
|
115 |
-
|
116 |
// echo " ?? ??";
|
117 |
//var_dump ($s);
|
118 |
//echo "<hr>";
|
119 |
//
|
120 |
// echo "<pre>";
|
121 |
// var_dump($order);
|
122 |
-
|
123 |
|
124 |
if ($order->getId()) {
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
137 |
//var_dump ($order);
|
138 |
|
139 |
if (method_exists($payment, 'registerCaptureNotification')) {
|
@@ -141,37 +139,38 @@ class Mage_Paystation_PostbackController extends Mage_Core_Controller_Front_Acti
|
|
141 |
$order->sendNewOrderEmail();
|
142 |
} else {
|
143 |
$newOrderStatus = $order->getStatus();
|
144 |
-
if (!$order->canInvoice()) {
|
145 |
-
// when order cannot create invoice, need to have some logic to take care
|
146 |
-
$order->addStatusToHistory(
|
147 |
-
$order->getStatus(), // keep order status/state
|
148 |
-
Mage::helper('paystation')->__('Error in creating an invoice', true), $notified = true
|
149 |
-
);
|
150 |
-
} else {
|
151 |
-
// need to save transaction id
|
152 |
-
$order->getPayment()->setTransactionId($_POST['order_num']);
|
153 |
-
|
154 |
-
// need to convert from order into invoice
|
155 |
-
$invoice = $order->prepareInvoice();
|
156 |
-
$invoice->register()->pay();
|
157 |
-
Mage::getModel('core/resource_transaction')
|
158 |
-
->addObject($invoice)
|
159 |
-
->addObject($invoice->getOrder())
|
160 |
-
->save();
|
161 |
-
|
162 |
-
$order->setState(
|
163 |
-
//Mage_Sales_Model_Order::STATE_COMPLETE, true,
|
164 |
-
Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('paystation')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()), $notified = true);
|
165 |
-
//Mage_Sales_Model_Order::STATE_PROCESSING);//, true, Mage::helper('paystation')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()), $notified = true);
|
166 |
-
|
167 |
-
$order->save();
|
168 |
-
$order->sendNewOrderEmail();
|
169 |
-
}
|
170 |
}
|
171 |
$order->save();
|
172 |
}
|
173 |
}
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
|
177 |
?>
|
58 |
$xpl = explode(':', $merchant_ref);
|
59 |
$customer_email = $xpl[0];
|
60 |
$orderid = $xpl[1];
|
61 |
+
$testmode = Mage::getStoreConfig('payment/paystation_standard/testmode', Mage::app()->getStore());
|
62 |
|
63 |
+
if ($orderid == "test-mode" && $testmode == "1") {
|
64 |
+
$orderid = $xpl[2];
|
65 |
+
}
|
66 |
|
67 |
|
68 |
|
75 |
if ($errorCode == 0) {
|
76 |
|
77 |
// transaction approved ...
|
78 |
+
//var_dump ($order);
|
79 |
|
80 |
+
$this->processOrder($order, $transactionId, $errorMessage);
|
81 |
|
|
|
|
|
82 |
$s = $order->getStatusLabel();
|
83 |
|
84 |
+
//var_dump ($s);
|
85 |
+
//echo " -==- =-=-= ";
|
86 |
+
//var_dump ($s);
|
87 |
+
//var_dump ($order);
|
|
|
|
|
88 |
|
89 |
$success = true;
|
90 |
|
91 |
$msg = "Payment successful.\n<br />TnxID: " . $transactionId . ".\n<br />TnxSess: " . $merchantSession;
|
92 |
+
|
93 |
|
94 |
return; // this
|
95 |
} else {
|
96 |
if ($order->getId()) {
|
97 |
$order->addStatusToHistory(
|
98 |
+
$order->getStatus(), //continue setting current order status
|
99 |
Mage_Sales_Model_Order::STATE_CANCELED, urldecode($errorMessage) . ' at PayStation', Mage::helper('paystation')->__($errorMessage . ' from PayStation')
|
100 |
);
|
101 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
|
102 |
$order->save();
|
103 |
|
104 |
+
//\echo "<hr>";
|
105 |
}
|
106 |
}
|
107 |
}
|
108 |
}
|
109 |
|
110 |
+
function processOrder($order, $transactionId, $errorMessage) {
|
111 |
//$s = "dsffsdsd";//$order->getStatusLabel();
|
|
|
112 |
// echo " ?? ??";
|
113 |
//var_dump ($s);
|
114 |
//echo "<hr>";
|
115 |
//
|
116 |
// echo "<pre>";
|
117 |
// var_dump($order);
|
118 |
+
echo "<hr>";
|
119 |
|
120 |
if ($order->getId()) {
|
121 |
+
if ($order->canInvoice())
|
122 |
+
$this->doInvoice($order);
|
123 |
+
else {
|
124 |
+
$amount = $order->getGrandTotal();
|
125 |
+
$order->addStatusToHistory(
|
126 |
+
$order->getStatus(), urldecode($errorMessage) . ' at Paystation', Mage::helper('paystation')->__($errorMessage . ' from Paystation')
|
127 |
+
);
|
128 |
+
$payment = $order->getPayment();
|
129 |
+
$payment->setTransactionId($transactionId)
|
130 |
+
->setIsTransactionClosed(0);
|
131 |
+
|
132 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true); //, Mage::helper('paystation')->__('PayStation payment successful.', true), $notified = true);
|
133 |
+
$order->save();
|
134 |
+
}
|
135 |
//var_dump ($order);
|
136 |
|
137 |
if (method_exists($payment, 'registerCaptureNotification')) {
|
139 |
$order->sendNewOrderEmail();
|
140 |
} else {
|
141 |
$newOrderStatus = $order->getStatus();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
$order->save();
|
144 |
}
|
145 |
}
|
146 |
|
147 |
+
function doInvoice($order) {
|
148 |
+
if (!$order->canInvoice()) {
|
149 |
+
|
150 |
+
// when order cannot create invoice, need to have some logic to take care
|
151 |
+
$order->addStatusToHistory(
|
152 |
+
$order->getStatus(), // keep order status/state
|
153 |
+
Mage::helper('paystation')->__('Error in creating an invoice', true), $notified = true
|
154 |
+
);
|
155 |
+
} else {
|
156 |
+
//exit( 'invoice creation');
|
157 |
+
// need to save transaction id
|
158 |
+
$order->getPayment()->setTransactionId($_GET['ti']);
|
159 |
+
|
160 |
+
// need to convert from order into invoice
|
161 |
+
$invoice = $order->prepareInvoice();
|
162 |
+
$invoice->register()->pay();
|
163 |
+
Mage::getModel('core/resource_transaction')
|
164 |
+
->addObject($invoice)
|
165 |
+
->addObject($invoice->getOrder())
|
166 |
+
->save();
|
167 |
+
|
168 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('paystation')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()), $notified = true);
|
169 |
+
$order->save();
|
170 |
+
$order->sendNewOrderEmail();
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
}
|
175 |
|
176 |
?>
|
app/code/local/Mage/Paystation/controllers/StandardController.php
CHANGED
@@ -1,342 +1,339 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
|
10 |
-
*
|
11 |
-
* @
|
12 |
-
* @
|
13 |
-
* @
|
14 |
-
|
15 |
-
|
16 |
-
{
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
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 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* PayStation Payment Module For Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* @package Mage_Paystation
|
12 |
+
* @author Gayatri S Ajith <gayatri@schogini.com>
|
13 |
+
* @copyright Copyright (c) 2010 Schogini (http://schogini.biz)
|
14 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
15 |
+
*/
|
16 |
+
class Mage_Paystation_StandardController extends Mage_Core_Controller_Front_Action {
|
17 |
+
|
18 |
+
protected $_order;
|
19 |
+
|
20 |
+
public function getOrder() {
|
21 |
+
if ($this->_order == null) {
|
22 |
+
|
23 |
+
}
|
24 |
+
return $this->_order;
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _expireAjax() {
|
28 |
+
if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
|
29 |
+
$this->getResponse()->setHeader('HTTP/1.1', '403 Session Expired');
|
30 |
+
exit;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getStandard() {
|
35 |
+
return Mage::getSingleton('paystation/standard');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* When a customer chooses Paystation on Checkout/Payment page
|
40 |
+
*
|
41 |
+
*/
|
42 |
+
public function redirectAction() {
|
43 |
+
|
44 |
+
$paystation = Mage::getSingleton('paystation/standard');
|
45 |
+
$paystation->payment_success = false;
|
46 |
+
|
47 |
+
$session = Mage::getSingleton('checkout/session');
|
48 |
+
$session->setPaystationStandardQuoteId($session->getQuoteId());
|
49 |
+
$_SESSION['quoteId'] = $session->getQuoteId();
|
50 |
+
$session->unsQuoteId();
|
51 |
+
|
52 |
+
header('location: ' . $_SESSION['redirectURL']);
|
53 |
+
}
|
54 |
+
|
55 |
+
public function notificationurlAction() {
|
56 |
+
$success = false;
|
57 |
+
$message = '';
|
58 |
+
$display_message = '';
|
59 |
+
|
60 |
+
$session = Mage::getSingleton('checkout/session');
|
61 |
+
$quote = $session->getQuote();
|
62 |
+
$quote_data = $quote->$_data;
|
63 |
+
$is_multi_shipping = $quote_data ['is_multi_shipping'];
|
64 |
+
|
65 |
+
$confirm = -1;
|
66 |
+
$success = false;
|
67 |
+
$QL_amount = '';
|
68 |
+
$QL_EC = -1;
|
69 |
+
|
70 |
+
if (isset($_SESSION['paystation_id'])) {
|
71 |
+
$confirm = $this->transactionVerification($_SESSION['paystation_id'], $_GET['ti'], $QL_amount, $QL_merchant_session, $QL_EC);
|
72 |
+
//mail ('jack@face.co.nz', 'QL_amount:'.(int)$QL_amount. ' QL_merchant_session: '.$QL_merchant_session. ' ec: '.$confirm, '');
|
73 |
+
}
|
74 |
+
|
75 |
+
if (!isset($_GET['em'])) {
|
76 |
+
$_SESSION['paystation_success'] = false;
|
77 |
+
$success = false;
|
78 |
+
$display_message = "Sorry, we couldn't find the payment information.\nTransaction ID: " . ((isset($_GET['ti'])) ? $_GET['ti'] : 'Not defined') . "\nError Code: " . ((isset($_GET['ec'])) ? $_GET['ec'] : 'Not defined');
|
79 |
+
$message = "Payment information was not included with return URL." .
|
80 |
+
"\n<br />TnxID: " . ((isset($_GET['ti'])) ? $_GET['ti'] : 'Not defined') .
|
81 |
+
"\n<br />ErrCode: " . ((isset($_GET['ec'])) ? $_GET['ec'] : 'Not defined') .
|
82 |
+
"\n<br />TnxSess: " . ((isset($_GET['ms'])) ? $_GET['ms'] : 'Not defined') .
|
83 |
+
"\n<br />Amount: " . ((isset($_GET['am'])) ? $_GET['am'] : 'Not defined');
|
84 |
+
} elseif ($_GET['ec'] == "0" && (int) $confirm == 0 && $QL_amount == $_GET['am'] && $_SESSION['paystation_ms'] == $QL_merchant_session) {
|
85 |
+
// transaction approved ...
|
86 |
+
|
87 |
+
|
88 |
+
$success = true;
|
89 |
+
$_SESSION['paystation_success'] = true;
|
90 |
+
$msg = "Payment successful.\n<br />TnxID: " . ((isset($_GET['ti'])) ? $_GET['ti'] : 'Not defined') . ".\n<br />TnxSess: " . ((isset($_GET['ms'])) ? $_GET['ms'] : 'Not defined');
|
91 |
+
|
92 |
+
$session = Mage::getSingleton('checkout/session');
|
93 |
+
|
94 |
+
//get the order number from the merchant reference
|
95 |
+
$merchant_ref = $_GET['merchant_ref'];
|
96 |
+
$xpl = explode('-', $merchant_ref);
|
97 |
+
$_SESSION['paystation_cust_email'] = $xpl[1];
|
98 |
+
|
99 |
+
$orderid = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
100 |
+
|
101 |
+
if ($orderid == NULL) {
|
102 |
+
$xpl = explode(':', $merchant_ref);
|
103 |
+
$customer_email = $xpl[0];
|
104 |
+
$orderid = $xpl[1];
|
105 |
+
$testmode = Mage::getStoreConfig('payment/paystation_standard/testmode', Mage::app()->getStore());
|
106 |
+
|
107 |
+
if ($orderid == "test-mode" && $testmode == "1") {
|
108 |
+
$orderid = $xpl[2];
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderid);
|
113 |
+
|
114 |
+
if ($_SESSION['paystation_multishipping'] == true) {
|
115 |
+
|
116 |
+
$this->_redirect('checkout/multishipping/success');
|
117 |
+
} else {
|
118 |
+
$postback = Mage::getStoreConfig('payment/paystation_standard/postback', Mage::app()->getStore());
|
119 |
+
|
120 |
+
if ($order && $postback == "0") {
|
121 |
+
$this->processOrder($order);
|
122 |
+
}
|
123 |
+
$this->_redirect('checkout/onepage/success');
|
124 |
+
}
|
125 |
+
return; // this return has not particular use - just to ensure that after redirect it doesn't do anything
|
126 |
+
} else {
|
127 |
+
// transaction failed
|
128 |
+
$success = false;
|
129 |
+
$display_message = $_GET['em'] . ".\nTransaction ID: " . ((isset($_GET['ti'])) ? $_GET['ti'] : 'Not defined') . "\nError Code: " . ((isset($_GET['ec'])) ? $_GET['ec'] : 'Not defined');
|
130 |
+
|
131 |
+
$message = "Paystation payment unsucessful. Message from gateway: " . $_GET['em'] .
|
132 |
+
"\n<br />TnxID: " . ((isset($_GET['ti'])) ? $_GET['ti'] : 'Not defined') .
|
133 |
+
"\n<br />ErrCode: " . ((isset($_GET['ec'])) ? $_GET['ec'] : 'Not defined') .
|
134 |
+
"\n<br />TnxSess: " . ((isset($_GET['ms'])) ? $_GET['ms'] : 'Not defined') .
|
135 |
+
"\n<br />Amount: " . ((isset($_GET['am'])) ? $_GET['am'] : 'Not defined');
|
136 |
+
}
|
137 |
+
|
138 |
+
if (!$success) {
|
139 |
+
if ($is_multi_shipping == true) {
|
140 |
+
|
141 |
+
$_SESSION['paystation_success'] = false;
|
142 |
+
$_SESSION['paystation_error_message'] = $display_message;
|
143 |
+
$this->_redirect('checkout/multishipping/success');
|
144 |
+
} elseif ($is_multi_shipping == false)
|
145 |
+
$this->paymentError($message, $display_message);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
function paymentError($msg, $display_message = '') {
|
150 |
+
// if a display message has not been set then, use the order message
|
151 |
+
if (empty($display_message))
|
152 |
+
$display_message = $msg;
|
153 |
+
|
154 |
+
// cancel order
|
155 |
+
$session = Mage::getSingleton('checkout/session');
|
156 |
+
$session->setQuoteId($session->getPaystationStandardQuoteId(true));
|
157 |
+
Mage::getModel('sales/quote')->load($session->getQuoteId())->setIsActive(true)->save();
|
158 |
+
|
159 |
+
|
160 |
+
$postback = Mage::getStoreConfig('payment/paystation_standard/postback', Mage::app()->getStore());
|
161 |
+
|
162 |
+
if ($session->getLastRealOrderId() && $postback == "0") {
|
163 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
164 |
+
if ($order->getId()) {
|
165 |
+
$order->addStatusToHistory(
|
166 |
+
//$order->getStatus(),//continue setting current order status
|
167 |
+
Mage_Sales_Model_Order::STATE_CANCELED, urldecode($msg) . ' at PayStation', Mage::helper('paystation')->__($msg . ' from PayStation')
|
168 |
+
);
|
169 |
+
$order->save();
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
$display_message = 'Paystation payment unsuccessful. Reason: ' . "\n" . $display_message;
|
174 |
+
$session->addError(nl2br($display_message));
|
175 |
+
|
176 |
+
$this->_redirect('checkout/onepage/failure');
|
177 |
+
}
|
178 |
+
|
179 |
+
public function transactionVerification($paystationID, $transactionID, &$QL_amount, &$QL_merchant_session, &$QL_EC) {
|
180 |
+
|
181 |
+
$transactionVerified = '';
|
182 |
+
$lookupXML = $this->quickLookup($paystationID, 'ti', $transactionID);
|
183 |
+
//$lookupXML=quickLookup($paystationID,'ms',$merchantSession);
|
184 |
+
$p = xml_parser_create();
|
185 |
+
xml_parse_into_struct($p, $lookupXML, $vals, $tags);
|
186 |
+
xml_parser_free($p);
|
187 |
+
//ob_start();
|
188 |
+
///echo "\r\n";
|
189 |
+
for ($i = 0; $i < count($vals); $i++) {
|
190 |
+
|
191 |
+
$key = $vals[$i];
|
192 |
+
$key = $key['tag'];
|
193 |
+
$val = $i;
|
194 |
+
//var_dump ($key);
|
195 |
+
if ($key == "PAYSTATIONERRORCODE") {
|
196 |
+
$transactionVerified = (int) $vals[$val]['value'];
|
197 |
+
$QL_EC = (int) $transactionVerified;
|
198 |
+
//echo "QL_EC: "; var_dump ($QL_EC);
|
199 |
+
} elseif ($key == "PURCHASEAMOUNT") { //19
|
200 |
+
$QL_amount = $vals[$val];
|
201 |
+
$QL_amount = $QL_amount ['value'];
|
202 |
+
} elseif ($key == "MERCHANTSESSION") { //15
|
203 |
+
$QL_merchant_session = $vals[$val]['value'];
|
204 |
+
} else {
|
205 |
+
continue;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
return $transactionVerified;
|
210 |
+
}
|
211 |
+
|
212 |
+
public function quickLookup($pi, $type, $value) {
|
213 |
+
/*
|
214 |
+
https://www.paystation.co.nz/lookup/quick/?pi=850047&ms=123
|
215 |
+
- or –
|
216 |
+
https://www.paystation.co.nz/lookup/quick/?pi=850047&ti=0000585260-01
|
217 |
+
*/
|
218 |
+
|
219 |
+
$url = "https://payments.paystation.co.nz/lookup/"; //
|
220 |
+
$params = "&pi=$pi&$type=$value";
|
221 |
+
|
222 |
+
$authenticationKey = Mage::getStoreConfig('payment/paystation_standard/hmac_key', Mage::app()->getStore());
|
223 |
+
$hmacWebserviceName = 'paystation';
|
224 |
+
$pstn_HMACTimestamp = time();
|
225 |
+
|
226 |
+
$hmacBody = pack('a*', $pstn_HMACTimestamp) . pack('a*', $hmacWebserviceName) . pack('a*', $params);
|
227 |
+
$hmacHash = hash_hmac('sha512', $hmacBody, $authenticationKey);
|
228 |
+
$hmacGetParams = '?pstn_HMACTimestamp=' . $pstn_HMACTimestamp . '&pstn_HMAC=' . $hmacHash;
|
229 |
+
|
230 |
+
$url.= $hmacGetParams;
|
231 |
+
$defined_vars = get_defined_vars();
|
232 |
+
//use curl to get reponse
|
233 |
+
$ch = curl_init();
|
234 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
235 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
236 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
237 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
238 |
+
curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']);
|
239 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
240 |
+
$result = curl_exec($ch);
|
241 |
+
curl_close($ch);
|
242 |
+
|
243 |
+
|
244 |
+
|
245 |
+
$h = htmlspecialchars($result);
|
246 |
+
|
247 |
+
return $result;
|
248 |
+
}
|
249 |
+
|
250 |
+
function parseCode($mvalues) {
|
251 |
+
$result = '';
|
252 |
+
for ($i = 0; $i < count($mvalues); $i++) {
|
253 |
+
if (!strcmp($mvalues[$i]["tag"], "QSIRESPONSECODE") && isset($mvalues[$i]["value"])) {
|
254 |
+
$result = $mvalues[$i]["value"];
|
255 |
+
}
|
256 |
+
}
|
257 |
+
return $result;
|
258 |
+
}
|
259 |
+
|
260 |
+
function processOrder($order) {
|
261 |
+
$message = "";
|
262 |
+
if ($order->getId()) {
|
263 |
+
$message .= "got order id ...";
|
264 |
+
|
265 |
+
$amount = $order->getGrandTotal();
|
266 |
+
$order->addStatusToHistory(
|
267 |
+
$order->getStatus(), urldecode($msg) . ' at Paystation', Mage::helper('paystation')->__($msg . ' from Paystation')
|
268 |
+
);
|
269 |
+
$payment = $order->getPayment();
|
270 |
+
$payment->setTransactionId($_GET['ti'])
|
271 |
+
->setIsTransactionClosed(0);
|
272 |
+
|
273 |
+
$order->setState(
|
274 |
+
Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Paystation payment successful.');
|
275 |
+
|
276 |
+
|
277 |
+
$st = $order->getStatus();
|
278 |
+
|
279 |
+
|
280 |
+
if (method_exists($payment, 'registerCaptureNotification')) {
|
281 |
+
$message .= "has registerCaptureNotification ...";
|
282 |
+
if ($order->canInvoice()) {
|
283 |
+
$message .= "canInvoice() ...";
|
284 |
+
$this->doInvoice($order);
|
285 |
+
$order->sendNewOrderEmail();
|
286 |
+
}
|
287 |
+
|
288 |
+
else {
|
289 |
+
$message .= " cannot Invoice ...";
|
290 |
+
$payment->registerCaptureNotification($amount);
|
291 |
+
$order->sendNewOrderEmail();
|
292 |
+
|
293 |
+
$order->setState(
|
294 |
+
Mage_Sales_Model_Order::STATE_PROCESSING, true, 'PayStation payment successful.', true);
|
295 |
+
$order->save();
|
296 |
+
}
|
297 |
+
} else {
|
298 |
+
$message .= " not have registerCaptureNotification ...";
|
299 |
+
$newOrderStatus = $order->getStatus();
|
300 |
+
$this->doInvoice($order);
|
301 |
+
}
|
302 |
+
$order->save();
|
303 |
+
mail ('jack@face.co.nz', 'order process', $message );
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
function doInvoice($order) {
|
308 |
+
if (!$order->canInvoice()) {
|
309 |
+
|
310 |
+
// when order cannot create invoice, need to have some logic to take care
|
311 |
+
$order->addStatusToHistory(
|
312 |
+
$order->getStatus(), // keep order status/state
|
313 |
+
Mage::helper('paystation')->__('Error in creating an invoice', true), $notified = true
|
314 |
+
);
|
315 |
+
} else {
|
316 |
+
//exit( 'invoice creation');
|
317 |
+
|
318 |
+
// need to save transaction id
|
319 |
+
$order->getPayment()->setTransactionId($_GET['ti']);
|
320 |
+
|
321 |
+
// need to convert from order into invoice
|
322 |
+
$invoice = $order->prepareInvoice();
|
323 |
+
$invoice->register()->pay();
|
324 |
+
Mage::getModel('core/resource_transaction')
|
325 |
+
->addObject($invoice)
|
326 |
+
->addObject($invoice->getOrder())
|
327 |
+
->save();
|
328 |
+
|
329 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('paystation')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()), $notified = true);
|
330 |
+
$order->save();
|
331 |
+
$order->sendNewOrderEmail();
|
332 |
+
}
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
|
337 |
+
}
|
338 |
+
|
339 |
+
?>
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,18 +1,26 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Paystation_Magento_1_8_ModuleV5</name>
|
4 |
-
<version>0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Paystation
|
10 |
-
<description>Paystation
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<authors><author><name>Paystation</name><user>Paystation</user><email>info@paystation.co.nz</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir><dir name="Mage"><dir name="Paystation"><dir name="Block"><dir name="Standard"><file name="Form.php" hash="29304def98cb1949740c2a6d8edba9e0"/></dir></dir><dir name="Helper"><file name="Data.php" hash="37cfb5767197bb15b7c02f05b303a999"/></dir><dir name="Model"><file name="Abstract.php" hash="274b033bb3bc1bfe8f540114f810960e"/><file name="Session.php" hash="f677d1b5e6e2104536e4189eb563681a"/><dir name="Source"><file name="Cctype.php" hash="8ad4533997e40260a159a0014f5cf713"/><file name="PaymentAction.php" hash="920c20b2fe48b3cdce1cbcccdf3ec516"/><file name="Processing.php" hash="b66b423e58438e041ae5cddea19e2254"/><file name="StandardAction.php" hash="a324886c922616e3e640bf6cb0f20901"/></dir><file name="Standard.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.6</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Paystation_Magento_1_8_ModuleV5</name>
|
4 |
+
<version>0.0.13</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Paystation One-page Checkout with Post Back</summary>
|
10 |
+
<description>The Paystation 3-Party One-Page Checkout Module with Post Back for Magento 1.8 is free to download. For more information on Paystation please visit www.paystation.co.nz.
|
11 |
+

|
12 |
+
This module utilizes the Paystation Quick Look-up tool for transaction validation and Post Back tool for receiving transaction responses even if the customer re-direct is interrupted (optional).
|
13 |
+

|
14 |
+
If you are installing this module it is CRUCIAL that you follow all of the install instructions. The instructions can be found in the Release Notes tab above.
|
15 |
+

|
16 |
+
To request a free development account for integration testing please email info@paystation.co.nz.
|
17 |
+

|
18 |
+
Paystation is your ideal payments solution provider whether you are just starting out in eCommerce or are already well established and looking to leverage your existing technology for smarter payments.</description>
|
19 |
+
<notes>Minor bug fixes</notes>
|
20 |
<authors><author><name>Paystation</name><user>Paystation</user><email>info@paystation.co.nz</email></author></authors>
|
21 |
+
<date>2015-01-06</date>
|
22 |
+
<time>22:31:42</time>
|
23 |
+
<contents><target name="magelocal"><dir><dir name="Mage"><dir name="Paystation"><dir name="Block"><dir name="Standard"><file name="Form.php" hash="29304def98cb1949740c2a6d8edba9e0"/></dir></dir><dir name="Helper"><file name="Data.php" hash="37cfb5767197bb15b7c02f05b303a999"/></dir><dir name="Model"><file name="Abstract.php" hash="274b033bb3bc1bfe8f540114f810960e"/><file name="Session.php" hash="f677d1b5e6e2104536e4189eb563681a"/><dir name="Source"><file name="Cctype.php" hash="8ad4533997e40260a159a0014f5cf713"/><file name="PaymentAction.php" hash="920c20b2fe48b3cdce1cbcccdf3ec516"/><file name="Processing.php" hash="b66b423e58438e041ae5cddea19e2254"/><file name="StandardAction.php" hash="a324886c922616e3e640bf6cb0f20901"/></dir><file name="Standard.php" hash="507dad0df484b0b0df9ce90d55520054"/></dir><dir name="controllers"><file name="PostbackController.php" hash="f2e6b84825d2eeb042ba4ceab95c9b87"/><file name="StandardController.php" hash="4cd17a7059725727ca9eafc8f1f6f726"/></dir><dir name="etc"><file name="config.xml" hash="2d9b8ff62b677f80cc388b433c2de0ea"/><file name="system.xml" hash="1be2030b37f504cca10b64e6682e7eb3"/></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Mage_Paystation.xml" hash="dcfb6c0fa8c356597482c51671e8c726"/></dir></dir></target></contents>
|
24 |
<compatible/>
|
25 |
<dependencies><required><php><min>5.2.6</min><max>6.0.0</max></php></required></dependencies>
|
26 |
</package>
|