PaysonCheckout2 - Version 1.0.0.1

Version Notes

New modul paysonCheckout2

Download this release

Release Info

Developer Oscar Villegas
Extension PaysonCheckout2
Version 1.0.0.1
Comparing to
See all releases


Code changes from version 1.0.0.0 to 1.0.0.1

Files changed (29) hide show
  1. app/code/community/Payson/Payson/Block/Form.php +0 -11
  2. app/code/community/Payson/Payson/Block/Invoice/Form.php +0 -11
  3. app/code/community/Payson/Payson/Block/Order/Totals/Fee.php +0 -22
  4. app/code/community/Payson/Payson/Block/Standard/Form.php +0 -11
  5. app/code/community/Payson/Payson/Helper/Api.php +0 -1328
  6. app/code/community/Payson/Payson/Helper/Api/Response/Interface.php +0 -20
  7. app/code/community/Payson/Payson/Helper/Api/Response/Standard.php +0 -131
  8. app/code/community/Payson/Payson/Helper/Api/Response/Standard/Parameters.php +0 -66
  9. app/code/community/Payson/Payson/Helper/Api/Response/Validate.php +0 -46
  10. app/code/community/Payson/Payson/Helper/Data.php +0 -6
  11. app/code/community/Payson/Payson/Helper/FundingConstraint.php +0 -36
  12. app/code/community/Payson/Payson/Model/Config.php +0 -218
  13. app/code/community/Payson/Payson/Model/Method/Abstract.php +0 -148
  14. app/code/community/Payson/Payson/Model/Method/Invoice.php +0 -65
  15. app/code/community/Payson/Payson/Model/Method/Standard.php +0 -80
  16. app/code/community/Payson/Payson/Model/Mysql4/Setup.php +0 -6
  17. app/code/community/Payson/Payson/Model/Order/Creditmemo/Total/Invoice.php +0 -41
  18. app/code/community/Payson/Payson/Model/Order/Invoice/Total/Invoice.php +0 -42
  19. app/code/community/Payson/Payson/Model/Quote/Address/Total/Invoice.php +0 -44
  20. app/code/community/Payson/Payson/Model/Standard.php +0 -108
  21. app/code/community/Payson/Payson/Model/System/Config/Source/Paysondirectmethod.php +0 -52
  22. app/code/community/Payson/Payson/controllers/Adminhtml/Sales/Order/ShipmentController.php +0 -23
  23. app/code/community/Payson/Payson/controllers/CheckoutController.php +0 -238
  24. app/code/community/Payson/Payson/controllers/IpnController.php +0 -25
  25. app/code/community/Payson/Payson/etc/config.xml +0 -167
  26. app/code/community/Payson/Payson/etc/system.xml +0 -166
  27. app/code/community/Payson/Payson/sql/payson_setup/mysql4-install-0.1.0.php +0 -32
  28. app/code/community/Payson/Payson/sql/payson_setup/mysql4-upgrade-0.1.0-0.1.2.php +0 -8
  29. package.xml +12 -8
app/code/community/Payson/Payson/Block/Form.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Block_Form extends Mage_Payment_Block_Form {
4
-
5
- protected function _construct() {
6
- $this->setTemplate('Payson/Payson/form.phtml');
7
- parent::_construct();
8
- }
9
-
10
- }
11
-
app/code/community/Payson/Payson/Block/Invoice/Form.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Block_Invoice_Form extends Mage_Payment_Block_Form {
4
-
5
- protected function _construct() {
6
- $this->setTemplate('Payson/Payson/standard_form.phtml');
7
- parent::_construct();
8
- }
9
-
10
- }
11
-
app/code/community/Payson/Payson/Block/Order/Totals/Fee.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Block_Order_Totals_Fee extends Mage_Core_Block_Abstract {
4
-
5
- public function initTotals() {
6
- $parent = $this->getParentBlock();
7
- $this->_order = $parent->getOrder();
8
-
9
- if ($this->_order->getPayment()->getMethod() === 'payson_invoice') {
10
- $parent->addTotalBefore(new Varien_Object(array
11
- (
12
- 'code' => 'payson_invoice',
13
- 'label' => Mage::helper('payson')->__('Invoice fee'),
14
- 'value' => $this->_order->getPaysonInvoiceFee()
15
- )), 'tax');
16
- }
17
-
18
- return $this;
19
- }
20
-
21
- }
22
-
app/code/community/Payson/Payson/Block/Standard/Form.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Block_Standard_Form extends Mage_Payment_Block_Form {
4
-
5
- protected function _construct() {
6
- $this->setTemplate('Payson/Payson/standard_form.phtml');
7
- parent::_construct();
8
- }
9
-
10
- }
11
-
app/code/community/Payson/Payson/Helper/Api.php DELETED
@@ -1,1328 +0,0 @@
1
- <?php
2
-
3
- include 'FundingConstraint.php';
4
-
5
- class Payson_Payson_Helper_Api {
6
- /*
7
- * Constants
8
- */
9
-
10
- var $invoiceAmountMinLimit = 30;
11
-
12
- const DEBUG_MODE = false;
13
- const API_CALL_PAY = '%s://%sapi.payson.%s/%s/Pay/';
14
- const API_CALL_VALIDATE = '%s://%sapi.payson.%s/%s/Validate/';
15
- const API_CALL_PAYMENT_DETAILS = '%s://%sapi.payson.%s/%s/%sDetails/';
16
- const API_CALL_PAYMENT_UPDATE = '%s://%sapi.payson.%s/%s/%sUpdate/';
17
- const PAY_FORWARD_URL = '%s://%s%s.payson.%s/paySecure/';
18
- const APPLICATION_ID = 'Magento';
19
- const MODULE_NAME = 'Payson_AllinOne';
20
- const MODULE_VERSION = '1.8.3.3';
21
- const DEBUG_MODE_MAIL = 'testagent-checkout2@payson.se';
22
- const DEBUG_MODE_AGENT_ID = '4';
23
- const DEBUG_MODE_MD5 = '2acab30d-fe50-426f-90d7-8c60a7eb31d4';
24
- const STATUS_CREATED = 'CREATED';
25
- const STATUS_PENDING = 'PENDING';
26
- const STATUS_PROCESSING = 'PROCESSING';
27
- const STATUS_COMPLETED = 'COMPLETED';
28
- const STATUS_CREDITED = 'CREDITED';
29
- const STATUS_INCOMPLETE = 'INCOMPLETE';
30
- const STATUS_ERROR = 'ERROR';
31
- const STATUS_DENIED = 'DENIED';
32
- const STATUS_ABORTED = 'ABORTED';
33
- const STATUS_CANCELED = 'CANCELED';
34
- const STATUS_EXPIRED = 'EXPIRED';
35
- const STATUS_REVERSALERROR = 'REVERSALERROR';
36
- const PAYMENT_METHOD_BANK = 'BANK';
37
- const PAYMENT_METHOD_CREDITCARD = 'CREDITCARD';
38
- const PAYMENT_METHOD_INVOICE = 'INVOICE';
39
- const PAYMENT_METHOD_SMS = 'SMS';
40
- const GUARANTEE_STATUS_WAITINGFORSEND = 'WAITINGFORSEND';
41
- const GUARANTEE_STATUS_WAITINGFORACCEPTANCE = 'WAITINGFORACCEPTANCE';
42
- const GUARANTEE_STATUS_WAITINGFORRETURN = 'WAITINGFORRETURN';
43
- const GUARANTEE_STATUS_WAITINGFORRETURNACCEPTANCE = 'WAITINGFORRETURNACCEPTANCE';
44
- const GUARANTEE_STATUS_RETURNNOTACCEPTED = 'RETURNNOTACCEPTED';
45
- const GUARANTEE_STATUS_NOTRECEIVED = 'NOTRECEIVED';
46
- const GUARANTEE_STATUS_RETURNNOTRECEIVED = 'RETURNNOTRECEIVED';
47
- const GUARANTEE_STATUS_MONEYRETURNEDTOSENDER = 'MONEYRETURNEDTOSENDER';
48
- const GUARANTEE_STATUS_RETURNACCEPTED = 'RETURNACCEPTED';
49
- const INVOICE_STATUS_PENDING = 'PENDING';
50
- const INVOICE_STATUS_ORDERCREATED = 'ORDERCREATED';
51
- const INVOICE_STATUS_ORDERCANCELLED = 'ORDERCANCELLED';
52
- const INVOICE_STATUS_SHIPPED = 'SHIPPED';
53
- const INVOICE_STATUS_DONE = 'DONE';
54
- const UPDATE_ACTION_CANCELORDER = 'CANCELORDER';
55
- const UPDATE_ACTION_SHIPORDER = 'SHIPORDER';
56
- const UPDATE_ACTION_CREDITORDER = 'CREDITORDER';
57
- const UPDATE_ACTION_REFUNDORDER = 'REFUND';
58
- const GUARANTEE_REQUIRED = 'REQUIRED';
59
- const GUARANTEE_OPTIONAL = 'OPTIONAL';
60
- const GUARANTEE_NO = 'NO';
61
-
62
- //const PMETHOD ='';
63
-
64
- /*
65
- * Private properties
66
- */
67
- private $discountType;
68
- private $numberofItems;
69
- private $discountVat = 0.0;
70
- private $_order = null;
71
- private $response;
72
- private $order_discount_item = 0.0;
73
- /* @var $_config Payson_Payson_Model_Config */
74
- private $_config;
75
- /* @var $_helper Payson_Payson_Helper_Data */
76
- private $_helper;
77
- private $_products = array();
78
-
79
- /*
80
- * Private methods
81
- */
82
-
83
- public function __construct() {
84
- $this->_config = Mage::getModel('payson/config');
85
- $this->_helper = Mage::helper('payson');
86
- $this->_invoice = Mage::getModel('payson/method/invoice');
87
- }
88
-
89
- private function getHttpClient($url) {
90
-
91
- $client = new Varien_Http_Client();
92
-
93
- $client->setUri($url)
94
- ->setMethod(Zend_Http_Client::POST)
95
- ->setHeaders(array
96
- (
97
- 'PAYSON-SECURITY-USERID' => $this->_config->get('test_mode') ? self::DEBUG_MODE_AGENT_ID : $this->_config->Get('agent_id'),
98
- 'PAYSON-SECURITY-PASSWORD' => $this->_config->get('test_mode') ? self::DEBUG_MODE_MD5 : $this->_config->Get('md5_key'),
99
- 'PAYSON-APPLICATION-ID' => self::APPLICATION_ID,
100
- 'PAYSON-MODULE-INFO' => self::MODULE_NAME . '|' . self::MODULE_VERSION . '|' . Mage::getVersion()
101
- )
102
- );
103
-
104
- return $client->resetParameters();
105
- }
106
-
107
- private function setResponse(
108
- Payson_Payson_Helper_Api_Response_Interface $response) {
109
- $this->response = $response;
110
-
111
- return $this;
112
- }
113
-
114
- //Private functions for Swedish discount and vat calculations
115
- private function setAverageVat($vat) {
116
- $this->discountVat = $vat;
117
- }
118
-
119
- private function getAverageVat() {
120
- return $this->discountVat;
121
- }
122
-
123
- private function setDiscountType($type) {
124
- $this->discountType = $type;
125
- }
126
-
127
- private function getDiscountType() {
128
- return $this->discountType;
129
- }
130
-
131
- private function setNumberOfItems($items) {
132
- $this->numberofItems = $items;
133
- }
134
-
135
- private function getNumberOfItems() {
136
- return $this->numberofItems;
137
- }
138
-
139
- private function getStoreCountry() {
140
- $countryCode = Mage::getStoreConfig('general/country/default');
141
- $country = Mage::getModel('directory/country')->loadByCode($countryCode);
142
- return $country->country_id;
143
- }
144
-
145
- private function setSwedishDiscountItem($item, &$total, $orderitems, $order) {
146
-
147
- /*
148
- * Discount types $item->getAppliedRuleIds():
149
- * Fixed discount amount for the entire cart
150
- * Precentage discount for the entire cart
151
- * Fixed discount amount for each article in cart
152
- */
153
- $rule = Mage::getModel('salesrule/rule')->load($item->getAppliedRuleIds());
154
- $total -= $item->getDiscountAmount();
155
- $numberOfItem = floor($order->getData('total_qty_ordered'));
156
- $items = 0;
157
-
158
- $discountAmount = $item->getDiscountAmount();
159
- for ($i = 0; $i <= $numberOfItem; $i++) {
160
- $orderVat = $orderitems['orderItemList.orderItem(' . $i . ').taxPercentage'];
161
- $moms += $orderVat;
162
- //counting number of tax rows that is not zero
163
- if ($orderVat != 0) {
164
- $items++;
165
- }
166
- }
167
- $this->setNumberOfItems($numberOfItem);
168
- $this->setDiscountType($rule->simple_action);
169
- $totalMoms = $moms / $items;
170
-
171
- $this->setAverageVat($totalMoms);
172
-
173
- $this->order_discount_item += $discountAmount;
174
- }
175
-
176
- private function setInternationalDiscountItem($item, &$total) {
177
- $total -= $item->getDiscountAmount();
178
- $this->order_discount_item += $item->getDiscountAmount();
179
- }
180
-
181
- /**
182
- * Helper for Pay()
183
- *
184
- * @param Mage_Sales_Model_Order_Item $item
185
- * @param int $total
186
- * @return array
187
- */
188
- private function getProductOptions($id) {
189
- $product = new Mage_Catalog_Model_Product();
190
- $product->load($id);
191
- $product->getTypeInstance(true)->setStoreFilter(Mage::app()->getStore(), $product);
192
- return $product;
193
-
194
- }
195
- private function prepareOrderItemData($item, &$total, $order) {
196
- /* @var $product Mage_Catalog_Model_Product */
197
- $product = Mage::getModel('catalog/product')
198
- ->load($item->getProductId());
199
-
200
- $attributesString = "";
201
- $quoteItems = Mage::getModel('sales/quote_item')->getCollection();
202
- $quoteItems->addFieldToFilter('quote_id', $order->quote_id);
203
- $quoteItems->addFieldToFilter('product_type', 'bundle');
204
-
205
-
206
- if (($children = $item->getChildrenItems()) != null && !$product->isConfigurable()) {
207
- $args = array();
208
- $product = $this->getProductOptions($item->getProductId());
209
-
210
- if ($item->getProductType() != 'bundle'||$product->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
211
- $this->prepareProductData($item->getName(), $item->getSku(), $item->getQtyOrdered(), 0, 0);
212
- }
213
- foreach ($children as $child) {
214
- $this->prepareOrderItemData($child, $total, $order);
215
- }
216
- //checks if there are bundles items is present and if it is dynamic
217
- if (($quoteItems->getSize() < 1)) {
218
- return;
219
- } elseif ($product->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC && $item->getProductType() == 'bundle') {
220
- return;
221
- }
222
- }
223
-
224
- $productOptions = $item->getProductOptions();
225
-
226
- if (array_key_exists('attributes_info', $productOptions)) {
227
- foreach ($productOptions['attributes_info'] as $attribute) {
228
- $attributesString .= $attribute['label'] . ": " . $attribute['value'] . ", ";
229
- }
230
-
231
- if ($attributesString != "") {
232
- $attributesString = substr($attributesString, 0, strlen($attributesString) - 2);
233
- }
234
- }
235
-
236
- $name = $item->getName() . ($attributesString != "" ? " - " . $attributesString : "");
237
- $sku = $item->getSku();
238
- $tax_mod = (float) $item->getTaxPercent();
239
- $tax_mod /= 100;
240
- $tax_mod = round($tax_mod, 5);
241
-
242
- $qty = (float) $item->getQtyOrdered();
243
- $qty = round($qty, 2);
244
-
245
- $price = (float) $item->getRowTotalInclTax();
246
-
247
- $base_price = (($price / (1 + $tax_mod)) / $qty);
248
- $base_price = round($base_price, 3);
249
-
250
- $total += (($base_price * (1 + $tax_mod)) * $qty);
251
-
252
- $this->prepareProductData($name, $sku, $qty, $base_price, $tax_mod);
253
- }
254
-
255
- private function generateProductDataForPayson(array $args) {
256
- $productData = array();
257
- for ($i = 0; $i < sizeof($this->_products); $i++) {
258
- $productData += array
259
- (
260
- 'orderItemList.orderItem(' . $i . ').description' =>
261
- $this->_products[$i]['Description'],
262
- 'orderItemList.orderItem(' . $i . ').sku' =>
263
- $this->_products[$i]['Sku'],
264
- 'orderItemList.orderItem(' . $i . ').quantity' =>
265
- $this->_products[$i]['Quantity'],
266
- 'orderItemList.orderItem(' . $i . ').unitPrice' =>
267
- $this->_products[$i]['Price'],
268
- 'orderItemList.orderItem(' . $i . ').taxPercentage' =>
269
- $this->_products[$i]['Tax']
270
- );
271
- $args += $productData;
272
- }
273
-
274
- return $args;
275
- }
276
-
277
- private function prepareProductData($description, $sku, $qty, $base_price, $tax_mod) {
278
- $description = strlen($description) <= 128 ? $description : substr($description, 128);
279
- $sku = strlen($sku) <= 128 ? $sku : substr($sku, 128);
280
- $this->_products[] = array("Description" => $description, "Sku" => $sku,
281
- "Quantity" => $qty, "Price" => $base_price, "Tax" => $tax_mod);
282
- }
283
-
284
- /**
285
- * Helper for Pay()
286
- *
287
- * @param object $order
288
- * @param object $customer
289
- * @param object $store
290
- * @param int $i
291
- * @param int $total
292
- */
293
- private function prepareOrderShippingData($order, $customer, $store, &$total) {
294
- $tax_calc = Mage::getSingleton('tax/calculation');
295
-
296
- $tax_rate_req = $tax_calc->getRateRequest(
297
- $order->getShippingAddress(), $order->getBillingAddress(), $customer->getTaxClassId(), $store);
298
-
299
- if (($price = (float) $order->getShippingInclTax()) > 0) {
300
- $tax_mod = $tax_calc->getRate($tax_rate_req->setProductClassId(
301
- Mage::getStoreConfig('tax/classes/shipping_tax_class')));
302
- $tax_mod /= 100;
303
- $tax_mod = round($tax_mod, 5);
304
-
305
- $price -= (float) $order->getShippingDiscountAmount();
306
-
307
- $base_price = ($price / (1 + $tax_mod));
308
- $base_price = round($base_price, 3);
309
-
310
- $total += ($base_price * (1 + $tax_mod));
311
-
312
- $this->prepareProductData($order->getShippingDescription(), $order->getShippingMethod(), 1, $base_price, $tax_mod);
313
- }
314
- }
315
-
316
- /*
317
- * Public methods
318
- */
319
-
320
- /**
321
- * Get API response
322
- *
323
- * @return object
324
- */
325
- public function GetResponse() {
326
- return $this->response;
327
- }
328
-
329
- /**
330
- * Get forward/redirect url after a successful Pay() call
331
- *
332
- * @return string
333
- */
334
- public function GetPayForwardUrl() {
335
- $url = vsprintf(self::PAY_FORWARD_URL . '?token=' . $this->GetResponse()->TOKEN, $this->getFormatIfTest(null, true));
336
- return $url;
337
- }
338
-
339
- /**
340
- * http://api.payson.se/#title8
341
- *
342
- * @param object $order
343
- * @return object
344
- */
345
- public function showReceiptPage() {
346
- $Config = (int) $this->_config->get('show_receipt_page');
347
- $reciept2 = 'false';
348
- if ($Config === 1) {
349
- $reciept2 = 'true';
350
- }
351
- return $reciept2;
352
- }
353
-
354
- public function vatDiscount() {
355
- $inputValue = (int) $this->_config->Get('vat_discount');
356
- $enableVatDiscount = 'false';
357
- if ($inputValue === 1) {
358
- $enableVatDiscount = 'true';
359
- }
360
- return $enableVatDiscount;
361
- }
362
-
363
- public function Pay(Mage_Sales_Model_Order $order) {
364
-
365
- $payment_method = $order->getPayment()->getMethod();
366
-
367
- /* @var $store Mage_Core_Model_Store */
368
- $store = Mage::app()->getStore($order->getStoreId());
369
- $customer = Mage::getModel('customer/customer')
370
- ->load($order->getCustomerId());
371
- $billing_address = $order->getBillingAddress();
372
-
373
- // Need a two character locale code. This collects the store chosen language
374
- $locale_code = Mage::getSingleton('core/locale')->getLocaleCode();
375
- $locale_code = strtoupper(substr($locale_code, 0, 2));
376
-
377
-
378
- if (!in_array($locale_code, array('SV', 'FI', 'EN'))) {
379
- switch ($locale_code) {
380
- case 'DA':
381
- case 'NO': {
382
- $locale_code = 'SV';
383
- break;
384
- }
385
- default: {
386
- $locale_code = 'EN';
387
- }
388
- }
389
- }
390
-
391
- // $args will contain the arguments of the API request to Payson
392
- $args = array
393
- (
394
- 'returnUrl' =>
395
- Mage::getUrl('payson/checkout/return', array('_secure' => true)),
396
- 'cancelUrl' =>
397
- Mage::getUrl('payson/checkout/cancel', array('_secure' => true)),
398
- 'ipnNotificationUrl' =>
399
- Mage::getUrl('payson/ipn/notify', array('_secure' => true)),
400
- 'localeCode' =>
401
- $locale_code,
402
- 'currencyCode' =>
403
- strtoupper(substr($order->getOrderCurrency()->getCode(), 0, 3)),
404
- 'memo' =>
405
- sprintf($this->_helper->__('Order from %s'), $store->getName()),
406
- 'senderEmail' =>
407
- $order->getCustomerEmail(),
408
- 'senderFirstName' =>
409
- $billing_address->getFirstname(),
410
- 'senderLastName' =>
411
- $billing_address->getLastname(),
412
- 'receiverList.receiver(0).email' =>
413
- $this->_config->get('test_mode') ? self::DEBUG_MODE_MAIL : $this->_config->Get('email'),
414
- 'trackingId' => $order->getRealOrderId(),
415
- 'showReceiptPage' => $this->showReceiptPage()
416
- );
417
-
418
- if (!$this->_config->CanPaymentGuarantee()) {
419
- $args['guaranteeOffered'] = self::GUARANTEE_NO;
420
- }
421
- $isCurrency = strtoupper(Mage::app()->getStore()->getCurrentCurrencyCode());
422
- $paymentMethod = $this->_config->get('payson_All_in_one');
423
- //Get Payson paymentmethod
424
- //Direct Payment
425
- if ($this->_config->CanStandardPayment() && $isCurrency == 'SEK') {
426
- $payment = $this->getConstrains($paymentMethod);
427
- }
428
- //InvoicePayment with check if invoice amount is above minimum
429
- if ($this->_config->CanInvoicePayment() && ($order->getSubtotal() >= $this->invoiceAmountMinLimit) && ($isCurrency == 'SEK')) {
430
- $payment = $this->getConstrains($paymentMethod);
431
- }
432
- //Remove invoice if invoice amount is below minimum amount
433
- if ($this->_config->CanInvoicePayment() && ($order->getSubtotal() < $this->invoiceAmountMinLimit) && ($isCurrency == 'SEK')) {
434
- $disableInvoice = true;
435
- $payment = $this->getConstrains($paymentMethod);
436
- if (in_array(3, $payment)) {
437
- $newArray = array();
438
- foreach ($payment as $pkey) {
439
- if ($pkey != 3)
440
- $newArray[] = $pkey;
441
- }
442
- $payment = $newArray;
443
- }
444
- }
445
- //If other currency than SEK remove payment option Invocie and SMS
446
- if (($this->_config->CanInvoicePayment() || $this->_config->CanStandardPayment()) && ($isCurrency != 'SEK')) {
447
- $payment = $this->getConstrains($paymentMethod);
448
- //Remove Invoice from array
449
- if (in_array(3, $payment)) {
450
- $disableInvoice = true;
451
- $newArray = array();
452
- foreach ($payment as $pkey) {
453
- if ($pkey != 3) {
454
- $newArray[] = $pkey;
455
- }
456
- }
457
- $payment = $newArray;
458
- }
459
- //Remove SMS from array
460
- if (in_array(4, $payment)) {
461
- $newArray = array();
462
- foreach ($payment as $pkey) {
463
- if ($pkey != 4) {
464
- $newArray[] = $pkey;
465
- }
466
- }
467
- $payment = $newArray;
468
- }
469
- }
470
-
471
- $result = (!isset($payment)) ? $payment = '' : $payment;
472
-
473
- define("PMETHOD", serialize($result));
474
- $output = array();
475
- FundingConstraint::addConstraintsToOutput($result, $output);
476
- $args = array_merge($args, $output);
477
-
478
- // Calculate price of each item in the order
479
- $total = 0;
480
- foreach ($order->getAllVisibleItems() as $item) {
481
- $this->prepareOrderItemData($item, $total, $order);
482
- }
483
-
484
- $productItems = $this->generateProductDataForPayson($args);
485
- $customerCountry = $order->getBillingAddress()->country_id;
486
- if ($this->getStoreCountry() == 'SE' && $customerCountry == 'SE' && $this->vatDiscount() == 'true') {
487
-
488
- foreach ($order->getAllVisibleItems() as $item) {
489
- $this->setSwedishDiscountItem($item, $total, $productItems, $order);
490
- }
491
- if ($this->order_discount_item > 0) {
492
- switch ($this->getDiscountType()) {
493
- case Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION:
494
- case Mage_SalesRule_Model_Rule::TO_PERCENT_ACTION:
495
- $this->prepareProductData('Rabatt inkl moms', 'Rabatt', 1, -$this->order_discount_item, $this->getAverageVat());
496
- break;
497
- case Mage_SalesRule_Model_Rule::BY_FIXED_ACTION:
498
- $specialDiscount = $this->order_discount_item / $this->getNumberOfItems();
499
- $this->prepareProductData('Rabatt inkl moms', 'Rabatt', $this->getNumberOfItems(), -$specialDiscount, $this->getAverageVat());
500
- break;
501
- default:
502
- $this->prepareProductData('Rabatt inkl moms', 'Rabatt', 1, -$this->order_discount_item, $this->getAverageVat());
503
- break;
504
- }
505
- }
506
- } else {
507
-
508
- foreach ($order->getAllVisibleItems() as $item) {
509
- $this->setInternationalDiscountItem($item, $total);
510
- }
511
-
512
- if ($this->order_discount_item > 0) {
513
- $this->prepareProductData('discount', 'discount', 1, -$this->order_discount_item, 0.0);
514
- }
515
- }
516
- //
517
-
518
- // Calculate price for shipping
519
- $this->prepareOrderShippingData($order, $customer, $store, $total);
520
- $args = $this->generateProductDataForPayson($args);
521
-
522
- if ($this->_config->CanInvoicePayment() && ($order->getSubtotal() >= $this->invoiceAmountMinLimit) && !$disableInvoice) {
523
-
524
- if ($order->getPaysonInvoiceFee() > 0) {
525
-
526
- $fee = $order->getPaysonInvoiceFee();
527
-
528
- $args['invoiceFee'] = round((float) $fee, 3);
529
- $total += $fee;
530
- }
531
- }
532
- $roundedTotal = round($total, 2);
533
- if ($this->getStoreCountry() == 'SE' && $customerCountry == 'SE' && $this->vatDiscount() == 'true') {
534
- if ($this->order_discount_item > 0) {
535
- switch ($this->getDiscountType()) {
536
- case Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION:
537
- case Mage_SalesRule_Model_Rule::TO_PERCENT_ACTION:
538
- case Mage_SalesRule_Model_Rule::BY_FIXED_ACTION:
539
- case Mage_SalesRule_Model_Rule::CART_FIXED_ACTION:
540
- $roundedTotal = $roundedTotal - ($this->order_discount_item * $this->getAverageVat());
541
- break;
542
-
543
- default:
544
- break;
545
- }
546
- }
547
- }
548
- $args['receiverList.receiver(0).amount'] = $roundedTotal;
549
-
550
- $url = vsprintf(self::API_CALL_PAY, $this->getFormatIfTest($order->getStoreId()));
551
-
552
- $client = $this->getHttpClient($url)
553
- ->setParameterPost($args);
554
-
555
- $response = Payson_Payson_Helper_Api_Response_Standard
556
- ::FromHttpBody($client->request('POST')->getBody());
557
- $this->setResponse($response);
558
-
559
-
560
- $resource = Mage::getSingleton('core/resource');
561
- $db = $resource->getConnection('core_write');
562
-
563
- $order_table = $resource->getTableName('payson_order');
564
- $order_log_table = $resource->getTableName('payson_order_log');
565
-
566
- $db->insert($order_table, array
567
- (
568
- 'order_id' => $order->getRealOrderId(),
569
- 'added' => new Zend_Db_Expr('NOW()'),
570
- 'updated' => new Zend_Db_Expr('NOW()'),
571
- 'valid' => (int) $response->IsValid(),
572
- 'token' => (isset($response->TOKEN) ? $response->TOKEN :
573
- new Zend_Db_Expr('NULL')),
574
- 'store_id' => $order->getStoreId()
575
- ));
576
-
577
- $payson_order_id = $db->lastInsertId();
578
-
579
- $db->insert($order_log_table, array
580
- (
581
- 'payson_order_id' => $payson_order_id,
582
- 'added' => new Zend_Db_Expr('NOW()'),
583
- 'api_call' => 'pay',
584
- 'valid' => (int) $response->IsValid(),
585
- 'response' => serialize($response->ToArray())
586
- ));
587
-
588
- if (!$response->IsValid()) {
589
-
590
- throw new Mage_Core_Exception(sprintf($this->_helper->__(
591
- 'Failed to initialize payment. Payson replied: %s'), $response->GetError()), $response->GetErrorId());
592
- }
593
-
594
- return $this;
595
- }
596
-
597
- public function PaymentMethod() {
598
-
599
- }
600
-
601
- private function getConstrains($paymentMethod) {
602
-
603
- $constraints = array();
604
- $opts = array(
605
- -1 => array(''),
606
- 0 => array('sms'),
607
- 1 => array('bank'),
608
- 2 => array('card'),
609
- 3 => array('bank', 'sms'),
610
- 4 => array('card', 'sms'),
611
- 5 => array('card', 'bank'),
612
- 6 => array('card', 'bank', 'sms'),
613
- 7 => array(''),
614
- 8 => array('invoice'),
615
- 9 => array('invoice', 'sms'),
616
- 10 => array('invoice', 'bank'),
617
- 11 => array('invoice', 'card'),
618
- 12 => array('invoice', 'bank', 'sms'),
619
- 13 => array('invoice', 'card', 'sms'),
620
- 14 => array('invoice', 'card', 'bank'),
621
- 15 => array('invoice', 'card', 'bank', 'sms'),
622
- );
623
- $optsStrings = array('' => FundingConstraint::NONE, 'bank' => FundingConstraint::BANK, 'card' => FundingConstraint::CREDITCARD, 'invoice' => FundingConstraint::INVOICE, 'sms' => FundingConstraint::SMS);
624
- if ($opts[$paymentMethod]) {
625
- foreach ($opts[$paymentMethod] as $methodStringName) {
626
- $constraints[] = $optsStrings[$methodStringName];
627
- }
628
- }
629
- return $constraints;
630
- }
631
-
632
- /**
633
- * Implements the IPN procedure
634
- *
635
- * http://api.payson.se/#title11
636
- *
637
- * @param string $http_body
638
- * @param string $content_type
639
- * @return object $this
640
- */
641
- public function confirmationEmail($entityId) {
642
- $resource = Mage::getSingleton('core/resource');
643
- $db = $resource->getConnection('core_write');
644
- $order_table = $resource->getTableName('sales_flat_order');
645
- $status = $db->fetchRow(
646
- 'SELECT status FROM `' . $order_table . '` WHERE
647
- entity_id = ? LIMIT 0,1', $entityId);
648
-
649
- return $status;
650
- }
651
-
652
- public function Validate($http_body, $content_type) {
653
-
654
- // Parse request done by Payson to our IPN controller
655
- $ipn_response = Payson_Payson_Helper_Api_Response_Standard
656
- ::FromHttpBody($http_body);
657
- // Get the database connection
658
- $resource = Mage::getSingleton('core/resource');
659
- $db = $resource->getConnection('core_write');
660
-
661
- $order_table = $resource->getTableName('payson_order');
662
- $order_log_table = $resource->getTableName('payson_order_log');
663
-
664
-
665
- /* Save data sent by Payson, log entry as invalid by default, this
666
- value will be changed later in this method if successful. No payson
667
- order id is set, because we dont have one yet */
668
- $db->insert($order_log_table, array
669
- (
670
- 'added' => new Zend_Db_Expr('NOW()'),
671
- 'api_call' => 'validate',
672
- 'valid' => 0,
673
- 'response' => serialize($ipn_response->ToArray())
674
- ));
675
-
676
- $order_log_id = $db->lastInsertId();
677
-
678
- /* Save fetch mode so that we can reset it and not mess up Magento
679
- functionality */
680
- $old_fetch_mode = $db->getFetchMode();
681
- $db->setFetchMode(Zend_Db::FETCH_OBJ);
682
-
683
- // Get payson order information and validate token
684
- $payson_order = $db->fetchRow(
685
- 'SELECT
686
- id,
687
- order_id,
688
- store_id
689
- FROM
690
- `' . $order_table . '`
691
- WHERE
692
- valid = 1
693
- AND
694
- token = ?
695
- LIMIT
696
- 0,1', $ipn_response->token);
697
-
698
- if ($payson_order === false) {
699
- Mage::throwException('Invalid token');
700
- }
701
-
702
- // Do the validate API call
703
- $client = $this->getHttpClient(vsprintf(self::API_CALL_VALIDATE, $this->getFormatIfTest($payson_order->store_id)))
704
- ->setRawData($http_body, $content_type);
705
-
706
- $response = Payson_Payson_Helper_Api_Response_Validate
707
- ::FromHttpBody($client->request('POST')->getBody());
708
-
709
- $this->setResponse($response);
710
-
711
- if (!$response->IsValid()) {
712
- Mage::throwException('Validate call was unsuccessful');
713
- }
714
-
715
-
716
-
717
- // Update order log with payson order id
718
- $db->update($order_log_table, array
719
- (
720
- 'payson_order_id' => $payson_order->id
721
- ), array
722
- (
723
- 'id = ?' => $order_log_id
724
- ));
725
-
726
- // the order model does not expect FETCH_OBJ!
727
- $db->setFetchMode($old_fetch_mode);
728
-
729
- /**
730
- * @var Mage_Sales_Model_Order
731
- */
732
- $order = Mage::getModel('sales/order')
733
- ->loadByIncrementId($payson_order->order_id);
734
-
735
- // Stop if order dont exist
736
- if (is_null($order->getId())) {
737
- Mage::throwException('Invalid order');
738
- }
739
-
740
- if ($order->getState() === Mage_Sales_Model_Order::STATE_COMPLETE) {
741
- Mage::throwException('Order is no longer active');
742
- }
743
- $sendEmail = $this->confirmationEmail($order->getEntityId());
744
- $receivers = $ipn_response->receiverList->receiver->ToArray();
745
- $investigatefee = $order['base_payson_invoice_fee'];
746
-
747
- $new_receivers = array();
748
- foreach ($receivers as $item) {
749
- foreach ($item as $key => $value) {
750
- $new_receivers[$key] = $value;
751
- }
752
- }
753
- $currentAmount = $new_receivers['amount'];
754
- $newAmount = $currentAmount += $investigatefee;
755
-
756
- /* Verify payment amount. floor() since there might be a precision
757
- difference */
758
- switch ($ipn_response->status) {
759
- case self::STATUS_COMPLETED: {
760
- //Changes the status of the order from pending_payment to processing
761
- if ($sendEmail['status'] == 'pending_payment') {
762
- $order->sendNewOrderEmail()->save();
763
- }
764
- $order->setState(
765
- Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $this->_config->get('test_mode') ? $this->_helper->__('Payson test completed the order payment') : $this->_helper->__('Payson completed the order payment'));
766
- $order['payson_invoice_fee'] = 0;
767
- $order['base_payson_invoice_fee'] = 0;
768
- //It creates the invoice to the order
769
- $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
770
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
771
- $invoice->register();
772
- $transactionSave = Mage::getModel('core/resource_transaction')
773
- ->addObject($invoice)
774
- ->addObject($invoice->getOrder());
775
- $transactionSave->save();
776
-
777
- break;
778
- }
779
- case self::STATUS_CREATED:
780
- case self::STATUS_PENDING:
781
- case self::STATUS_PROCESSING:
782
- case self::STATUS_CREDITED: {
783
- if (($ipn_response->status === self::STATUS_PENDING) &&
784
- ($ipn_response->type === self::PAYMENT_METHOD_INVOICE) &&
785
- ($ipn_response->invoiceStatus ===
786
- self::INVOICE_STATUS_ORDERCREATED)) {
787
- if ($sendEmail['status'] == 'pending_payment') {
788
- $order->sendNewOrderEmail()->save();
789
- }
790
- //Changes the status of the order from pending to processing
791
- $order->setState(
792
- Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $this->_config->get('test_mode') ? $this->_helper->__('Payson test created an invoice') : $this->_helper->__('Payson created an invoice'));
793
- $order->setBaseGrandTotal($newAmount);
794
- $order->setGrandTotal($newAmount);
795
- $order->setTotalDue($newAmount);
796
- $order->save();
797
-
798
-
799
- if (isset($ipn_response->shippingAddress)) {
800
- $address_info = $ipn_response->shippingAddress
801
- ->ToArray();
802
-
803
- $address = $order->getShippingAddress();
804
-
805
- if (isset($address_info['name'])) {
806
- $address->setFirstname($address_info['name']);
807
- $address->setMiddlename('');
808
- $address->setLastname('');
809
- }
810
-
811
- if (isset($address_info['streetAddress'])) {
812
- $address->setStreet($address_info['streetAddress']);
813
- }
814
-
815
- if (isset($address_info['postalCode'])) {
816
- $address->setPostcode($address_info['streetAddress']);
817
- }
818
-
819
- if (isset($address_info['city'])) {
820
- $address->setCity($address_info['city']);
821
- }
822
-
823
- if (isset($address_info['country'])) {
824
-
825
- $foo = array
826
- (
827
- 'afghanistan' => 'AF',
828
- 'albania' => 'AL',
829
- 'algeria' => 'DZ',
830
- 'american samoa' => 'AS',
831
- 'andorra' => 'AD',
832
- 'angola' => 'AO',
833
- 'anguilla' => 'AI',
834
- 'antarctica' => 'AQ',
835
- 'antigua and barbuda' => 'AG',
836
- 'argentina' => 'AR',
837
- 'armenia' => 'AM',
838
- 'aruba' => 'AW',
839
- 'australia' => 'AU',
840
- 'austria' => 'AT',
841
- 'azerbaijan' => 'AZ',
842
- 'bahamas' => 'BS',
843
- 'bahrain' => 'BH',
844
- 'bangladesh' => 'BD',
845
- 'barbados' => 'BB',
846
- 'belarus' => 'BY',
847
- 'belgium' => 'BE',
848
- 'belize' => 'BZ',
849
- 'benin' => 'BJ',
850
- 'bermuda' => 'BM',
851
- 'bhutan' => 'BT',
852
- 'bolivia' => 'BO',
853
- 'bosnia and herzegovina' => 'BA',
854
- 'botswana' => 'BW',
855
- 'bouvet island' => 'BV',
856
- 'brazil' => 'BR',
857
- 'british indian ocean territory' => 'IO',
858
- 'brunei darussalam' => 'BN',
859
- 'bulgaria' => 'BG',
860
- 'burkina faso' => 'BF',
861
- 'burundi' => 'BI',
862
- 'cambodia' => 'KH',
863
- 'cameroon' => 'CM',
864
- 'canada' => 'CA',
865
- 'cape verde' => 'CV',
866
- 'cayman islands' => 'KY',
867
- 'central african republic' => 'CF',
868
- 'chad' => 'TD',
869
- 'chile' => 'CL',
870
- 'china' => 'CN',
871
- 'christmas island' => 'CX',
872
- 'cocos (keeling) islands' => 'CC',
873
- 'colombia' => 'CO',
874
- 'comoros' => 'KM',
875
- 'congo' => 'CG',
876
- 'congo, the democratic republic of the' => 'CD',
877
- 'cook islands' => 'CK',
878
- 'costa rica' => 'CR',
879
- 'cote d ivoire' => 'CI',
880
- 'croatia' => 'HR',
881
- 'cuba' => 'CU',
882
- 'cyprus' => 'CY',
883
- 'czech republic' => 'CZ',
884
- 'denmark' => 'DK',
885
- 'djibouti' => 'DJ',
886
- 'dominica' => 'DM',
887
- 'dominican republic' => 'DO',
888
- 'east timor' => 'TP',
889
- 'ecuador' => 'EC',
890
- 'egypt' => 'EG',
891
- 'el salvador' => 'SV',
892
- 'equatorial guinea' => 'GQ',
893
- 'eritrea' => 'ER',
894
- 'estonia' => 'EE',
895
- 'ethiopia' => 'ET',
896
- 'falkland islands (malvinas)' => 'FK',
897
- 'faroe islands' => 'FO',
898
- 'fiji' => 'FJ',
899
- 'finland' => 'FI',
900
- 'france' => 'FR',
901
- 'french guiana' => 'GF',
902
- 'french polynesia' => 'PF',
903
- 'french southern territories' => 'TF',
904
- 'gabon' => 'GA',
905
- 'gambia' => 'GM',
906
- 'georgia' => 'GE',
907
- 'germany' => 'DE',
908
- 'ghana' => 'GH',
909
- 'gibraltar' => 'GI',
910
- 'greece' => 'GR',
911
- 'greenland' => 'GL',
912
- 'grenada' => 'GD',
913
- 'guadeloupe' => 'GP',
914
- 'guam' => 'GU',
915
- 'guatemala' => 'GT',
916
- 'guinea' => 'GN',
917
- 'guinea-bissau' => 'GW',
918
- 'guyana' => 'GY',
919
- 'haiti' => 'HT',
920
- 'heard island and mcdonald islands' => 'HM',
921
- 'holy see (vatican city state)' => 'VA',
922
- 'honduras' => 'HN',
923
- 'hong kong' => 'HK',
924
- 'hungary' => 'HU',
925
- 'iceland' => 'IS',
926
- 'india' => 'IN',
927
- 'indonesia' => 'ID',
928
- 'iran, islamic republic of' => 'IR',
929
- 'iraq' => 'IQ',
930
- 'ireland' => 'IE',
931
- 'israel' => 'IL',
932
- 'italy' => 'IT',
933
- 'jamaica' => 'JM',
934
- 'japan' => 'JP',
935
- 'jordan' => 'JO',
936
- 'kazakstan' => 'KZ',
937
- 'kenya' => 'KE',
938
- 'kiribati' => 'KI',
939
- 'korea democratic peoples republic of' => 'KP',
940
- 'korea republic of' => 'KR',
941
- 'kuwait' => 'KW',
942
- 'kyrgyzstan' => 'KG',
943
- 'lao peoples democratic republic' => 'LA',
944
- 'latvia' => 'LV',
945
- 'lebanon' => 'LB',
946
- 'lesotho' => 'LS',
947
- 'liberia' => 'LR',
948
- 'libyan arab jamahiriya' => 'LY',
949
- 'liechtenstein' => 'LI',
950
- 'lithuania' => 'LT',
951
- 'luxembourg' => 'LU',
952
- 'macau' => 'MO',
953
- 'macedonia, the former yugoslav republic of' => 'MK',
954
- 'madagascar' => 'MG',
955
- 'malawi' => 'MW',
956
- 'malaysia' => 'MY',
957
- 'maldives' => 'MV',
958
- 'mali' => 'ML',
959
- 'malta' => 'MT',
960
- 'marshall islands' => 'MH',
961
- 'martinique' => 'MQ',
962
- 'mauritania' => 'MR',
963
- 'mauritius' => 'MU',
964
- 'mayotte' => 'YT',
965
- 'mexico' => 'MX',
966
- 'micronesia, federated states of' => 'FM',
967
- 'moldova, republic of' => 'MD',
968
- 'monaco' => 'MC',
969
- 'mongolia' => 'MN',
970
- 'montserrat' => 'MS',
971
- 'morocco' => 'MA',
972
- 'mozambique' => 'MZ',
973
- 'myanmar' => 'MM',
974
- 'namibia' => 'NA',
975
- 'nauru' => 'NR',
976
- 'nepal' => 'NP',
977
- 'netherlands' => 'NL',
978
- 'netherlands antilles' => 'AN',
979
- 'new caledonia' => 'NC',
980
- 'new zealand' => 'NZ',
981
- 'nicaragua' => 'NI',
982
- 'niger' => 'NE',
983
- 'nigeria' => 'NG',
984
- 'niue' => 'NU',
985
- 'norfolk island' => 'NF',
986
- 'northern mariana islands' => 'MP',
987
- 'norway' => 'NO',
988
- 'oman' => 'OM',
989
- 'pakistan' => 'PK',
990
- 'palau' => 'PW',
991
- 'palestinian territory, occupied' => 'PS',
992
- 'panama' => 'PA',
993
- 'papua new guinea' => 'PG',
994
- 'paraguay' => 'PY',
995
- 'peru' => 'PE',
996
- 'philippines' => 'PH',
997
- 'pitcairn' => 'PN',
998
- 'poland' => 'PL',
999
- 'portugal' => 'PT',
1000
- 'puerto rico' => 'PR',
1001
- 'qatar' => 'QA',
1002
- 'reunion' => 'RE',
1003
- 'romania' => 'RO',
1004
- 'russian federation' => 'RU',
1005
- 'rwanda' => 'RW',
1006
- 'saint helena' => 'SH',
1007
- 'saint kitts and nevis' => 'KN',
1008
- 'saint lucia' => 'LC',
1009
- 'saint pierre and miquelon' => 'PM',
1010
- 'saint vincent and the grenadines' => 'VC',
1011
- 'samoa' => 'WS',
1012
- 'san marino' => 'SM',
1013
- 'sao tome and principe' => 'ST',
1014
- 'saudi arabia' => 'SA',
1015
- 'senegal' => 'SN',
1016
- 'seychelles' => 'SC',
1017
- 'sierra leone' => 'SL',
1018
- 'singapore' => 'SG',
1019
- 'slovakia' => 'SK',
1020
- 'slovenia' => 'SI',
1021
- 'solomon islands' => 'SB',
1022
- 'somalia' => 'SO',
1023
- 'south africa' => 'ZA',
1024
- 'south georgia and the south sandwich islands' => 'GS',
1025
- 'spain' => 'ES',
1026
- 'sri lanka' => 'LK',
1027
- 'sudan' => 'SD',
1028
- 'suriname' => 'SR',
1029
- 'svalbard and jan mayen' => 'SJ',
1030
- 'swaziland' => 'SZ',
1031
- 'sweden' => 'SE',
1032
- 'switzerland' => 'CH',
1033
- 'syrian arab republic' => 'SY',
1034
- 'taiwan, province of china' => 'TW',
1035
- 'tajikistan' => 'TJ',
1036
- 'tanzania, united republic of' => 'TZ',
1037
- 'thailand' => 'TH',
1038
- 'togo' => 'TG',
1039
- 'tokelau' => 'TK',
1040
- 'tonga' => 'TO',
1041
- 'trinidad and tobago' => 'TT',
1042
- 'tunisia' => 'TN',
1043
- 'turkey' => 'TR',
1044
- 'turkmenistan' => 'TM',
1045
- 'turks and caicos islands' => 'TC',
1046
- 'tuvalu' => 'TV',
1047
- 'uganda' => 'UG',
1048
- 'ukraine' => 'UA',
1049
- 'united arab emirates' => 'AE',
1050
- 'united kingdom' => 'GB',
1051
- 'united states' => 'US',
1052
- 'united states minor outlying islands' => 'UM',
1053
- 'uruguay' => 'UY',
1054
- 'uzbekistan' => 'UZ',
1055
- 'vanuatu' => 'VU',
1056
- 'venezuela' => 'VE',
1057
- 'viet nam' => 'VN',
1058
- 'virgin islands, british' => 'VG',
1059
- 'virgin islands, u.s.' => 'VI',
1060
- 'wallis and futuna' => 'WF',
1061
- 'western sahara' => 'EH',
1062
- 'yemen' => 'YE',
1063
- 'yugoslavia' => 'YU',
1064
- 'zambia' => 'ZM',
1065
- 'zimbabwe' => 'ZW'
1066
- );
1067
-
1068
- $address_info['country'] = strtolower(
1069
- $address_info['country']);
1070
-
1071
- if (isset($foo[$address_info['country']])) {
1072
- $address->setCountryId(
1073
- $foo[$address_info['country']]);
1074
- }
1075
- }
1076
-
1077
- $address->save();
1078
- $order->addStatusHistoryComment(sprintf($this->_helper->__(
1079
- 'Payson updated the shipping address')));
1080
- }
1081
- } else {
1082
- $order['payson_invoice_fee'] = 0;
1083
- $order['base_payson_invoice_fee'] = 0;
1084
- $order->addStatusHistoryComment(sprintf(
1085
- $this->_helper->__('Payson pinged the order with status %s'), $ipn_response->status));
1086
- }
1087
-
1088
- break;
1089
- }
1090
-
1091
- case self::STATUS_ERROR:
1092
- case self::STATUS_DENIED:
1093
-
1094
- $order->cancel();
1095
-
1096
-
1097
- $order->addStatusHistoryComment($this->_helper->__('The order was denied by Payson.'));
1098
-
1099
- break;
1100
-
1101
- case self::STATUS_INCOMPLETE:
1102
- case self::STATUS_EXPIRED:
1103
- case self::STATUS_CANCELED:
1104
- case self::STATUS_ABORTED:
1105
- $order->cancel();
1106
-
1107
- $order->addStatusHistoryComment($this->_helper->__('The order was canceled or not completed within allocated time'));
1108
- break;
1109
-
1110
- case self::STATUS_REVERSALERROR:
1111
- default: {
1112
- $order->cancel();
1113
- }
1114
- }
1115
-
1116
- $order->save();
1117
- $db->update($order_log_table, array
1118
- (
1119
- 'valid' => 1
1120
- ), array
1121
- (
1122
- 'id = ?' => $order_log_id
1123
- ));
1124
-
1125
- $db->update($order_table, array
1126
- (
1127
- 'ipn_status' => $ipn_response->status
1128
- ), array
1129
- (
1130
- 'id = ?' => $payson_order->id
1131
- ));
1132
-
1133
-
1134
- return $this;
1135
- }
1136
-
1137
- public function PaymentDetails($order_id) {
1138
-
1139
- // Get the database connection
1140
- $resource = Mage::getSingleton('core/resource');
1141
- $db = $resource->getConnection('core_write');
1142
-
1143
- $order_table = $resource->getTableName('payson_order');
1144
- $order_log_table = $resource->getTableName('payson_order_log');
1145
- /* Save fetch mode so that we can reset it and not mess up Magento
1146
- functionality */
1147
- $old_fetch_mode = $db->getFetchMode();
1148
- $db->setFetchMode(Zend_Db::FETCH_OBJ);
1149
-
1150
- // Get payson order information and validate token
1151
- $payson_order = $db->fetchRow(
1152
- 'SELECT
1153
- id,
1154
- token,
1155
- store_id
1156
- FROM
1157
- `' . $order_table . '`
1158
- WHERE
1159
- valid = 1
1160
- AND
1161
- order_id = ?
1162
- LIMIT
1163
- 0,1', $order_id);
1164
-
1165
- try {
1166
- $payson_order !== false;
1167
- } catch (Exception $e) {
1168
- Mage::throwException('Invalid order id (' . $order_id . ')' . $e->getMessage());
1169
- }
1170
- $db->setFetchMode($old_fetch_mode);
1171
-
1172
- $args = array
1173
- (
1174
- 'token' => $payson_order->token
1175
- );
1176
- $url = vsprintf(self::API_CALL_PAYMENT_DETAILS, $this->getFormatIfTest($payson_order->store_id));
1177
-
1178
- $client = $this->getHttpClient($url)
1179
- ->setParameterPost($args);
1180
-
1181
- $response = Payson_Payson_Helper_Api_Response_Standard
1182
- ::FromHttpBody($client->request('POST')->getBody());
1183
-
1184
- $this->setResponse($response);
1185
-
1186
- $db->insert($order_log_table, array
1187
- (
1188
- 'payson_order_id' => $payson_order->id,
1189
- 'added' => new Zend_Db_Expr('NOW()'),
1190
- 'api_call' => 'payment_details',
1191
- 'valid' => (int) $response->IsValid(),
1192
- 'response' => serialize($response->ToArray())
1193
- ));
1194
-
1195
- $payson_validator = $db->fetchRow(
1196
- 'SELECT ipn_status, token FROM `' . $order_table . '` WHERE order_id = ? LIMIT 0,1', $order_id);
1197
- if ((!$response->IsValid()) && ($payson_validator->ipn_status == NULL && $payson_validator->token == NULL)) {
1198
-
1199
- $sales_flat_order = 'sales_flat_order';
1200
- if ($order_id !== null && $payson_order !== false) {
1201
- $new_order_id = Mage::getModel('sales/order')->loadByIncrementId($order_id)->getEntityId();
1202
- $db->update($sales_flat_order, array('state' => 'canceled', 'status' => 'canceled'), array('entity_id = ?' => $new_order_id));
1203
- }
1204
- }
1205
-
1206
- if (!$response->IsValid()) {
1207
- $redirectUrl = Mage::getUrl('checkout/cart');
1208
- Mage::getSingleton('checkout/session')->setRedirectUrl($redirectUrl);
1209
- }
1210
-
1211
- return $this;
1212
- }
1213
-
1214
- /**
1215
- * http://api.payson.se/#title13
1216
- *
1217
- * @params int $order_id Real order id
1218
- * @params string $action
1219
- * @return object $this
1220
- */
1221
- public function PaymentUpdate($order_id, $action) {
1222
-
1223
- // Get the database connection
1224
- $resource = Mage::getSingleton('core/resource');
1225
- $db = $resource->getConnection('core_write');
1226
-
1227
- $order_table = $resource->getTableName('payson_order');
1228
- $order_log_table = $resource->getTableName('payson_order_log');
1229
-
1230
- /* Save fetch mode so that we can reset it and not mess up Magento
1231
- functionality */
1232
- $old_fetch_mode = $db->getFetchMode();
1233
- $db->setFetchMode(Zend_Db::FETCH_OBJ);
1234
-
1235
- // Get payson order information and validate token
1236
- $payson_order = $db->fetchRow(
1237
- 'SELECT
1238
- id,
1239
- token,
1240
- store_id
1241
- FROM
1242
- `' . $order_table . '`
1243
- WHERE
1244
- valid = 1
1245
- AND
1246
- order_id = ?
1247
- LIMIT
1248
- 0,1', $order_id);
1249
-
1250
-
1251
-
1252
- try {
1253
- $payson_order !== false;
1254
- } catch (Exception $e) {
1255
- Mage::throwException('Invalid order id (' . $order_id . ')' . $e->getMessage());
1256
- }
1257
-
1258
- $db->setFetchMode($old_fetch_mode);
1259
-
1260
- $args = array
1261
- (
1262
- 'token' => $payson_order->token,
1263
- 'action' => $action
1264
- );
1265
-
1266
- $client = $this->getHttpClient(vsprintf(self::API_CALL_PAYMENT_UPDATE, $this->getFormatIfTest($payson_order->store_id)))
1267
- ->setParameterPost($args);
1268
-
1269
- $response = Payson_Payson_Helper_Api_Response_Standard
1270
- ::FromHttpBody($client->request('POST')->getBody());
1271
-
1272
- $this->setResponse($response);
1273
-
1274
- $db->insert($order_log_table, array
1275
- (
1276
- 'payson_order_id' => $payson_order->id,
1277
- 'added' => new Zend_Db_Expr('NOW()'),
1278
- 'api_call' => 'payment_update',
1279
- 'valid' => (int) $response->IsValid(),
1280
- 'response' => serialize($response->ToArray())
1281
- ));
1282
-
1283
- return $this;
1284
- }
1285
-
1286
- private function getFormatIfTest($storeID = null, $isForwardURL = FALSE) {
1287
-
1288
- $stack = array();
1289
- /* @var $isTest bool */
1290
- $isTest = ($this->_config->get('test_mode', $storeID) == "1");
1291
-
1292
- array_push($stack, self::DEBUG_MODE ? "http" : "https");
1293
- array_push($stack, $isTest && !self::DEBUG_MODE ? "test-" : (self::DEBUG_MODE && !$isForwardURL ? "mvc" : ""));
1294
-
1295
- if ($isForwardURL == true) {
1296
- array_push($stack, self::DEBUG_MODE ? "app" : "www");
1297
- }
1298
-
1299
- array_push($stack, self::DEBUG_MODE ? "local" : "se");
1300
- array_push($stack, self::DEBUG_MODE ? "Payment" : "1.0");
1301
-
1302
- array_push($stack, self::DEBUG_MODE ? "" : "Payment");
1303
- return $stack;
1304
- }
1305
-
1306
- public function getIpnStatus($order_id) {
1307
- $resource = Mage::getSingleton('core/resource');
1308
- $db = $resource->getConnection('core_write');
1309
- $order_table = $resource->getTableName('payson_order');
1310
- $query = 'SELECT ipn_status FROM `' . $order_table . '` WHERE order_id = ' . $order_id;
1311
- return $db->fetchRow($query);
1312
- }
1313
-
1314
- public function paysonApiError($error) {
1315
- $error_code = '<html>
1316
- <head>
1317
- <meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
1318
- <script type="text/javascript">
1319
- alert("' . $error . '");
1320
- window.location="' . ('/index.php') . '";
1321
- </script>
1322
- </head>
1323
- </html>';
1324
- echo $error_code;
1325
- exit;
1326
- }
1327
-
1328
- }
app/code/community/Payson/Payson/Helper/Api/Response/Interface.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- interface Payson_Payson_Helper_Api_Response_Interface {
4
-
5
- /**
6
- * Construct a response object from a string
7
- *
8
- * @param string $body
9
- * @return object
10
- */
11
- public static function FromHttpBody($body);
12
-
13
- /**
14
- * Whether this response is valid
15
- *
16
- * @return bool
17
- */
18
- public function IsValid();
19
- }
20
-
app/code/community/Payson/Payson/Helper/Api/Response/Standard.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Helper_Api_Response_Standard extends Payson_Payson_Helper_Api_Response_Standard_Parameters implements Payson_Payson_Helper_Api_Response_Interface {
4
- /*
5
- * Constants
6
- */
7
-
8
- const ACK_SUCCESS = 'SUCCESS';
9
- const ACK_FAILURE = 'FAILURE';
10
-
11
- /*
12
- * Public methods
13
- */
14
-
15
- /**
16
- * Parse response object and instantiate
17
- *
18
- * @param string $response
19
- * @return object
20
- */
21
- static public function FromHttpBody($body) {
22
- $params = array();
23
- parse_str($body, $params);
24
-
25
- foreach ($params as $key => $value) {
26
- $sub_key = strtok($key, '_');
27
-
28
- if ($sub_key === $key) {
29
- continue;
30
- }
31
-
32
- $current = &$params;
33
-
34
- do {
35
- $matches = array();
36
-
37
- if (preg_match('/\((\d)\)#x2F;', $sub_key, $matches) === 1) {
38
- $sub_key = substr($sub_key, 0, -3);
39
-
40
- if (!strlen($sub_key)) {
41
- continue;
42
- }
43
- }
44
-
45
- if (!isset($current[$sub_key]) || !is_array($current[$sub_key])) {
46
- $current[$sub_key] = array();
47
- }
48
-
49
- $current = &$current[$sub_key];
50
-
51
- if (isset($matches[1])) {
52
- if (!isset($current[$matches[1]]) ||
53
- !is_array($current[$matches[1]])) {
54
- $current[$matches[1]] = array();
55
- }
56
-
57
- $current = &$current[$matches[1]];
58
- }
59
- } while (($sub_key = strtok('_')) !== false);
60
-
61
- $current = $value;
62
-
63
- unset($params[$key]);
64
- }
65
-
66
- return new self($params);
67
- }
68
-
69
- /**
70
- * Populate parameters
71
- *
72
- * @param array $params
73
- * @return void
74
- */
75
- public function __construct(array $params) {
76
- if (empty($params)) {
77
- Mage::throwException('Invalid response');
78
- }
79
-
80
- parent::__construct($params);
81
- }
82
-
83
- /**
84
- * @inheritDoc
85
- */
86
- public function IsValid() {
87
- return (isset($this->responseEnvelope->ack) &&
88
- ($this->responseEnvelope->ack === self::ACK_SUCCESS));
89
- }
90
-
91
- /**
92
- * Compile all errors into a string
93
- *
94
- * @return string
95
- */
96
- public function GetError() {
97
- $ret = '';
98
-
99
- if (isset($this->errorList->error)) {
100
- foreach ($this->errorList->error->ToArray() as $error) {
101
- if (isset($error['parameter'])) {
102
- $ret .= $error['parameter'] . ' ';
103
- }
104
-
105
- $ret .= '(' . $error['errorId'] . ') ' .
106
- $error['message'] . ' ';
107
- }
108
- }
109
-
110
- return rtrim($ret);
111
- }
112
-
113
- /**
114
- * Get first error id
115
- *
116
- * @return int|null
117
- */
118
- public function GetErrorId() {
119
- if (isset($this->errorList->error)) {
120
- foreach ($this->errorList->error->ToArray() as $error) {
121
- if (isset($error['errorId'])) {
122
- return (int) $error['errorId'];
123
- }
124
- }
125
- }
126
-
127
- return null;
128
- }
129
-
130
- }
131
-
app/code/community/Payson/Payson/Helper/Api/Response/Standard/Parameters.php DELETED
@@ -1,66 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Helper_Api_Response_Standard_Parameters {
4
- /*
5
- * Protected properties
6
- */
7
-
8
- /**
9
- * Multi-dimensional array containing parameters from the response
10
- *
11
- * @var array
12
- */
13
- protected $params = array();
14
-
15
- /*
16
- * Public methods
17
- */
18
-
19
- /**
20
- * Constructor!
21
- *
22
- * @param arary $params
23
- * @return void
24
- */
25
- public function __construct(array $params) {
26
- foreach ($params as $key => $value) {
27
- if (is_array($value)) {
28
- $this->params[$key] = new self($value);
29
- } else {
30
- $this->params[$key] = $value;
31
- }
32
- }
33
- }
34
-
35
- public function __get($name) {
36
- return (isset($this->params[$name]) ? $this->params[$name] : null);
37
- }
38
-
39
- public function __set($name, $value) {
40
- $this->params[$name] = $value;
41
- }
42
-
43
- public function __isset($name) {
44
- return isset($this->params[$name]);
45
- }
46
-
47
- /**
48
- * Compile the parameters into an array
49
- *
50
- * @return array
51
- */
52
- public function ToArray() {
53
- foreach ($this->params as $key => $value) {
54
- if ($value instanceof
55
- Payson_Payson_Helper_Api_Response_Standard_Parameters) {
56
- $arr[$key] = $value->ToArray();
57
- } else {
58
- $arr[$key] = $value;
59
- }
60
- }
61
-
62
- return $arr;
63
- }
64
-
65
- }
66
-
app/code/community/Payson/Payson/Helper/Api/Response/Validate.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Helper_Api_Response_Validate implements Payson_Payson_Helper_Api_Response_Interface {
4
- /*
5
- * Constants
6
- */
7
-
8
- const VERIFIED = 'VERIFIED';
9
- const INVALID = 'INVALID';
10
-
11
- /*
12
- * Private properties
13
- */
14
-
15
- private $data;
16
-
17
- /*
18
- * Public methods
19
- */
20
-
21
- /**
22
- * @inheritDoc
23
- */
24
- static public function FromHttpBody($data) {
25
- return new self($data);
26
- }
27
-
28
- /**
29
- * Constructor!
30
- *
31
- * @param string $data
32
- * @return void
33
- */
34
- public function __construct($data) {
35
- $this->data = $data;
36
- }
37
-
38
- /**
39
- * @inheritDoc
40
- */
41
- public function IsValid() {
42
- return ($this->data === self::VERIFIED);
43
- }
44
-
45
- }
46
-
app/code/community/Payson/Payson/Helper/Data.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Helper_Data extends Mage_Core_Helper_Abstract {
4
-
5
- }
6
-
app/code/community/Payson/Payson/Helper/FundingConstraint.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
-
3
- class FundingConstraint {
4
-
5
- const NONE = 0;
6
- const CREDITCARD = 1;
7
- const BANK = 2;
8
- const INVOICE = 3;
9
- const SMS = 4;
10
-
11
- public static function addConstraintsToOutput($fundingConstraints, &$output) {
12
- $formatString = "fundingList.fundingConstraint(%d).constraint";
13
-
14
- $i = 0;
15
- foreach ($fundingConstraints as $constraint) {
16
- if ($constraint != self::NONE) {
17
- $output[sprintf($formatString, $i)] = self::ConstantToString($constraint);
18
- $i++;
19
- }
20
- }
21
- }
22
-
23
- public static function ConstantToString($value) {
24
- switch ($value) {
25
- case self::BANK:
26
- return "BANK";
27
- case self::CREDITCARD:
28
- return "CREDITCARD";
29
- case self::INVOICE:
30
- return "INVOICE";
31
- case self::SMS:
32
- return "SMS";
33
- }
34
- }
35
-
36
- }
app/code/community/Payson/Payson/Model/Config.php DELETED
@@ -1,218 +0,0 @@
1
- <?php
2
-
3
- class Payson_Payson_Model_Config {
4
- /*
5
- * Constants
6
- */
7
-
8
- //const PAYMENT_GUARANTEE = 'payment_guarantee';
9
-
10
- const PAYMENT_GUARANTEE = 'NO';
11
- const DIRECT_PAYMENT = 'direct_payment';
12
- const CREDIT_CARD_PAYMENT = 'credit_card_payment';
13
- const INVOICE_PAYMENT = 'invoice_payment';
14
-
15
- /*
16
- * Private properties
17
- */
18
-
19
- /**
20
- * Default store id used in GetConfig()
21
- *
22
- * @var int
23
- */
24
- private $default_store_id;
25
-
26
- /**
27
- * Supported currency codes
28
- *
29
- * @var array
30
- */
31
- private $supported_currencies = array
32
- (
33
- 'SEK', 'EUR'
34
- );
35
-
36
- /*
37
- * Public methods
38
- */
39
-
40
- /**
41
- * Constructor!
42
- *
43
- * @return void
44
- */
45
-
46
- public function __construct() {
47
- $this->SetDefaultStoreId(Mage::app()->getStore()->getId());
48
- }
49
-
50
- /**
51
- * Set default store id
52
- *
53
- * @param int $store
54
- * @return object $this
55
- */
56
- public function SetDefaultStoreId($store) {
57
-
58
- $this->default_store_id = $store;
59
-
60
- return $this;
61
- }
62
-
63
- /**
64
- * Get default store id
65
- *
66
- * @return int
67
- */
68
- public function GetDefaultStoreId() {
69
-
70
- return $this->default_store_id;
71
- }
72
-
73
- /**
74
- * Whether $currency is supported
75
- *
76
- * @param string $currency
77
- * @return bool
78
- */
79
- public function IsCurrencySupported($currency) {
80
- return in_array(strtoupper($currency), $this->supported_currencies);
81
- }
82
-
83
- /**
84
- * Get configuration value
85
- *
86
- * @param mixed $name
87
- * @param int|null $store [optional]
88
- * @param mixed $default [optional]
89
- * @param string $prefix [optional]
90
- */
91
- public function GetConfig($name, $store = null, $default = null, $prefix = 'payment/payson_standard/') {
92
- if (!isset($store)) {
93
- $store = $this->GetDefaultStoreId();
94
- }
95
-
96
- $name = $prefix . $name;
97
- $value = Mage::getStoreConfig($name, $store);
98
-
99
- return (isset($value) ? $value : $default);
100
- }
101
-
102
- /**
103
- * @see GetConfig
104
- */
105
- public function Get($name, $store = null, $default = null, $prefix = 'payment/payson_standard/') {
106
- return $this->GetConfig($name, $store, $default, $prefix);
107
- }
108
-
109
- /**
110
- * Get Payson specific invoice fee excluding tax
111
- *
112
- * @param object $order
113
- * @return float
114
- */
115
- public function GetInvoiceFee($order) {
116
- $currency = $order->getBaseCurrencyCode();
117
- $currency = strtolower($currency);
118
-
119
- if (!$this->IsCurrencySupported($currency)) {
120
- return 0;
121
- }
122
-
123
- $store = Mage::app()->getStore($order->getStoreId());
124
-
125
- $fee = $this->GetConfig('invoice_fee_' . $currency, $store->getId(), 0, 'payment/payson_invoice/');
126
- $fee = round((float) $fee, 3);
127
-
128
- return $fee;
129
- }
130
-
131
- /**
132
- * Get Payson specific invoice fee including tax
133
- *
134
- * @param object $order
135
- * @return float
136
- */
137
- public function GetInvoiceFeeInclTax($order) {
138
- $fee = $this->GetInvoiceFee($order);
139
- $fee *= (1 + $this->GetInvoiceFeeTaxMod($order));
140
- $fee = round($fee, 3);
141
-
142
- return $fee;
143
- }
144
-
145
- /**
146
- * Get Payson specific invoice fee tax modifier
147
- *
148
- * @param object $order
149
- * @return float
150
- */
151
- public function GetInvoiceFeeTaxMod($order) {
152
- $store = Mage::app()->getStore($order->getStoreId());
153
-
154
- $tax_calc = Mage::getSingleton('tax/calculation');
155
- $customer = Mage::getModel('customer/customer')
156
- ->load($order->getCustomerId());
157
- $tax_class = $this->GetConfig('invoice_fee_tax', $store->getId(), 0, 'payment/payson_invoice/');
158
-
159
- $tax_rate_req = $tax_calc->getRateRequest(
160
- $order->getShippingAddress(), $order->getBillingAddress(), $customer->getTaxClassId(), $store)
161
- ->setProductClassId($tax_class);
162
-
163
- $tax_mod = (float) $tax_calc->getRate($tax_rate_req);
164
- $tax_mod /= 100;
165
- $tax_mod = round($tax_mod, 5);
166
-
167
- return $tax_mod;
168
- }
169
-
170
- /**
171
- * Does this store support payment guarantee?
172
- *
173
- * @param int|null $store [optional]
174
- * @return bool
175
- */
176
- public function CanPaymentGuarantee($store = null) {
177
- return (bool) $this->GetConfig(self::PAYMENT_GUARANTEE, $store, false);
178
- }
179
-
180
- /**
181
- * Is invoice payment enabled?
182
- *
183
- * @param int|null $store [optional]
184
- * @return bool
185
- */
186
-
187
- public function CanInvoicePayment($store = null) {
188
-
189
- return $this->GetConfig('active_invoice', $store, false, 'payment/payson_invoice/');
190
- }
191
- /**
192
- * Is standard payment enabled?
193
- *
194
- * @param int|null $store [optional]
195
- * @return bool
196
- */
197
- public function CanStandardPayment($store = null) {
198
- return $this->GetConfig('active', $store, false, 'payment/payson_standard/');
199
- }
200
-
201
- public function restoreCartOnCancel($store = null) {
202
- if (!$store)
203
- $store = Mage::app()->getStore()->getId();
204
- $configValue = $this->GetConfig("restore_on_cancel", $store);
205
-
206
- return $configValue == 1;
207
- }
208
-
209
- public function restoreCartOnError($store = null) {
210
- if (!$store)
211
- $store = Mage::app()->getStore()->getId();
212
- $configValue = $this->GetConfig("restore_on_error", $store);
213
-
214
- return $configValue == 1;
215
- }
216
-
217
- }
218
-
app/code/community/Payson/Payson/Model/Method/Abstract.php DELETED
@@ -1,148 +0,0 @@
1
- <?php
2
-
3
- abstract class Payson_Payson_Model_Method_Abstract extends Mage_Payment_Model_Method_Abstract {
4
-
5
- /**
6
- * @inheritDoc
7
- */
8
- protected $_isGateway = false;
9
- protected $_canAuthorize = false;
10
- protected $_canCapture = false;
11
- protected $_canCapturePartial = false;
12
- protected $_canRefund = false;
13
- protected $_canRefundInvoicePartial = false;
14
- protected $_canVoid = false;
15
- protected $_canUseInternal = false; // true
16
- protected $_canUseCheckout = true; // true
17
- protected $_canUseForMultishipping = false; // true
18
- protected $_isInitializeNeeded = false;
19
- protected $_canFetchTransactionInfo = false;
20
- protected $_canReviewPayment = false;
21
- protected $_canCreateBillingAgreement = false;
22
- protected $_canManageRecurringProfiles = false; // true
23
-
24
- /**
25
- * @inheritDoc
26
- */
27
- protected $_canCancelInvoice = true;
28
-
29
- /*
30
- * Protected methods
31
- */
32
-
33
- protected function GetCheckout() {
34
- return Mage::getSingleton('checkout/session');
35
- }
36
-
37
- protected function GetQuote() {
38
- return $this->GetCheckout()->getQuote();
39
- }
40
-
41
- /*
42
- * Public methods
43
- */
44
-
45
- /**
46
- * Redirect url when user place order
47
- *
48
- * @return string
49
- */
50
- public function getOrderPlaceRedirectUrl() {
51
- return Mage::getUrl('payson/checkout/redirect', array('_secure' => true));
52
- }
53
-
54
- /**
55
- * @inheritDoc
56
- */
57
- /* public function initialize($payment_action, $state_object)
58
- {
59
- $state_object->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
60
- $state_object->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
61
- $state_object->setIsNotified(false);
62
-
63
- return $this;
64
- } */
65
-
66
- /**
67
- * Whether this paymend method is available for specified currency
68
- *
69
- * @param string $currency
70
- * @return bool
71