Version Notes
New Payson module
Download this release
Release Info
Developer | Oscar Villegas |
Extension | Payson |
Version | 1.8.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.6.1 to 1.8.0
- app/code/community/Payson/Payson/Block/Invoice/Form.php +1 -1
- app/code/community/Payson/Payson/Helper/Api.php +130 -56
- app/code/community/Payson/Payson/Helper/FundingConstraint.php +36 -0
- app/code/community/Payson/Payson/Model/Config.php +13 -16
- app/code/community/Payson/Payson/Model/Method/Abstract.php +8 -24
- app/code/community/Payson/Payson/Model/Method/Invoice.php +0 -118
- app/code/community/Payson/Payson/Model/Method/Standard.php +42 -2
- app/code/community/Payson/Payson/Model/Order/Creditmemo/Total/Invoice.php +6 -9
- app/code/community/Payson/Payson/Model/Order/Invoice/Total/Invoice.php +8 -9
- app/code/community/Payson/Payson/Model/Quote/Address/Total/Invoice.php +9 -29
- app/code/community/Payson/Payson/Model/Standard.php +6 -18
- app/code/community/Payson/Payson/Model/System/Config/Source/Paysondirectmethod.php +37 -10
- app/code/community/Payson/Payson/controllers/Adminhtml/Sales/Order/ShipmentController.php +12 -13
- app/code/community/Payson/Payson/controllers/CheckoutController.php +29 -12
- app/code/community/Payson/Payson/etc/config.xml +1 -2
- app/code/community/Payson/Payson/etc/system.xml +50 -41
- app/code/community/Payson/Payson/etc/system.xml.bak +185 -0
- app/design/adminhtml/default/default/Payson/Payson/total.phtml +7 -1
- app/design/adminhtml/default/default/template/Payson/Payson/total.phtml +8 -2
- app/design/frontend/base/default/template/Payson/Payson/invoice_form.phtml +0 -15
- app/design/frontend/base/default/template/Payson/Payson/standard_form.phtml +20 -5
- app/etc/modules/Payson_Payson.xml +1 -1
- app/locale/sv_SE/Payson_Payson.csv +7 -6
- package.xml +7 -7
- skin/frontend/base/default/Payson/Payson/Allinone.png +0 -0
- skin/frontend/base/default/Payson/Payson/Allinone3.png +0 -0
app/code/community/Payson/Payson/Block/Invoice/Form.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
class Payson_Payson_Block_Invoice_Form extends Mage_Payment_Block_Form {
|
4 |
|
5 |
protected function _construct() {
|
6 |
-
$this->setTemplate('Payson/Payson/
|
7 |
parent::_construct();
|
8 |
}
|
9 |
|
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 |
|
app/code/community/Payson/Payson/Helper/Api.php
CHANGED
@@ -1,10 +1,14 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
3 |
class Payson_Payson_Helper_Api {
|
4 |
/*
|
5 |
* Constants
|
6 |
*/
|
7 |
|
|
|
|
|
8 |
const DEBUG_MODE = false;
|
9 |
const API_CALL_PAY = '%s://%sapi.payson.%s/%s/Pay/';
|
10 |
const API_CALL_VALIDATE = '%s://%sapi.payson.%s/%s/Validate/';
|
@@ -12,11 +16,11 @@ class Payson_Payson_Helper_Api {
|
|
12 |
const API_CALL_PAYMENT_UPDATE = '%s://%sapi.payson.%s/%s/%sUpdate/';
|
13 |
const PAY_FORWARD_URL = '%s://%s%s.payson.%s/paySecure/';
|
14 |
const APPLICATION_ID = 'Magento';
|
15 |
-
const MODULE_NAME = '
|
16 |
-
const MODULE_VERSION = '1.
|
17 |
-
const DEBUG_MODE_MAIL = '
|
18 |
-
const DEBUG_MODE_AGENT_ID = '
|
19 |
-
const DEBUG_MODE_MD5 = '
|
20 |
const STATUS_CREATED = 'CREATED';
|
21 |
const STATUS_PENDING = 'PENDING';
|
22 |
const STATUS_PROCESSING = 'PROCESSING';
|
@@ -29,6 +33,7 @@ class Payson_Payson_Helper_Api {
|
|
29 |
const PAYMENT_METHOD_BANK = 'BANK';
|
30 |
const PAYMENT_METHOD_CREDITCARD = 'CREDITCARD';
|
31 |
const PAYMENT_METHOD_INVOICE = 'INVOICE';
|
|
|
32 |
const GUARANTEE_STATUS_WAITINGFORSEND = 'WAITINGFORSEND';
|
33 |
const GUARANTEE_STATUS_WAITINGFORACCEPTANCE = 'WAITINGFORACCEPTANCE';
|
34 |
const GUARANTEE_STATUS_WAITINGFORRETURN = 'WAITINGFORRETURN';
|
@@ -51,6 +56,8 @@ class Payson_Payson_Helper_Api {
|
|
51 |
const GUARANTEE_OPTIONAL = 'OPTIONAL';
|
52 |
const GUARANTEE_NO = 'NO';
|
53 |
|
|
|
|
|
54 |
/*
|
55 |
* Private properties
|
56 |
*/
|
@@ -61,6 +68,7 @@ class Payson_Payson_Helper_Api {
|
|
61 |
private $_config;
|
62 |
/* @var $_helper Payson_Payson_Helper_Data */
|
63 |
private $_helper;
|
|
|
64 |
private $_products = array();
|
65 |
|
66 |
/*
|
@@ -70,6 +78,7 @@ class Payson_Payson_Helper_Api {
|
|
70 |
public function __construct() {
|
71 |
$this->_config = Mage::getModel('payson/config');
|
72 |
$this->_helper = Mage::helper('payson');
|
|
|
73 |
}
|
74 |
|
75 |
private function getHttpClient($url) {
|
@@ -244,7 +253,7 @@ class Payson_Payson_Helper_Api {
|
|
244 |
* http://api.payson.se/#title8
|
245 |
*
|
246 |
* @param object $order
|
247 |
-
* @return object
|
248 |
*/
|
249 |
public function showReceiptPage() {
|
250 |
$Config = (int) $this->_config->get('show_receipt_page');
|
@@ -293,8 +302,6 @@ class Payson_Payson_Helper_Api {
|
|
293 |
'localeCode' =>
|
294 |
$locale_code,
|
295 |
'currencyCode' =>
|
296 |
-
//$order->getOrderCurrency()->getCode(),
|
297 |
-
//$order->getBaseCurrencyCode(),
|
298 |
strtoupper(substr($order->getOrderCurrency()->getCode(), 0, 3)),
|
299 |
'memo' =>
|
300 |
sprintf($this->_helper->__('Order from %s'), $store->getName()),
|
@@ -313,30 +320,62 @@ class Payson_Payson_Helper_Api {
|
|
313 |
if (!$this->_config->CanPaymentGuarantee()) {
|
314 |
$args['guaranteeOffered'] = self::GUARANTEE_NO;
|
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 |
// Calculate price of each item in the order
|
|
|
340 |
foreach ($order->getAllVisibleItems() as $item) {
|
341 |
$this->prepareOrderItemData($item, $total);
|
342 |
}
|
@@ -344,33 +383,38 @@ class Payson_Payson_Helper_Api {
|
|
344 |
foreach ($order->getAllVisibleItems() as $item) {
|
345 |
$this->setOrderDiscountItem($item, $total);
|
346 |
}
|
|
|
347 |
if ($this->order_discount_item > 0) {
|
348 |
$this->prepareProductData('discount', 'discount', 1, -$this->order_discount_item, 0.0);
|
349 |
}
|
350 |
// Calculate price for shipping
|
351 |
$this->prepareOrderShippingData($order, $customer, $store, $total);
|
|
|
352 |
|
353 |
-
if ($order->
|
354 |
-
$fee = $order->getPaysonInvoiceFee();
|
355 |
-
$args['invoiceFee'] = round((float) $fee, 3);
|
356 |
-
$total += $fee;
|
357 |
-
}
|
358 |
|
359 |
-
|
360 |
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
$roundedTotal = round($total, 2);
|
362 |
|
363 |
$args['receiverList.receiver(0).amount'] = $roundedTotal;
|
364 |
|
365 |
$url = vsprintf(self::API_CALL_PAY, $this->getFormatIfTest($order->getStoreId()));
|
|
|
366 |
$client = $this->getHttpClient($url)
|
367 |
->setParameterPost($args);
|
368 |
|
369 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
370 |
::FromHttpBody($client->request('POST')->getBody());
|
371 |
-
|
372 |
$this->setResponse($response);
|
373 |
|
|
|
374 |
$resource = Mage::getSingleton('core/resource');
|
375 |
$db = $resource->getConnection('core_write');
|
376 |
|
@@ -408,6 +452,41 @@ class Payson_Payson_Helper_Api {
|
|
408 |
return $this;
|
409 |
}
|
410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
/**
|
412 |
* Implements the IPN procedure
|
413 |
*
|
@@ -417,8 +496,6 @@ class Payson_Payson_Helper_Api {
|
|
417 |
* @param string $content_type
|
418 |
* @return object $this
|
419 |
*/
|
420 |
-
|
421 |
-
|
422 |
public function Validate($http_body, $content_type) {
|
423 |
|
424 |
// Parse request done by Payson to our IPN controller
|
@@ -432,6 +509,7 @@ class Payson_Payson_Helper_Api {
|
|
432 |
$order_table = $resource->getTableName('payson_order');
|
433 |
$order_log_table = $resource->getTableName('payson_order_log');
|
434 |
|
|
|
435 |
/* Save data sent by Payson, log entry as invalid by default, this
|
436 |
value will be changed later in this method if successful. No payson
|
437 |
order id is set, because we dont have one yet */
|
@@ -445,13 +523,6 @@ class Payson_Payson_Helper_Api {
|
|
445 |
|
446 |
$order_log_id = $db->lastInsertId();
|
447 |
|
448 |
-
/* $ipn_response will never contain responseEnvelope.ack, as I first
|
449 |
-
thought it would */
|
450 |
-
/* if(!$ipn_response->IsValid())
|
451 |
-
{
|
452 |
-
Mage::throwException('Invalid request');
|
453 |
-
} */
|
454 |
-
|
455 |
/* Save fetch mode so that we can reset it and not mess up Magento
|
456 |
functionality */
|
457 |
$old_fetch_mode = $db->getFetchMode();
|
@@ -532,10 +603,6 @@ LIMIT
|
|
532 |
|
533 |
/* Verify payment amount. floor() since there might be a precision
|
534 |
difference */
|
535 |
-
if (floor((float) $receivers[0]['amount']) !==
|
536 |
-
floor((float) $order->getTotalDue())) {
|
537 |
-
Mage::throwException('Invalid amount');
|
538 |
-
}
|
539 |
|
540 |
switch ($ipn_response->status) {
|
541 |
case self::STATUS_COMPLETED: {
|
@@ -572,6 +639,7 @@ LIMIT
|
|
572 |
$order->save();
|
573 |
|
574 |
|
|
|
575 |
if (isset($ipn_response->shippingAddress)) {
|
576 |
$address_info = $ipn_response->shippingAddress
|
577 |
->ToArray();
|
@@ -597,7 +665,7 @@ LIMIT
|
|
597 |
}
|
598 |
|
599 |
if (isset($address_info['country'])) {
|
600 |
-
|
601 |
$foo = array
|
602 |
(
|
603 |
'afghanistan' => 'AF',
|
@@ -855,10 +923,10 @@ LIMIT
|
|
855 |
'Payson updated the shipping address')));
|
856 |
}
|
857 |
} else {
|
858 |
-
$order->addStatusHistoryComment(sprintf(
|
859 |
-
$this->_helper->__('Payson pinged the order with status %s'), $ipn_response->status));
|
860 |
$order['payson_invoice_fee']= 0;
|
861 |
$order['base_payson_invoice_fee']=0;
|
|
|
|
|
862 |
}
|
863 |
|
864 |
break;
|
@@ -868,12 +936,16 @@ LIMIT
|
|
868 |
|
869 |
$order->cancel();
|
870 |
|
|
|
871 |
$order->addStatusHistoryComment($this->_helper->__('The order was denied by Payson.'));
|
872 |
|
873 |
break;
|
874 |
|
875 |
case self::STATUS_INCOMPLETE:
|
876 |
case self::STATUS_EXPIRED:
|
|
|
|
|
|
|
877 |
case self::STATUS_REVERSALERROR:
|
878 |
default: {
|
879 |
$order->cancel();
|
@@ -881,8 +953,6 @@ LIMIT
|
|
881 |
}
|
882 |
|
883 |
$order->save();
|
884 |
-
|
885 |
-
// Update the database tables
|
886 |
$db->update($order_log_table, array
|
887 |
(
|
888 |
'valid' => 1
|
@@ -899,6 +969,7 @@ LIMIT
|
|
899 |
'id = ?' => $payson_order->id
|
900 |
));
|
901 |
|
|
|
902 |
return $this;
|
903 |
}
|
904 |
|
@@ -916,7 +987,6 @@ LIMIT
|
|
916 |
|
917 |
$order_table = $resource->getTableName('payson_order');
|
918 |
$order_log_table = $resource->getTableName('payson_order_log');
|
919 |
-
|
920 |
/* Save fetch mode so that we can reset it and not mess up Magento
|
921 |
functionality */
|
922 |
$old_fetch_mode = $db->getFetchMode();
|
@@ -1010,8 +1080,12 @@ AND
|
|
1010 |
LIMIT
|
1011 |
0,1', $order_id);
|
1012 |
|
1013 |
-
|
1014 |
-
|
|
|
|
|
|
|
|
|
1015 |
}
|
1016 |
|
1017 |
$db->setFetchMode($old_fetch_mode);
|
@@ -1067,7 +1141,7 @@ LIMIT
|
|
1067 |
array_push($stack, self::DEBUG_MODE ? "Payment" : "1.0");
|
1068 |
|
1069 |
array_push($stack, self::DEBUG_MODE ? "" : "Payment");
|
1070 |
-
//print_r($stack);
|
1071 |
return $stack;
|
1072 |
}
|
1073 |
|
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/';
|
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_Magento_AllinOne';
|
20 |
+
const MODULE_VERSION = '1.0';
|
21 |
+
const DEBUG_MODE_MAIL = 'karlbrundin@gmail.com';
|
22 |
+
const DEBUG_MODE_AGENT_ID = '87';
|
23 |
+
const DEBUG_MODE_MD5 = '1445c9a1-a2de-451d-baba-af26deccce0c';
|
24 |
const STATUS_CREATED = 'CREATED';
|
25 |
const STATUS_PENDING = 'PENDING';
|
26 |
const STATUS_PROCESSING = 'PROCESSING';
|
33 |
const PAYMENT_METHOD_BANK = 'BANK';
|
34 |
const PAYMENT_METHOD_CREDITCARD = 'CREDITCARD';
|
35 |
const PAYMENT_METHOD_INVOICE = 'INVOICE';
|
36 |
+
const PAYMENT_METHOD_SMS = 'SMS';
|
37 |
const GUARANTEE_STATUS_WAITINGFORSEND = 'WAITINGFORSEND';
|
38 |
const GUARANTEE_STATUS_WAITINGFORACCEPTANCE = 'WAITINGFORACCEPTANCE';
|
39 |
const GUARANTEE_STATUS_WAITINGFORRETURN = 'WAITINGFORRETURN';
|
56 |
const GUARANTEE_OPTIONAL = 'OPTIONAL';
|
57 |
const GUARANTEE_NO = 'NO';
|
58 |
|
59 |
+
//const PMETHOD ='';
|
60 |
+
|
61 |
/*
|
62 |
* Private properties
|
63 |
*/
|
68 |
private $_config;
|
69 |
/* @var $_helper Payson_Payson_Helper_Data */
|
70 |
private $_helper;
|
71 |
+
private $_invoice;
|
72 |
private $_products = array();
|
73 |
|
74 |
/*
|
78 |
public function __construct() {
|
79 |
$this->_config = Mage::getModel('payson/config');
|
80 |
$this->_helper = Mage::helper('payson');
|
81 |
+
$this->_invoice = Mage::getModel('payson/method/invoice');
|
82 |
}
|
83 |
|
84 |
private function getHttpClient($url) {
|
253 |
* http://api.payson.se/#title8
|
254 |
*
|
255 |
* @param object $order
|
256 |
+
* @return object
|
257 |
*/
|
258 |
public function showReceiptPage() {
|
259 |
$Config = (int) $this->_config->get('show_receipt_page');
|
302 |
'localeCode' =>
|
303 |
$locale_code,
|
304 |
'currencyCode' =>
|
|
|
|
|
305 |
strtoupper(substr($order->getOrderCurrency()->getCode(), 0, 3)),
|
306 |
'memo' =>
|
307 |
sprintf($this->_helper->__('Order from %s'), $store->getName()),
|
320 |
if (!$this->_config->CanPaymentGuarantee()) {
|
321 |
$args['guaranteeOffered'] = self::GUARANTEE_NO;
|
322 |
}
|
323 |
+
$isCurrency = strtoupper(Mage::app()->getStore()->getCurrentCurrencyCode());
|
324 |
+
$paymentMethod = $this->_config->get('payson_All_in_one');
|
325 |
+
//Get Payson paymentmethod
|
326 |
+
//Direct Payment
|
327 |
+
if ($this->_config->CanStandardPayment() && $isCurrency == 'SEK') {
|
328 |
+
$payment = $this->getConstrains($paymentMethod);
|
329 |
+
}
|
330 |
+
//InvoicePayment with check if invoice amount is above minimum
|
331 |
+
if ($this->_config->CanInvoicePayment() && ($order->getSubtotal() >= $this->invoiceAmountMinLimit) && ($isCurrency == 'SEK')) {
|
332 |
+
$payment = $this->getConstrains($paymentMethod);
|
333 |
+
}
|
334 |
+
//Remove invoice if invoice amount is below minimum amount
|
335 |
+
if ($this->_config->CanInvoicePayment() && ($order->getSubtotal() < $this->invoiceAmountMinLimit) && ($isCurrency == 'SEK')) {
|
336 |
+
$disableInvoice = true;
|
337 |
+
$payment = $this->getConstrains($paymentMethod);
|
338 |
+
if (in_array(3, $payment)) {
|
339 |
+
$newArray = array();
|
340 |
+
foreach ($payment as $pkey) {
|
341 |
+
if ($pkey != 3)
|
342 |
+
$newArray[] = $pkey;
|
343 |
+
}
|
344 |
+
$payment = $newArray;
|
345 |
}
|
346 |
+
}
|
347 |
+
//If other currency than SEK remove payment option Invocie and SMS
|
348 |
+
if (($this->_config->CanInvoicePayment() || $this->_config->CanStandardPayment()) && ($isCurrency != 'SEK')) {
|
349 |
+
$payment = $this->getConstrains($paymentMethod);
|
350 |
+
//Remove Invoice from array
|
351 |
+
if (in_array(3, $payment)) {
|
352 |
+
$disableInvoice = true;
|
353 |
+
$newArray = array();
|
354 |
+
foreach ($payment as $pkey) {
|
355 |
+
if ($pkey != 3) {
|
356 |
+
$newArray[] = $pkey;
|
357 |
+
}
|
358 |
+
}
|
359 |
+
$payment = $newArray;
|
360 |
+
}
|
361 |
+
//Remove SMS from array
|
362 |
+
if (in_array(4, $payment)) {
|
363 |
+
$newArray = array();
|
364 |
+
foreach ($payment as $pkey) {
|
365 |
+
if ($pkey != 4) {
|
366 |
+
$newArray[] = $pkey;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
$payment = $newArray;
|
370 |
}
|
371 |
}
|
372 |
+
define("PMETHOD", serialize($payment));
|
373 |
+
$output = array();
|
374 |
+
FundingConstraint::addConstraintsToOutput($payment, $output);
|
375 |
+
$args = array_merge($args, $output);
|
376 |
|
377 |
// Calculate price of each item in the order
|
378 |
+
$total = 0;
|
379 |
foreach ($order->getAllVisibleItems() as $item) {
|
380 |
$this->prepareOrderItemData($item, $total);
|
381 |
}
|
383 |
foreach ($order->getAllVisibleItems() as $item) {
|
384 |
$this->setOrderDiscountItem($item, $total);
|
385 |
}
|
386 |
+
|
387 |
if ($this->order_discount_item > 0) {
|
388 |
$this->prepareProductData('discount', 'discount', 1, -$this->order_discount_item, 0.0);
|
389 |
}
|
390 |
// Calculate price for shipping
|
391 |
$this->prepareOrderShippingData($order, $customer, $store, $total);
|
392 |
+
$args = $this->generateProductDataForPayson($args);
|
393 |
|
394 |
+
if ($this->_config->CanInvoicePayment() && ($order->getSubtotal() >= $this->invoiceAmountMinLimit) && !$disableInvoice) {
|
|
|
|
|
|
|
|
|
395 |
|
396 |
+
if ($order->getPaysonInvoiceFee() > 0) {
|
397 |
|
398 |
+
$fee = $order->getPaysonInvoiceFee();
|
399 |
+
|
400 |
+
$args['invoiceFee'] = round((float) $fee, 3);
|
401 |
+
$total += $fee;
|
402 |
+
}
|
403 |
+
}
|
404 |
$roundedTotal = round($total, 2);
|
405 |
|
406 |
$args['receiverList.receiver(0).amount'] = $roundedTotal;
|
407 |
|
408 |
$url = vsprintf(self::API_CALL_PAY, $this->getFormatIfTest($order->getStoreId()));
|
409 |
+
|
410 |
$client = $this->getHttpClient($url)
|
411 |
->setParameterPost($args);
|
412 |
|
413 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
414 |
::FromHttpBody($client->request('POST')->getBody());
|
|
|
415 |
$this->setResponse($response);
|
416 |
|
417 |
+
|
418 |
$resource = Mage::getSingleton('core/resource');
|
419 |
$db = $resource->getConnection('core_write');
|
420 |
|
452 |
return $this;
|
453 |
}
|
454 |
|
455 |
+
public function PaymentMethod() {
|
456 |
+
|
457 |
+
}
|
458 |
+
|
459 |
+
private function getConstrains($paymentMethod) {
|
460 |
+
|
461 |
+
$constraints = array();
|
462 |
+
$opts = array(
|
463 |
+
-1 => array(''),
|
464 |
+
0 => array('sms'),
|
465 |
+
1 => array('bank'),
|
466 |
+
2 => array('card'),
|
467 |
+
3 => array('bank', 'sms'),
|
468 |
+
4 => array('card', 'sms'),
|
469 |
+
5 => array('card', 'bank'),
|
470 |
+
6 => array('card', 'bank', 'sms'),
|
471 |
+
7 => array(''),
|
472 |
+
8 => array('invoice'),
|
473 |
+
9 => array('invoice', 'sms'),
|
474 |
+
10 => array('invoice', 'bank'),
|
475 |
+
11 => array('invoice', 'card'),
|
476 |
+
12 => array('invoice', 'bank', 'sms'),
|
477 |
+
13 => array('invoice', 'card', 'sms'),
|
478 |
+
14 => array('invoice', 'card', 'bank'),
|
479 |
+
15 => array('invoice', 'card', 'bank', 'sms'),
|
480 |
+
);
|
481 |
+
$optsStrings = array('' => FundingConstraint::NONE, 'bank' => FundingConstraint::BANK, 'card' => FundingConstraint::CREDITCARD, 'invoice' => FundingConstraint::INVOICE, 'sms' => FundingConstraint::SMS);
|
482 |
+
if ($opts[$paymentMethod]) {
|
483 |
+
foreach ($opts[$paymentMethod] as $methodStringName) {
|
484 |
+
$constraints[] = $optsStrings[$methodStringName];
|
485 |
+
}
|
486 |
+
}
|
487 |
+
return $constraints;
|
488 |
+
}
|
489 |
+
|
490 |
/**
|
491 |
* Implements the IPN procedure
|
492 |
*
|
496 |
* @param string $content_type
|
497 |
* @return object $this
|
498 |
*/
|
|
|
|
|
499 |
public function Validate($http_body, $content_type) {
|
500 |
|
501 |
// Parse request done by Payson to our IPN controller
|
509 |
$order_table = $resource->getTableName('payson_order');
|
510 |
$order_log_table = $resource->getTableName('payson_order_log');
|
511 |
|
512 |
+
|
513 |
/* Save data sent by Payson, log entry as invalid by default, this
|
514 |
value will be changed later in this method if successful. No payson
|
515 |
order id is set, because we dont have one yet */
|
523 |
|
524 |
$order_log_id = $db->lastInsertId();
|
525 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
526 |
/* Save fetch mode so that we can reset it and not mess up Magento
|
527 |
functionality */
|
528 |
$old_fetch_mode = $db->getFetchMode();
|
603 |
|
604 |
/* Verify payment amount. floor() since there might be a precision
|
605 |
difference */
|
|
|
|
|
|
|
|
|
606 |
|
607 |
switch ($ipn_response->status) {
|
608 |
case self::STATUS_COMPLETED: {
|
639 |
$order->save();
|
640 |
|
641 |
|
642 |
+
|
643 |
if (isset($ipn_response->shippingAddress)) {
|
644 |
$address_info = $ipn_response->shippingAddress
|
645 |
->ToArray();
|
665 |
}
|
666 |
|
667 |
if (isset($address_info['country'])) {
|
668 |
+
|
669 |
$foo = array
|
670 |
(
|
671 |
'afghanistan' => 'AF',
|
923 |
'Payson updated the shipping address')));
|
924 |
}
|
925 |
} else {
|
|
|
|
|
926 |
$order['payson_invoice_fee']= 0;
|
927 |
$order['base_payson_invoice_fee']=0;
|
928 |
+
$order->addStatusHistoryComment(sprintf(
|
929 |
+
$this->_helper->__('Payson pinged the order with status %s'), $ipn_response->status));
|
930 |
}
|
931 |
|
932 |
break;
|
936 |
|
937 |
$order->cancel();
|
938 |
|
939 |
+
|
940 |
$order->addStatusHistoryComment($this->_helper->__('The order was denied by Payson.'));
|
941 |
|
942 |
break;
|
943 |
|
944 |
case self::STATUS_INCOMPLETE:
|
945 |
case self::STATUS_EXPIRED:
|
946 |
+
$order->cancel();
|
947 |
+
|
948 |
+
$order->addStatusHistoryComment($this->_helper->__('The order was not completed within allocated time'));
|
949 |
case self::STATUS_REVERSALERROR:
|
950 |
default: {
|
951 |
$order->cancel();
|
953 |
}
|
954 |
|
955 |
$order->save();
|
|
|
|
|
956 |
$db->update($order_log_table, array
|
957 |
(
|
958 |
'valid' => 1
|
969 |
'id = ?' => $payson_order->id
|
970 |
));
|
971 |
|
972 |
+
|
973 |
return $this;
|
974 |
}
|
975 |
|
987 |
|
988 |
$order_table = $resource->getTableName('payson_order');
|
989 |
$order_log_table = $resource->getTableName('payson_order_log');
|
|
|
990 |
/* Save fetch mode so that we can reset it and not mess up Magento
|
991 |
functionality */
|
992 |
$old_fetch_mode = $db->getFetchMode();
|
1080 |
LIMIT
|
1081 |
0,1', $order_id);
|
1082 |
|
1083 |
+
|
1084 |
+
|
1085 |
+
try {
|
1086 |
+
$payson_order !== false;
|
1087 |
+
} catch (Exception $e) {
|
1088 |
+
Mage::throwException('Invalid order id (' . $order_id . ')' . $e->getMessage());
|
1089 |
}
|
1090 |
|
1091 |
$db->setFetchMode($old_fetch_mode);
|
1141 |
array_push($stack, self::DEBUG_MODE ? "Payment" : "1.0");
|
1142 |
|
1143 |
array_push($stack, self::DEBUG_MODE ? "" : "Payment");
|
1144 |
+
//print_r($stack);
|
1145 |
return $stack;
|
1146 |
}
|
1147 |
|
app/code/community/Payson/Payson/Helper/FundingConstraint.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
CHANGED
@@ -42,6 +42,7 @@ class Payson_Payson_Model_Config {
|
|
42 |
*
|
43 |
* @return void
|
44 |
*/
|
|
|
45 |
public function __construct() {
|
46 |
$this->SetDefaultStoreId(Mage::app()->getStore()->getId());
|
47 |
}
|
@@ -53,6 +54,7 @@ class Payson_Payson_Model_Config {
|
|
53 |
* @return object $this
|
54 |
*/
|
55 |
public function SetDefaultStoreId($store) {
|
|
|
56 |
$this->default_store_id = $store;
|
57 |
|
58 |
return $this;
|
@@ -64,6 +66,7 @@ class Payson_Payson_Model_Config {
|
|
64 |
* @return int
|
65 |
*/
|
66 |
public function GetDefaultStoreId() {
|
|
|
67 |
return $this->default_store_id;
|
68 |
}
|
69 |
|
@@ -91,7 +94,6 @@ class Payson_Payson_Model_Config {
|
|
91 |
}
|
92 |
|
93 |
$name = $prefix . $name;
|
94 |
-
// Mage::getStoreConfigFlag
|
95 |
$value = Mage::getStoreConfig($name, $store);
|
96 |
|
97 |
return (isset($value) ? $value : $default);
|
@@ -152,7 +154,6 @@ class Payson_Payson_Model_Config {
|
|
152 |
$tax_calc = Mage::getSingleton('tax/calculation');
|
153 |
$customer = Mage::getModel('customer/customer')
|
154 |
->load($order->getCustomerId());
|
155 |
-
|
156 |
$tax_class = $this->GetConfig('invoice_fee_tax', $store->getId(), 0, 'payment/payson_invoice/');
|
157 |
|
158 |
$tax_rate_req = $tax_calc->getRateRequest(
|
@@ -176,29 +177,25 @@ class Payson_Payson_Model_Config {
|
|
176 |
return (bool) $this->GetConfig(self::PAYMENT_GUARANTEE, $store, false);
|
177 |
}
|
178 |
|
179 |
-
|
180 |
-
* Is
|
181 |
*
|
182 |
* @param int|null $store [optional]
|
183 |
* @return bool
|
184 |
*/
|
185 |
-
public function CanStandardPayment($store = null) {
|
186 |
-
return $this->GetConfig('active', $store, false, 'payment/payson_standard/');
|
187 |
-
}
|
188 |
|
|
|
|
|
|
|
|
|
189 |
/**
|
190 |
-
* Is
|
191 |
*
|
192 |
* @param int|null $store [optional]
|
193 |
* @return bool
|
194 |
-
*/
|
195 |
-
public function
|
196 |
-
|
197 |
-
{
|
198 |
-
return false;
|
199 |
-
} */
|
200 |
-
|
201 |
-
return $this->GetConfig('active', $store, false, 'payment/payson_invoice/');
|
202 |
}
|
203 |
|
204 |
public function restoreCartOnCancel($store = null) {
|
42 |
*
|
43 |
* @return void
|
44 |
*/
|
45 |
+
|
46 |
public function __construct() {
|
47 |
$this->SetDefaultStoreId(Mage::app()->getStore()->getId());
|
48 |
}
|
54 |
* @return object $this
|
55 |
*/
|
56 |
public function SetDefaultStoreId($store) {
|
57 |
+
|
58 |
$this->default_store_id = $store;
|
59 |
|
60 |
return $this;
|
66 |
* @return int
|
67 |
*/
|
68 |
public function GetDefaultStoreId() {
|
69 |
+
|
70 |
return $this->default_store_id;
|
71 |
}
|
72 |
|
94 |
}
|
95 |
|
96 |
$name = $prefix . $name;
|
|
|
97 |
$value = Mage::getStoreConfig($name, $store);
|
98 |
|
99 |
return (isset($value) ? $value : $default);
|
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(
|
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) {
|
app/code/community/Payson/Payson/Model/Method/Abstract.php
CHANGED
@@ -90,8 +90,12 @@ abstract class Payson_Payson_Model_Method_Abstract extends Mage_Payment_Model_Me
|
|
90 |
$helper = Mage::helper('payson');
|
91 |
$order_id = $order->getData('increment_id');
|
92 |
$api = Mage::helper('payson/api');
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
95 |
Payson_Payson_Helper_Api::UPDATE_ACTION_CREDITORDER :
|
96 |
Payson_Payson_Helper_Api::UPDATE_ACTION_REFUNDORDER);
|
97 |
|
@@ -122,6 +126,8 @@ abstract class Payson_Payson_Model_Method_Abstract extends Mage_Payment_Model_Me
|
|
122 |
$api->PaymentDetails($order_id);
|
123 |
$details = $api->GetResponse();
|
124 |
|
|
|
|
|
125 |
if (($details->type === Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE) ||
|
126 |
($details->invoiceStatus === Payson_Payson_Helper_Api::INVOICE_STATUS_ORDERCREATED) ||
|
127 |
($details->type !== Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE && $details->status === Payson_Payson_Helper_Api::STATUS_CREATED) ||
|
@@ -133,32 +139,10 @@ abstract class Payson_Payson_Model_Method_Abstract extends Mage_Payment_Model_Me
|
|
133 |
|
134 |
$payment->setTransactionId('auth')
|
135 |
->setIsTransactionClosed(1);
|
136 |
-
//->setShouldCloseParentTransaction(1);
|
137 |
} else {
|
138 |
Mage::throwException($helper->__('Payson is not ready to cancel the order. Please try again later.'));
|
139 |
}
|
140 |
-
|
141 |
return $this;
|
142 |
}
|
143 |
|
144 |
-
/**
|
145 |
-
* Is run when payment method is selected
|
146 |
-
*
|
147 |
-
* @return void
|
148 |
-
*/
|
149 |
-
/* public function validate()
|
150 |
-
{
|
151 |
-
$session = Mage::getSingleton('checkout/session');
|
152 |
-
|
153 |
-
if(isset($_POST['payment']['method']))
|
154 |
-
{
|
155 |
-
$session->setData('payson_payment_method',
|
156 |
-
$_POST['payment']['method']);
|
157 |
-
}
|
158 |
-
else
|
159 |
-
{
|
160 |
-
$session->unsetData('payson_payment_method');
|
161 |
-
}
|
162 |
-
} */
|
163 |
}
|
164 |
-
|
90 |
$helper = Mage::helper('payson');
|
91 |
$order_id = $order->getData('increment_id');
|
92 |
$api = Mage::helper('payson/api');
|
93 |
+
if ($method == "payson_standard") {
|
94 |
+
$paysonPaymethod = $method;
|
95 |
+
}if ($method == "payson_invoice") {
|
96 |
+
$paysonPaymethod = $method;
|
97 |
+
}
|
98 |
+
$api->PaymentUpdate($order_id, $paysonPaymethod ?
|
99 |
Payson_Payson_Helper_Api::UPDATE_ACTION_CREDITORDER :
|
100 |
Payson_Payson_Helper_Api::UPDATE_ACTION_REFUNDORDER);
|
101 |
|
126 |
$api->PaymentDetails($order_id);
|
127 |
$details = $api->GetResponse();
|
128 |
|
129 |
+
|
130 |
+
|
131 |
if (($details->type === Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE) ||
|
132 |
($details->invoiceStatus === Payson_Payson_Helper_Api::INVOICE_STATUS_ORDERCREATED) ||
|
133 |
($details->type !== Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE && $details->status === Payson_Payson_Helper_Api::STATUS_CREATED) ||
|
139 |
|
140 |
$payment->setTransactionId('auth')
|
141 |
->setIsTransactionClosed(1);
|
|
|
142 |
} else {
|
143 |
Mage::throwException($helper->__('Payson is not ready to cancel the order. Please try again later.'));
|
144 |
}
|
|
|
145 |
return $this;
|
146 |
}
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
|
app/code/community/Payson/Payson/Model/Method/Invoice.php
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Method_Invoice extends Payson_Payson_Model_Method_Abstract {
|
4 |
-
/*
|
5 |
-
* Protected properties
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* @inheritDoc
|
10 |
-
*/
|
11 |
-
protected $_code = 'payson_invoice';
|
12 |
-
protected $_formBlockType = 'payson/invoice_form';
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @inheritDoc
|
16 |
-
*/
|
17 |
-
protected $_canCapture = true;
|
18 |
-
protected $_canRefund = true;
|
19 |
-
protected $_canVoid = true;
|
20 |
-
//protected $_canUseCheckout = true;
|
21 |
-
private $invoiceAmountMinLimit = 30;
|
22 |
-
|
23 |
-
/*
|
24 |
-
* Public methods
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @inheritDoc
|
29 |
-
*/
|
30 |
-
public function capture(Varien_Object $payment, $amount) {
|
31 |
-
$order = $payment->getOrder();
|
32 |
-
$order_id = $order->getData('increment_id');
|
33 |
-
|
34 |
-
$api = Mage::helper('payson/api');
|
35 |
-
$helper = Mage::helper('payson');
|
36 |
-
$api->PaymentDetails($order_id);
|
37 |
-
$details = $api->GetResponse();
|
38 |
-
|
39 |
-
if (($details->type ===
|
40 |
-
Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE) ||
|
41 |
-
($details->invoiceStatus ===
|
42 |
-
Payson_Payson_Helper_Api::INVOICE_STATUS_ORDERCREATED)) {
|
43 |
-
$api->PaymentUpdate($order_id, Payson_Payson_Helper_Api::UPDATE_ACTION_SHIPORDER);
|
44 |
-
|
45 |
-
$order->addStatusHistoryComment($helper->__(
|
46 |
-
'Order was activated at Payson'));
|
47 |
-
} else {
|
48 |
-
Mage::throwException($helper->__('Payson is not ready to create an invoice. Please try again later.'));
|
49 |
-
}
|
50 |
-
|
51 |
-
return $this;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* @inheritDoc
|
56 |
-
*/
|
57 |
-
public function authorize(Varien_Object $payment, $amount) {
|
58 |
-
$payment->setTransactionId('auth')->setIsTransactionClosed(0);
|
59 |
-
|
60 |
-
return $this;
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* @inheritDoc
|
65 |
-
*/
|
66 |
-
public function getTitle() {
|
67 |
-
//if(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal() >> 30)
|
68 |
-
// echo Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal(); //$this->_canUseCheckout = false;
|
69 |
-
$order = Mage::registry('current_order');
|
70 |
-
|
71 |
-
if (!isset($order) && ($invoice = Mage::registry('current_invoice'))) {
|
72 |
-
$order = $invoice->getOrder();
|
73 |
-
}
|
74 |
-
|
75 |
-
if (isset($order)) {
|
76 |
-
$invoice_fee = $order->getPaysonInvoiceFee();
|
77 |
-
|
78 |
-
if ($invoice_fee) {
|
79 |
-
$invoice_fee = $order->formatPrice($invoice_fee);
|
80 |
-
}
|
81 |
-
} else {
|
82 |
-
$invoice_fee = Mage::getModel('payson/config')
|
83 |
-
->GetInvoiceFeeInclTax($this->getQuote());
|
84 |
-
|
85 |
-
if ($invoice_fee) {
|
86 |
-
$invoice_fee = Mage::app()->getStore()
|
87 |
-
->formatPrice($invoice_fee);
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
$invoice_fee = strip_tags($invoice_fee);
|
92 |
-
|
93 |
-
return sprintf(Mage::helper('payson')
|
94 |
-
->__('Checkout with Payson invoice %s invoice fee'), ($invoice_fee ? '+' . $invoice_fee : ''));
|
95 |
-
}
|
96 |
-
|
97 |
-
public function canUseCheckout() {
|
98 |
-
if ($this->isSweden()) {
|
99 |
-
if (strtoupper(Mage::app()->getStore()->getCurrentCurrencyCode()) != 'SEK')
|
100 |
-
return false;
|
101 |
-
if (Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal() < $this->invoiceAmountMinLimit)
|
102 |
-
return false;
|
103 |
-
else
|
104 |
-
return true;
|
105 |
-
}
|
106 |
-
return false;
|
107 |
-
}
|
108 |
-
|
109 |
-
public function isSweden() {
|
110 |
-
$checkout = Mage::getSingleton('checkout/session')->getQuote();
|
111 |
-
$billing = $checkout->getBillingAddress();
|
112 |
-
if (strtoupper($billing->getCountry()) != 'SE')
|
113 |
-
return false;
|
114 |
-
else
|
115 |
-
return true;
|
116 |
-
}
|
117 |
-
|
118 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Payson/Payson/Model/Method/Standard.php
CHANGED
@@ -23,7 +23,35 @@ class Payson_Payson_Model_Method_Standard extends Payson_Payson_Model_Method_Abs
|
|
23 |
* @inheritDoc
|
24 |
*/
|
25 |
public function getTitle() {
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
@@ -34,6 +62,18 @@ class Payson_Payson_Model_Method_Standard extends Payson_Payson_Model_Method_Abs
|
|
34 |
|
35 |
return $this;
|
36 |
}
|
|
|
|
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
|
23 |
* @inheritDoc
|
24 |
*/
|
25 |
public function getTitle() {
|
26 |
+
$this->_config = Mage::getModel('payson/config');
|
27 |
+
$order = Mage::registry('current_order');
|
28 |
+
if (!isset($order) && ($invoice = Mage::registry('current_invoice'))) {
|
29 |
+
$order = $invoice->getOrder();
|
30 |
+
}
|
31 |
+
|
32 |
+
if (isset($order)) {
|
33 |
+
$invoice_fee = $order->getPaysonInvoiceFee();
|
34 |
+
|
35 |
+
if ($invoice_fee) {
|
36 |
+
$invoice_fee = $order->formatPrice($invoice_fee);
|
37 |
+
}
|
38 |
+
} else {
|
39 |
+
$invoice_fee = Mage::getModel('payson/config')
|
40 |
+
->GetInvoiceFeeInclTax($this->getQuote());
|
41 |
+
|
42 |
+
if ($invoice_fee) {
|
43 |
+
$invoice_fee = Mage::app()->getStore()
|
44 |
+
->formatPrice($invoice_fee);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$invoice_fee = strip_tags($invoice_fee);
|
49 |
+
if($this->_config->CanInvoicePayment()){
|
50 |
+
return sprintf(Mage::helper('payson')->__('Checkout with Payson. If invoice is choosen as payment method an %s invoice fee will be added.'), ($invoice_fee));
|
51 |
+
}else{
|
52 |
+
return Mage::helper('payson')->__('Checkout with Payson');
|
53 |
+
}
|
54 |
+
|
55 |
}
|
56 |
|
57 |
/**
|
62 |
|
63 |
return $this;
|
64 |
}
|
65 |
+
public function canUseCheckout() {
|
66 |
+
$this->_config = Mage::getModel('payson/config');
|
67 |
|
68 |
+
if ($this->_config->CanInvoicePayment()){
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
if($this->_config->CanStandardPayment()){
|
72 |
+
return true;
|
73 |
+
}else{
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
|
79 |
+
}
|
app/code/community/Payson/Payson/Model/Order/Creditmemo/Total/Invoice.php
CHANGED
@@ -4,20 +4,17 @@ class Payson_Payson_Model_Order_Creditmemo_Total_Invoice extends
|
|
4 |
Mage_Sales_Model_Order_Creditmemo_Total_Abstract {
|
5 |
|
6 |
protected $_code = 'payson_invoice';
|
7 |
-
|
8 |
public function collect(Mage_Sales_Model_Order_Creditmemo $invoice) {
|
9 |
$order = $invoice->getOrder();
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
14 |
return $this;
|
15 |
}
|
16 |
-
|
17 |
-
/* if($order->hasInvoices() !== 0)
|
18 |
-
{
|
19 |
-
return $this;
|
20 |
-
} */
|
21 |
|
22 |
$base_fee = $order->getBasePaysonInvoiceFee();
|
23 |
$fee = $order->getPaysonInvoiceFee();
|
4 |
Mage_Sales_Model_Order_Creditmemo_Total_Abstract {
|
5 |
|
6 |
protected $_code = 'payson_invoice';
|
|
|
7 |
public function collect(Mage_Sales_Model_Order_Creditmemo $invoice) {
|
8 |
$order = $invoice->getOrder();
|
9 |
+
$this->_config = Mage::getModel('payson/config');
|
10 |
+
$method = $order->getPayment()->getMethod();
|
11 |
|
12 |
+
if(!$this->_config->CanInvoicePayment()){
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
if ($method !== 'payson_standard') {
|
16 |
return $this;
|
17 |
}
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
$base_fee = $order->getBasePaysonInvoiceFee();
|
20 |
$fee = $order->getPaysonInvoiceFee();
|
app/code/community/Payson/Payson/Model/Order/Invoice/Total/Invoice.php
CHANGED
@@ -2,18 +2,18 @@
|
|
2 |
|
3 |
class Payson_Payson_Model_Order_Invoice_Total_Invoice extends
|
4 |
Mage_Sales_Model_Order_Invoice_Total_Abstract {
|
5 |
-
|
6 |
-
protected $_code = '
|
7 |
-
|
8 |
public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
|
9 |
$order = $invoice->getOrder();
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
return $this;
|
15 |
}
|
16 |
-
|
17 |
if ($order->hasInvoices() == 0) {
|
18 |
return $this;
|
19 |
}
|
@@ -40,4 +40,3 @@ Mage_Sales_Model_Order_Invoice_Total_Abstract {
|
|
40 |
}
|
41 |
|
42 |
}
|
43 |
-
|
2 |
|
3 |
class Payson_Payson_Model_Order_Invoice_Total_Invoice extends
|
4 |
Mage_Sales_Model_Order_Invoice_Total_Abstract {
|
5 |
+
|
6 |
+
protected $_code = 'payson_standard';
|
|
|
7 |
public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
|
8 |
$order = $invoice->getOrder();
|
9 |
+
$this->_config = Mage::getModel('payson/config');
|
10 |
+
if (!$this->_config->CanInvoicePayment()) {
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
$method = $order->getPayment()->getMethodInstance()->getCode();
|
14 |
+
if ($method !== 'payson_standard') {
|
15 |
return $this;
|
16 |
}
|
|
|
17 |
if ($order->hasInvoices() == 0) {
|
18 |
return $this;
|
19 |
}
|
40 |
}
|
41 |
|
42 |
}
|
|
app/code/community/Payson/Payson/Model/Quote/Address/Total/Invoice.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Payson_Payson_Model_Quote_Address_Total_Invoice extends
|
4 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract {
|
5 |
|
6 |
protected $_code = 'payson_invoice';
|
7 |
|
@@ -9,31 +8,29 @@ Mage_Sales_Model_Quote_Address_Total_Abstract {
|
|
9 |
if ($address->getAddressType() !== 'shipping') {
|
10 |
return $this;
|
11 |
}
|
12 |
-
|
13 |
$address->setBasePaysonInvoiceFee(0);
|
14 |
$address->setPaysonInvoiceFee(0);
|
15 |
-
|
16 |
$quote = $address->getQuote();
|
17 |
-
|
|
|
18 |
if (is_null($quote->getId())) {
|
19 |
return $this;
|
20 |
}
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
if ($method !== '
|
25 |
return $this;
|
26 |
}
|
27 |
|
|
|
28 |
$store = $quote->getStore();
|
29 |
$config = Mage::getModel('payson/config');
|
30 |
|
31 |
$fee = $config->GetInvoiceFeeInclTax($quote);
|
32 |
|
33 |
$base_grand_total = $address->getBaseGrandTotal();
|
34 |
-
$base_grand_total += $fee;
|
35 |
-
|
36 |
-
// TODO: update tax in another model?
|
37 |
|
38 |
$address->setBasePaysonInvoiceFee($fee);
|
39 |
$address->setPaysonInvoiceFee($store->convertPrice($fee, false));
|
@@ -41,24 +38,7 @@ Mage_Sales_Model_Quote_Address_Total_Abstract {
|
|
41 |
$address->setBaseGrandTotal($base_grand_total);
|
42 |
$address->setGrandTotal($store->convertPrice($base_grand_total, false));
|
43 |
|
44 |
-
//$this->_addBaseAmount($fee);
|
45 |
-
//$this->_addAmount($fee);
|
46 |
-
|
47 |
-
return $this;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function fetch(Mage_Sales_Model_Quote_Address $address) {
|
51 |
-
if (($fee = $address->getPaysonInvoiceFee()) > 0) {
|
52 |
-
$address->addTotal(array
|
53 |
-
(
|
54 |
-
'code' => $this->getCode(),
|
55 |
-
'title' => Mage::helper('payson')->__('Invoice fee'),
|
56 |
-
'value' => $fee
|
57 |
-
));
|
58 |
-
}
|
59 |
-
|
60 |
return $this;
|
61 |
}
|
62 |
|
63 |
}
|
64 |
-
|
1 |
<?php
|
2 |
|
3 |
+
class Payson_Payson_Model_Quote_Address_Total_Invoice extends Mage_Sales_Model_Quote_Address_Total_Abstract {
|
|
|
4 |
|
5 |
protected $_code = 'payson_invoice';
|
6 |
|
8 |
if ($address->getAddressType() !== 'shipping') {
|
9 |
return $this;
|
10 |
}
|
11 |
+
$this->_config = Mage::getModel('payson/config');
|
12 |
$address->setBasePaysonInvoiceFee(0);
|
13 |
$address->setPaysonInvoiceFee(0);
|
|
|
14 |
$quote = $address->getQuote();
|
15 |
+
|
16 |
+
$method = $address->getQuote()->getPayment()->getMethod();
|
17 |
if (is_null($quote->getId())) {
|
18 |
return $this;
|
19 |
}
|
20 |
+
if (!$this->_config->CanInvoicePayment()) {
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
if ($method !== 'payson_standard') {
|
24 |
return $this;
|
25 |
}
|
26 |
|
27 |
+
|
28 |
$store = $quote->getStore();
|
29 |
$config = Mage::getModel('payson/config');
|
30 |
|
31 |
$fee = $config->GetInvoiceFeeInclTax($quote);
|
32 |
|
33 |
$base_grand_total = $address->getBaseGrandTotal();
|
|
|
|
|
|
|
34 |
|
35 |
$address->setBasePaysonInvoiceFee($fee);
|
36 |
$address->setPaysonInvoiceFee($store->convertPrice($fee, false));
|
38 |
$address->setBaseGrandTotal($base_grand_total);
|
39 |
$address->setGrandTotal($store->convertPrice($base_grand_total, false));
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
return $this;
|
42 |
}
|
43 |
|
44 |
}
|
|
app/code/community/Payson/Payson/Model/Standard.php
CHANGED
@@ -47,7 +47,6 @@ class Payson_Payson_Model_Standard extends Mage_Payment_Model_Method_Abstract {
|
|
47 |
$state_object->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
48 |
$state_object->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
49 |
$state_object->setIsNotified(false);
|
50 |
-
|
51 |
return $this;
|
52 |
}
|
53 |
|
@@ -92,27 +91,16 @@ class Payson_Payson_Model_Standard extends Mage_Payment_Model_Method_Abstract {
|
|
92 |
return Mage::getModel('payson/config')->IsCurrencySupported($currency);
|
93 |
}
|
94 |
|
95 |
-
/**
|
96 |
-
* Is run when payment method is selected
|
97 |
-
*
|
98 |
-
* @return void
|
99 |
-
*/
|
100 |
-
public function validate() {
|
101 |
-
$session = Mage::getSingleton('checkout/session');
|
102 |
-
|
103 |
-
if (isset($_POST['payment']['payson_payment_method'])) {
|
104 |
-
$session->setData('payson_payment_method', $_POST['payment']['payson_payment_method']);
|
105 |
-
} else {
|
106 |
-
$session->unsetData('payson_payment_method');
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
/**
|
111 |
* @inheritDoc
|
112 |
*/
|
113 |
public function getTitle() {
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
116 |
|
117 |
}
|
118 |
-
|
47 |
$state_object->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
48 |
$state_object->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
49 |
$state_object->setIsNotified(false);
|
|
|
50 |
return $this;
|
51 |
}
|
52 |
|
91 |
return Mage::getModel('payson/config')->IsCurrencySupported($currency);
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/**
|
95 |
* @inheritDoc
|
96 |
*/
|
97 |
public function getTitle() {
|
98 |
+
|
99 |
+
if ($this->_config->CanStandardPayment()) {
|
100 |
+
return sprintf(Mage::helper('payson')->__('Checkout with Payson. If invoice is choosen as payment method an %s invoice fee will be added.'));
|
101 |
+
} elseif ($this->_config->CanStandardPayment()) {
|
102 |
+
return Mage::helper('payson')->__('Checkout with Payson');
|
103 |
+
}
|
104 |
}
|
105 |
|
106 |
}
|
|
app/code/community/Payson/Payson/Model/System/Config/Source/Paysondirectmethod.php
CHANGED
@@ -1,25 +1,52 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* My own options
|
4 |
*
|
5 |
*/
|
6 |
-
|
7 |
-
{
|
8 |
|
9 |
/**
|
10 |
* Options getter
|
11 |
*
|
12 |
* @return array
|
|
|
13 |
*/
|
14 |
-
|
15 |
-
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
}
|
24 |
-
|
25 |
-
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* My own options
|
5 |
*
|
6 |
*/
|
7 |
+
|
8 |
+
class Payson_Payson_Model_System_Config_Source_Paysondirectmethod {
|
9 |
|
10 |
/**
|
11 |
* Options getter
|
12 |
*
|
13 |
* @return array
|
14 |
+
*
|
15 |
*/
|
16 |
+
|
17 |
+
public function toOptionArray() {
|
18 |
+
|
19 |
+
$this->_config = Mage::getModel('payson/config');
|
20 |
+
|
21 |
+
|
22 |
+
$paysonInvoice = array(
|
23 |
+
array('value' => 7, 'label' => Mage::helper('adminhtml')->__('')),
|
24 |
+
array('value' => 8, 'label' => Mage::helper('adminhtml')->__('INVOICE')),
|
25 |
+
array('value' => 9, 'label' => Mage::helper('adminhtml')->__('INVOICE / SMS')),
|
26 |
+
array('value' => 10, 'label' => Mage::helper('adminhtml')->__('INVOICE / BANK')),
|
27 |
+
array('value' => 11, 'label' => Mage::helper('adminhtml')->__('INVOICE / CREDITCARD')),
|
28 |
+
array('value' => 12, 'label' => Mage::helper('adminhtml')->__('INVOICE / BANK / SMS')),
|
29 |
+
array('value' => 13, 'label' => Mage::helper('adminhtml')->__('INVOICE / CREDITCARD / SMS')),
|
30 |
+
array('value' => 14, 'label' => Mage::helper('adminhtml')->__('INVOICE / CREDITCARD / BANK')),
|
31 |
+
array('value' => 15, 'label' => Mage::helper('adminhtml')->__('INVOICE / CREDITCARD / BANK / SMS'))
|
32 |
+
|
33 |
);
|
34 |
+
$paysonDirect = array(
|
35 |
+
array('value' => -1, 'label' => Mage::helper('adminhtml')->__('')),
|
36 |
+
array('value' => 0, 'label' => Mage::helper('adminhtml')->__('SMS')),
|
37 |
+
array('value' => 1, 'label' => Mage::helper('adminhtml')->__('BANK')),
|
38 |
+
array('value' => 2, 'label' => Mage::helper('adminhtml')->__('CREDITCARD')),
|
39 |
+
array('value' => 3, 'label' => Mage::helper('adminhtml')->__('BANK / SMS')),
|
40 |
+
array('value' => 4, 'label' => Mage::helper('adminhtml')->__('CREDITCARD / SMS')),
|
41 |
+
array('value' => 5, 'label' => Mage::helper('adminhtml')->__('CREDITCARD / BANK')),
|
42 |
+
array('value' => 6, 'label' => Mage::helper('adminhtml')->__('CREDITCARD / BANK / SMS'))
|
43 |
+
|
44 |
+
);
|
45 |
+
if ($this->_config->CanInvoicePayment()) {
|
46 |
+
return $paysonInvoice;
|
47 |
+
} elseif ($this->_config->CanStandardPayment()) {
|
48 |
+
return $paysonDirect;
|
49 |
+
}
|
50 |
}
|
51 |
|
52 |
}
|
|
|
|
app/code/community/Payson/Payson/controllers/Adminhtml/Sales/Order/ShipmentController.php
CHANGED
@@ -7,20 +7,19 @@ class Payson_Payson_Adminhtml_Sales_Order_ShipmentController extends Mage_Adminh
|
|
7 |
public function saveAction() {
|
8 |
|
9 |
$order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'));
|
10 |
-
|
11 |
-
if ($order->getPayment()->getMethodInstance()->getCode() == "
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
}
|
20 |
-
|
21 |
-
parent::saveAction();
|
22 |
}
|
23 |
|
24 |
}
|
25 |
-
|
26 |
-
?>
|
7 |
public function saveAction() {
|
8 |
|
9 |
$order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'));
|
10 |
+
|
11 |
+
if ($order->getPayment()->getMethodInstance()->getCode() == "payson_standard") {
|
12 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
13 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
14 |
+
$invoice->register();
|
15 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
16 |
+
->addObject($invoice)
|
17 |
+
->addObject($invoice->getOrder());
|
18 |
+
$transactionSave->save();
|
19 |
+
|
20 |
+
|
21 |
+
parent::saveAction();
|
22 |
}
|
|
|
|
|
23 |
}
|
24 |
|
25 |
}
|
|
|
|
app/code/community/Payson/Payson/controllers/CheckoutController.php
CHANGED
@@ -69,9 +69,7 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
69 |
return $this;
|
70 |
}
|
71 |
|
72 |
-
|
73 |
-
* Public methods
|
74 |
-
*/
|
75 |
|
76 |
public function redirectAction() {
|
77 |
|
@@ -104,49 +102,69 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
104 |
$this->_redirect('checkout/cart');
|
105 |
}
|
106 |
}
|
107 |
-
|
108 |
public function returnAction() {
|
109 |
-
|
110 |
$order = $this->getOrder();
|
111 |
-
|
112 |
$paymentDetailsResponse = Mage::helper('payson/api')->PaymentDetails(Mage::getSingleton('checkout/session')->getLastRealOrderId())->getResponse();
|
113 |
$paymentStatus = $paymentDetailsResponse->status;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
switch ($paymentStatus) {
|
115 |
case 'COMPLETED':
|
116 |
case 'PENDING':
|
117 |
case 'PROCESSING':
|
118 |
case 'CREDITED': {
|
119 |
-
|
|
|
120 |
if ($paymentDetailsResponse->type !== 'INVOICE' && $paymentDetailsResponse->status === 'COMPLETED') {
|
121 |
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
122 |
$order->sendNewOrderEmail()->save();
|
|
|
|
|
|
|
123 |
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
124 |
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
125 |
$invoice->register();
|
126 |
$transactionSave = Mage::getModel('core/resource_transaction')
|
127 |
->addObject($invoice)
|
128 |
->addObject($invoice->getOrder());
|
129 |
-
$transactionSave->save();
|
130 |
|
|
|
131 |
$this->_redirect('checkout/onepage/success');
|
132 |
break;
|
133 |
}
|
134 |
-
|
135 |
-
|
136 |
if ($paymentDetailsResponse->type !== 'INVOICE' && $paymentDetailsResponse->status === 'PROCESSING') {
|
137 |
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true);
|
138 |
Mage::getSingleton('core/session')->addError(sprintf(Mage::helper('payson')->__('Your payment is being processed by Payson')));
|
|
|
|
|
139 |
$this->_redirect('checkout/onepage/success');
|
140 |
break;
|
141 |
}
|
142 |
if ($paymentDetailsResponse->type !== 'INVOICE' && $paymentDetailsResponse->status === 'PENDING') {
|
143 |
Mage::getSingleton('core/session')->addError(sprintf(Mage::helper('payson')->__('Something went wrong with the payment. Please, try a different payment method')));
|
|
|
|
|
144 |
$this->_redirect('checkout/onepage/failure');
|
145 |
break;
|
146 |
}
|
147 |
-
|
|
|
148 |
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
149 |
$order->sendNewOrderEmail()->save();
|
|
|
|
|
|
|
|
|
150 |
$this->_redirect('checkout/onepage/success');
|
151 |
break;
|
152 |
}
|
@@ -155,7 +173,6 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
155 |
$errorMessage = Mage::helper('payson')->__('The payment was denied by Payson. Please, try a different payment method');
|
156 |
Mage::getSingleton('core/session')->addError($errorMessage);
|
157 |
$this->cancelOrder($errorMessage);
|
158 |
-
|
159 |
$this->_redirect('checkout');
|
160 |
break;
|
161 |
}
|
69 |
return $this;
|
70 |
}
|
71 |
|
72 |
+
|
|
|
|
|
73 |
|
74 |
public function redirectAction() {
|
75 |
|
102 |
$this->_redirect('checkout/cart');
|
103 |
}
|
104 |
}
|
|
|
105 |
public function returnAction() {
|
|
|
106 |
$order = $this->getOrder();
|
107 |
+
|
108 |
$paymentDetailsResponse = Mage::helper('payson/api')->PaymentDetails(Mage::getSingleton('checkout/session')->getLastRealOrderId())->getResponse();
|
109 |
$paymentStatus = $paymentDetailsResponse->status;
|
110 |
+
$paymentDetails=$paymentDetailsResponse->receiverList->receiver->ToArray();
|
111 |
+
$new_paymentDetails = array();
|
112 |
+
foreach ($paymentDetails as $item) {
|
113 |
+
foreach ($item as $key => $value) {
|
114 |
+
$new_paymentDetails[$key] = $value;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
$investigatefee = $order['base_payson_invoice_fee'];
|
119 |
+
$currentAmount = $new_paymentDetails['amount'];
|
120 |
+
$newAmount = $currentAmount += $investigatefee;
|
121 |
switch ($paymentStatus) {
|
122 |
case 'COMPLETED':
|
123 |
case 'PENDING':
|
124 |
case 'PROCESSING':
|
125 |
case 'CREDITED': {
|
126 |
+
|
127 |
+
|
128 |
if ($paymentDetailsResponse->type !== 'INVOICE' && $paymentDetailsResponse->status === 'COMPLETED') {
|
129 |
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
130 |
$order->sendNewOrderEmail()->save();
|
131 |
+
$order['payson_invoice_fee']= 0;
|
132 |
+
$order['base_payson_invoice_fee']=0;
|
133 |
+
|
134 |
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
135 |
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
136 |
$invoice->register();
|
137 |
$transactionSave = Mage::getModel('core/resource_transaction')
|
138 |
->addObject($invoice)
|
139 |
->addObject($invoice->getOrder());
|
|
|
140 |
|
141 |
+
$transactionSave->save();
|
142 |
$this->_redirect('checkout/onepage/success');
|
143 |
break;
|
144 |
}
|
|
|
|
|
145 |
if ($paymentDetailsResponse->type !== 'INVOICE' && $paymentDetailsResponse->status === 'PROCESSING') {
|
146 |
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true);
|
147 |
Mage::getSingleton('core/session')->addError(sprintf(Mage::helper('payson')->__('Your payment is being processed by Payson')));
|
148 |
+
$order['payson_invoice_fee']= 0;
|
149 |
+
$order['base_payson_invoice_fee']=0;
|
150 |
$this->_redirect('checkout/onepage/success');
|
151 |
break;
|
152 |
}
|
153 |
if ($paymentDetailsResponse->type !== 'INVOICE' && $paymentDetailsResponse->status === 'PENDING') {
|
154 |
Mage::getSingleton('core/session')->addError(sprintf(Mage::helper('payson')->__('Something went wrong with the payment. Please, try a different payment method')));
|
155 |
+
$order['payson_invoice_fee']= 0;
|
156 |
+
$order['base_payson_invoice_fee']=0;
|
157 |
$this->_redirect('checkout/onepage/failure');
|
158 |
break;
|
159 |
}
|
160 |
+
//Update the order with the true amount
|
161 |
+
if ($paymentDetailsResponse->type === 'INVOICE' && $paymentDetailsResponse->type !== 'TRANSFER') {
|
162 |
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
163 |
$order->sendNewOrderEmail()->save();
|
164 |
+
$order->setBaseGrandTotal($newAmount);
|
165 |
+
$order->setGrandTotal($newAmount);
|
166 |
+
$order->setTotalDue($newAmount);
|
167 |
+
$order->save();
|
168 |
$this->_redirect('checkout/onepage/success');
|
169 |
break;
|
170 |
}
|
173 |
$errorMessage = Mage::helper('payson')->__('The payment was denied by Payson. Please, try a different payment method');
|
174 |
Mage::getSingleton('core/session')->addError($errorMessage);
|
175 |
$this->cancelOrder($errorMessage);
|
|
|
176 |
$this->_redirect('checkout');
|
177 |
break;
|
178 |
}
|
app/code/community/Payson/Payson/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Payson_Payson>
|
5 |
-
<version>1.
|
6 |
</Payson_Payson>
|
7 |
</modules>
|
8 |
<admin>
|
@@ -160,7 +160,6 @@
|
|
160 |
<payment_action>authorize</payment_action>
|
161 |
<order_status>pending</order_status>
|
162 |
<invoice_fee_sek>0</invoice_fee_sek>
|
163 |
-
<invoice_fee_eur>0</invoice_fee_eur>
|
164 |
</payson_invoice>
|
165 |
</payment>
|
166 |
</default>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Payson_Payson>
|
5 |
+
<version>1.0.0</version>
|
6 |
</Payson_Payson>
|
7 |
</modules>
|
8 |
<admin>
|
160 |
<payment_action>authorize</payment_action>
|
161 |
<order_status>pending</order_status>
|
162 |
<invoice_fee_sek>0</invoice_fee_sek>
|
|
|
163 |
</payson_invoice>
|
164 |
</payment>
|
165 |
</default>
|
app/code/community/Payson/Payson/etc/system.xml
CHANGED
@@ -4,11 +4,12 @@
|
|
4 |
<payment>
|
5 |
<groups>
|
6 |
<payson_standard translate="label" module="payson">
|
7 |
-
<label>Payson</label>
|
|
|
8 |
<sort_order>-100</sort_order>
|
9 |
<show_in_default>1</show_in_default>
|
10 |
<show_in_website>1</show_in_website>
|
11 |
-
<show_in_store>1</show_in_store>
|
12 |
<fields>
|
13 |
<test_mode translate="label,comment">
|
14 |
<label>Test mode</label>
|
@@ -58,16 +59,16 @@
|
|
58 |
<show_in_website>0</show_in_website>
|
59 |
<show_in_store>0</show_in_store>
|
60 |
</md5_key>
|
61 |
-
<
|
62 |
<label>Please select the payment method</label>
|
63 |
-
<comment>
|
64 |
<frontend_type>select</frontend_type>
|
65 |
<source_model>payson/system_config_source_paysondirectmethod</source_model>
|
66 |
<sort_order>45</sort_order>
|
67 |
<show_in_default>1</show_in_default>
|
68 |
<show_in_website>1</show_in_website>
|
69 |
<show_in_store>1</show_in_store>
|
70 |
-
</
|
71 |
<payment_guarantee translate="label,comment">
|
72 |
<label>Enable payment guarantee</label>
|
73 |
<comment>Enable/disable payment guarantee.</comment>
|
@@ -77,7 +78,45 @@
|
|
77 |
<show_in_default>0</show_in_default>
|
78 |
<show_in_website>0</show_in_website>
|
79 |
<show_in_store>0</show_in_store>
|
80 |
-
</payment_guarantee>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
<restore_on_cancel translate="label,comment">
|
82 |
<label>Restore cart on cancel</label>
|
83 |
<comment>Restore cart when customer cancel the payment</comment>
|
@@ -111,14 +150,14 @@
|
|
111 |
</fields>
|
112 |
</payson_standard>
|
113 |
<payson_invoice translate="label" module="payson">
|
114 |
-
<label>Payson invoice</label>
|
115 |
<sort_order>-99</sort_order>
|
116 |
<show_in_default>1</show_in_default>
|
117 |
<show_in_website>1</show_in_website>
|
118 |
<show_in_store>1</show_in_store>
|
119 |
<comment><![CDATA[Payson Invoice requires a separate contract. Please contact Payson for more information<a href="http://payson.se" target="_blank">Click here</a>]]></comment>
|
120 |
<fields>
|
121 |
-
<
|
122 |
<label>Enabled</label>
|
123 |
<comment>Enable/disable invoice payment with Payson.</comment>
|
124 |
<frontend_type>select</frontend_type>
|
@@ -127,17 +166,7 @@
|
|
127 |
<show_in_default>1</show_in_default>
|
128 |
<show_in_website>1</show_in_website>
|
129 |
<show_in_store>1</show_in_store>
|
130 |
-
</
|
131 |
-
<!--<activate_invoice translate="label,comment">
|
132 |
-
<label>Activate invoice on purchase</label>
|
133 |
-
<comment>Enable this to send Payson invoice to customer instantly after purchase. Disabling this means you have to mark the goods as Shipped in Admin to activate the invoice</comment>
|
134 |
-
<frontend_type>select</frontend_type>
|
135 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
136 |
-
<sort_order>15</sort_order>
|
137 |
-
<show_in_default>1</show_in_default>
|
138 |
-
<show_in_website>1</show_in_website>
|
139 |
-
<show_in_store>1</show_in_store>
|
140 |
-
</activate_invoice>-->
|
141 |
<invoice_fee_tax translate="label,comment">
|
142 |
<label>Invoice fee tax</label>
|
143 |
<comment>Tax class for invoice fees.</comment>
|
@@ -156,30 +185,10 @@
|
|
156 |
<show_in_default>1</show_in_default>
|
157 |
<show_in_website>1</show_in_website>
|
158 |
<show_in_store>1</show_in_store>
|
159 |
-
</invoice_fee_sek>
|
160 |
-
<invoice_fee_eur translate="label,comment">
|
161 |
-
<label>Invoice fee (EUR)</label>
|
162 |
-
<comment>Invoice fee for EUR excluding tax.</comment>
|
163 |
-
<frontend_type>text</frontend_type>
|
164 |
-
<sort_order>40</sort_order>
|
165 |
-
<show_in_default>1</show_in_default>
|
166 |
-
<show_in_website>1</show_in_website>
|
167 |
-
<show_in_store>1</show_in_store>
|
168 |
-
</invoice_fee_eur>
|
169 |
-
|
170 |
-
<!--<invoice_minimum_amount translate="label,comment">
|
171 |
-
<label>Invoice minimum amount (SEK)</label>
|
172 |
-
<comment>Invoice minimum amount</comment>
|
173 |
-
<frontend_type>text</frontend_type>
|
174 |
-
<sort_order>42</sort_order>
|
175 |
-
<show_in_default>1</show_in_default>
|
176 |
-
<show_in_website>1</show_in_website>
|
177 |
-
<show_in_store>1</show_in_store>
|
178 |
-
</invoice_minimum_amount>-->
|
179 |
</fields>
|
180 |
-
</payson_invoice>
|
181 |
</groups>
|
182 |
</payment>
|
183 |
</sections>
|
184 |
</config>
|
185 |
-
|
4 |
<payment>
|
5 |
<groups>
|
6 |
<payson_standard translate="label" module="payson">
|
7 |
+
<label>Payson All in one Payment</label>
|
8 |
+
<comment><![CDATA[Payson Invoice requires a separate contract. Please contact Payson for more information<a href="http://payson.se" target="_blank">Click here</a>]]></comment>
|
9 |
<sort_order>-100</sort_order>
|
10 |
<show_in_default>1</show_in_default>
|
11 |
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
<fields>
|
14 |
<test_mode translate="label,comment">
|
15 |
<label>Test mode</label>
|
59 |
<show_in_website>0</show_in_website>
|
60 |
<show_in_store>0</show_in_store>
|
61 |
</md5_key>
|
62 |
+
<payson_All_in_one translate="label">
|
63 |
<label>Please select the payment method</label>
|
64 |
+
<comment>Choose your prefered Payson payment</comment>
|
65 |
<frontend_type>select</frontend_type>
|
66 |
<source_model>payson/system_config_source_paysondirectmethod</source_model>
|
67 |
<sort_order>45</sort_order>
|
68 |
<show_in_default>1</show_in_default>
|
69 |
<show_in_website>1</show_in_website>
|
70 |
<show_in_store>1</show_in_store>
|
71 |
+
</payson_All_in_one>
|
72 |
<payment_guarantee translate="label,comment">
|
73 |
<label>Enable payment guarantee</label>
|
74 |
<comment>Enable/disable payment guarantee.</comment>
|
78 |
<show_in_default>0</show_in_default>
|
79 |
<show_in_website>0</show_in_website>
|
80 |
<show_in_store>0</show_in_store>
|
81 |
+
</payment_guarantee>
|
82 |
+
<!--<active_invoice translate="label,comment">
|
83 |
+
<label>Enable Invoice</label>
|
84 |
+
<comment>Enable/disable invoice payment with Payson.</comment>
|
85 |
+
<frontend_type>select</frontend_type>
|
86 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
+
<sort_order>43</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>1</show_in_website>
|
90 |
+
<show_in_store>1</show_in_store>
|
91 |
+
</active_invoice>
|
92 |
+
<invoice_fee_tax translate="label,comment">
|
93 |
+
<label>Invoice fee tax</label>
|
94 |
+
<comment>Tax class for invoice fees.</comment>
|
95 |
+
<frontend_type>select</frontend_type>
|
96 |
+
<source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
|
97 |
+
<sort_order>50</sort_order>
|
98 |
+
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>1</show_in_store>
|
101 |
+
</invoice_fee_tax>
|
102 |
+
<invoice_fee_sek translate="label,comment">
|
103 |
+
<label>Invoice fee (SEK)</label>
|
104 |
+
<comment>Invoice fee for SEK excluding tax.</comment>
|
105 |
+
<frontend_type>text</frontend_type>
|
106 |
+
<sort_order>55</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>1</show_in_store>
|
110 |
+
</invoice_fee_sek>
|
111 |
+
<invoice_fee_eur translate="label,comment">
|
112 |
+
<label>Invoice fee (EUR)</label>
|
113 |
+
<comment>Invoice fee for EUR excluding tax.</comment>
|
114 |
+
<frontend_type>text</frontend_type>
|
115 |
+
<sort_order>60</sort_order>
|
116 |
+
<show_in_default>1</show_in_default>
|
117 |
+
<show_in_website>1</show_in_website>
|
118 |
+
<show_in_store>1</show_in_store>
|
119 |
+
</invoice_fee_eur>-->
|
120 |
<restore_on_cancel translate="label,comment">
|
121 |
<label>Restore cart on cancel</label>
|
122 |
<comment>Restore cart when customer cancel the payment</comment>
|
150 |
</fields>
|
151 |
</payson_standard>
|
152 |
<payson_invoice translate="label" module="payson">
|
153 |
+
<label>Payson invoice setup</label>
|
154 |
<sort_order>-99</sort_order>
|
155 |
<show_in_default>1</show_in_default>
|
156 |
<show_in_website>1</show_in_website>
|
157 |
<show_in_store>1</show_in_store>
|
158 |
<comment><![CDATA[Payson Invoice requires a separate contract. Please contact Payson for more information<a href="http://payson.se" target="_blank">Click here</a>]]></comment>
|
159 |
<fields>
|
160 |
+
<active_invoice translate="label,comment">
|
161 |
<label>Enabled</label>
|
162 |
<comment>Enable/disable invoice payment with Payson.</comment>
|
163 |
<frontend_type>select</frontend_type>
|
166 |
<show_in_default>1</show_in_default>
|
167 |
<show_in_website>1</show_in_website>
|
168 |
<show_in_store>1</show_in_store>
|
169 |
+
</active_invoice>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
<invoice_fee_tax translate="label,comment">
|
171 |
<label>Invoice fee tax</label>
|
172 |
<comment>Tax class for invoice fees.</comment>
|
185 |
<show_in_default>1</show_in_default>
|
186 |
<show_in_website>1</show_in_website>
|
187 |
<show_in_store>1</show_in_store>
|
188 |
+
</invoice_fee_sek>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
</fields>
|
190 |
+
</payson_invoice>
|
191 |
</groups>
|
192 |
</payment>
|
193 |
</sections>
|
194 |
</config>
|
|
app/code/community/Payson/Payson/etc/system.xml.bak
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<payson_standard translate="label" module="payson">
|
7 |
+
<label>Payson All in one Payment</label>
|
8 |
+
<comment><![CDATA[Payson Invoice requires a separate contract. Please contact Payson for more information<a href="http://payson.se" target="_blank">Click here</a>]]></comment>
|
9 |
+
<sort_order>-100</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<test_mode translate="label,comment">
|
15 |
+
<label>Test mode</label>
|
16 |
+
<comment>Enable/disable test mode.</comment>
|
17 |
+
<frontend_type>select</frontend_type>
|
18 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
19 |
+
<sort_order>5</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store>
|
23 |
+
</test_mode>
|
24 |
+
<active translate="label,comment">
|
25 |
+
<label>Enabled</label>
|
26 |
+
<comment>Enable/disable payment with Payson.</comment>
|
27 |
+
<frontend_type>select</frontend_type>
|
28 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
29 |
+
<sort_order>10</sort_order>
|
30 |
+
<show_in_default>1</show_in_default>
|
31 |
+
<show_in_website>1</show_in_website>
|
32 |
+
<show_in_store>1</show_in_store>
|
33 |
+
</active>
|
34 |
+
<email translate="label,comment">
|
35 |
+
<label>Email</label>
|
36 |
+
<comment>Email address bound to your Payson account.</comment>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<validate>validate-email</validate>
|
39 |
+
<sort_order>20</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>0</show_in_website>
|
42 |
+
<show_in_store>0</show_in_store>
|
43 |
+
</email>
|
44 |
+
<agent_id translate="label,comment">
|
45 |
+
<label>Agent ID</label>
|
46 |
+
<comment>Agent ID is found on your Payson profile page.</comment>
|
47 |
+
<frontend_type>text</frontend_type>
|
48 |
+
<sort_order>30</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>0</show_in_website>
|
51 |
+
<show_in_store>0</show_in_store>
|
52 |
+
</agent_id>
|
53 |
+
<md5_key translate="label,comment">
|
54 |
+
<label>MD5 key</label>
|
55 |
+
<comment>MD5 key is found on your Payson profile page.</comment>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<sort_order>40</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>0</show_in_website>
|
60 |
+
<show_in_store>0</show_in_store>
|
61 |
+
</md5_key>
|
62 |
+
<payson_All_in_one translate="label">
|
63 |
+
<label>Please select the payment method</label>
|
64 |
+
<comment>Choose your prefered Payson payment</comment>
|
65 |
+
<frontend_type>select</frontend_type>
|
66 |
+
<source_model>payson/system_config_source_paysondirectmethod</source_model>
|
67 |
+
<sort_order>45</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
</payson_All_in_one>
|
72 |
+
<payment_guarantee translate="label,comment">
|
73 |
+
<label>Enable payment guarantee</label>
|
74 |
+
<comment>Enable/disable payment guarantee.</comment>
|
75 |
+
<frontend_type>select</frontend_type>
|
76 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
77 |
+
<sort_order>50</sort_order>
|
78 |
+
<show_in_default>0</show_in_default>
|
79 |
+
<show_in_website>0</show_in_website>
|
80 |
+
<show_in_store>0</show_in_store>
|
81 |
+
</payment_guarantee>
|
82 |
+
<!--<active_invoice translate="label,comment">
|
83 |
+
<label>Enable Invoice</label>
|
84 |
+
<comment>Enable/disable invoice payment with Payson.</comment>
|
85 |
+
<frontend_type>select</frontend_type>
|
86 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
87 |
+
<sort_order>43</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>1</show_in_website>
|
90 |
+
<show_in_store>1</show_in_store>
|
91 |
+
</active_invoice>
|
92 |
+
<invoice_fee_tax translate="label,comment">
|
93 |
+
<label>Invoice fee tax</label>
|
94 |
+
<comment>Tax class for invoice fees.</comment>
|
95 |
+
<frontend_type>select</frontend_type>
|
96 |
+
<source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
|
97 |
+
<sort_order>50</sort_order>
|
98 |
+
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>1</show_in_store>
|
101 |
+
</invoice_fee_tax>
|
102 |
+
<invoice_fee_sek translate="label,comment">
|
103 |
+
<label>Invoice fee (SEK)</label>
|
104 |
+
<comment>Invoice fee for SEK excluding tax.</comment>
|
105 |
+
<frontend_type>text</frontend_type>
|
106 |
+
<sort_order>55</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>1</show_in_store>
|
110 |
+
</invoice_fee_sek>-->
|
111 |
+
<restore_on_cancel translate="label,comment">
|
112 |
+
<label>Restore cart on cancel</label>
|
113 |
+
<comment>Restore cart when customer cancel the payment</comment>
|
114 |
+
<frontend_type>select</frontend_type>
|
115 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
116 |
+
<sort_order>100</sort_order>
|
117 |
+
<show_in_default>1</show_in_default>
|
118 |
+
<show_in_website>1</show_in_website>
|
119 |
+
<show_in_store>1</show_in_store>
|
120 |
+
</restore_on_cancel>
|
121 |
+
<restore_on_error translate="label,comment">
|
122 |
+
<label>Restore cart on error</label>
|
123 |
+
<comment>Restore cart when status from Payson is error</comment>
|
124 |
+
<frontend_type>select</frontend_type>
|
125 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
126 |
+
<sort_order>150</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>1</show_in_store>
|
130 |
+
</restore_on_error>
|
131 |
+
<show_receipt_page translate="label,comment">
|
132 |
+
<label>Show receipt page</label>
|
133 |
+
<comment>Here you can enable or disable our receipt page</comment>
|
134 |
+
<frontend_type>select</frontend_type>
|
135 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
136 |
+
<sort_order>200</sort_order>
|
137 |
+
<show_in_default>1</show_in_default>
|
138 |
+
<show_in_website>0</show_in_website>
|
139 |
+
<show_in_store>0</show_in_store>
|
140 |
+
</show_receipt_page>
|
141 |
+
</fields>
|
142 |
+
</payson_standard>
|
143 |
+
<payson_invoice translate="label" module="payson">
|
144 |
+
<label>Payson_invoice_setup</label>
|
145 |
+
<sort_order>-99</sort_order>
|
146 |
+
<show_in_default>1</show_in_default>
|
147 |
+
<show_in_website>1</show_in_website>
|
148 |
+
<show_in_store>1</show_in_store>
|
149 |
+
<comment><![CDATA[Payson Invoice requires a separate contract. Please contact Payson for more information<a href="http://payson.se" target="_blank">Click here</a>]]></comment>
|
150 |
+
<fields>
|
151 |
+
<active_invoice translate="label,comment">
|
152 |
+
<label>Enabled</label>
|
153 |
+
<comment>Enable/disable invoice payment with Payson.</comment>
|
154 |
+
<frontend_type>select</frontend_type>
|
155 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
156 |
+
<sort_order>10</sort_order>
|
157 |
+
<show_in_default>1</show_in_default>
|
158 |
+
<show_in_website>1</show_in_website>
|
159 |
+
<show_in_store>1</show_in_store>
|
160 |
+
</active_invoice>
|
161 |
+
<invoice_fee_tax translate="label,comment">
|
162 |
+
<label>Invoice fee tax</label>
|
163 |
+
<comment>Tax class for invoice fees.</comment>
|
164 |
+
<frontend_type>select</frontend_type>
|
165 |
+
<source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
|
166 |
+
<sort_order>20</sort_order>
|
167 |
+
<show_in_default>1</show_in_default>
|
168 |
+
<show_in_website>1</show_in_website>
|
169 |
+
<show_in_store>1</show_in_store>
|
170 |
+
</invoice_fee_tax>
|
171 |
+
<invoice_fee_sek translate="label,comment">
|
172 |
+
<label>Invoice fee (SEK)</label>
|
173 |
+
<comment>Invoice fee for SEK excluding tax.</comment>
|
174 |
+
<frontend_type>text</frontend_type>
|
175 |
+
<sort_order>30</sort_order>
|
176 |
+
<show_in_default>1</show_in_default>
|
177 |
+
<show_in_website>1</show_in_website>
|
178 |
+
<show_in_store>1</show_in_store>
|
179 |
+
</invoice_fee_sek>
|
180 |
+
</fields>
|
181 |
+
</payson_invoice>
|
182 |
+
</groups>
|
183 |
+
</payment>
|
184 |
+
</sections>
|
185 |
+
</config>
|
app/design/adminhtml/default/default/Payson/Payson/total.phtml
CHANGED
@@ -1,5 +1,11 @@
|
|
1 |
<tr>
|
2 |
<td class="label"><?php echo($this->__('Invoice Fee')); ?></td>
|
3 |
-
<td><?php
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
</tr>
|
5 |
|
1 |
<tr>
|
2 |
<td class="label"><?php echo($this->__('Invoice Fee')); ?></td>
|
3 |
+
<td><?php
|
4 |
+
$this->_config = Mage::getModel('payson/config');
|
5 |
+
if($this->_config->CanInvoicePayment()){
|
6 |
+
echo($this->displayPriceAttribute('payson_invoice_fee'));
|
7 |
+
|
8 |
+
}
|
9 |
+
?></td>
|
10 |
</tr>
|
11 |
|
app/design/adminhtml/default/default/template/Payson/Payson/total.phtml
CHANGED
@@ -1,5 +1,11 @@
|
|
1 |
<tr>
|
2 |
-
<td class="label"><?php echo($this->__('Invoice
|
3 |
-
<td><?php
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
</tr>
|
5 |
|
1 |
<tr>
|
2 |
+
<td class="label"><?php echo($this->__('Invoice fee')); ?></td>
|
3 |
+
<td><?php
|
4 |
+
$this->_config = Mage::getModel('payson/config');
|
5 |
+
if($this->_config->CanInvoicePayment()){
|
6 |
+
echo($this->displayPriceAttribute('payson_invoice_fee'));
|
7 |
+
|
8 |
+
}
|
9 |
+
?></td>
|
10 |
</tr>
|
11 |
|
app/design/frontend/base/default/template/Payson/Payson/invoice_form.phtml
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$helper = Mage::Helper('payson');
|
3 |
-
$code = $this->getMethodCode();
|
4 |
-
?>
|
5 |
-
<fieldset class="form-list">
|
6 |
-
<label for="p_method_<?php echo($code); ?>" style="float: none"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/base/default/Payson/Payson/payson_faktura.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
7 |
-
<p id="payment_form_<?php echo($code); ?>" style="display: none">
|
8 |
-
<?php
|
9 |
-
echo($helper->__('You will be redirected to Payson\'s website.'));
|
10 |
-
echo '<br /><br />';
|
11 |
-
echo($helper->__('If you choose to pay by Paysoninvoice so there is a fee. Payment terms are 14 days and the invoice will be sent separately by email to the email address you specify. To pay by Paysoninvoice You must be 18 years old and be registered in Sweden as well as authorized in the credit assessment carried out at purchase.'));
|
12 |
-
?>
|
13 |
-
</p>
|
14 |
-
</fieldset>
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/Payson/Payson/standard_form.phtml
CHANGED
@@ -1,9 +1,24 @@
|
|
1 |
<?php
|
2 |
$helper = Mage::Helper('payson');
|
3 |
$code = $this->getMethodCode();
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
<
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
1 |
<?php
|
2 |
$helper = Mage::Helper('payson');
|
3 |
$code = $this->getMethodCode();
|
4 |
+
$this->_config = Mage::getModel('payson/config');
|
5 |
+
if (!$this->_config->CanInvoicePayment()) {
|
6 |
+
?>
|
7 |
+
<fieldset class="form-list">
|
8 |
+
<label for="p_method_<?php echo($code); ?>" style="float: none"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/base/default/Payson/Payson/payson.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
9 |
+
<p id="payment_form_<?php echo($code); ?>" style="display: none">
|
10 |
+
<?php
|
11 |
+
echo($helper->__('You will be redirected to Payson\'s website.'));
|
12 |
+
echo '<br /><br />';
|
13 |
+
}
|
14 |
+
if ($this->_config->CanInvoicePayment()) {
|
15 |
+
?>
|
16 |
+
<fieldset class="form-list">
|
17 |
+
<label for="p_method_<?php echo($code); ?>" style="float: none"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/base/default/Payson/Payson/Allinone.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
18 |
+
<p id="payment_form_<?php echo($code); ?>" style="display: none">
|
19 |
+
<?php
|
20 |
+
echo($helper->__('If you choose to pay with Payson invoice there will be an additional invoice fee, as seen above. Payment terms are 14 days and the invoice will be sent separately by email to the email address you specify. To pay by Payson invoice You must be 18 years old and be registered in Sweden as well as authorized in the credit assessment carried out at purchase.'));
|
21 |
+
}
|
22 |
+
?></p>
|
23 |
+
</fieldset>
|
24 |
|
app/etc/modules/Payson_Payson.xml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
<Payson_Payson>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
-
<version>1.2.
|
8 |
<depends>
|
9 |
<Mage_Payment />
|
10 |
</depends>
|
4 |
<Payson_Payson>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
+
<version>1.2.3</version>
|
8 |
<depends>
|
9 |
<Mage_Payment />
|
10 |
</depends>
|
app/locale/sv_SE/Payson_Payson.csv
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
"Checkout with Payson","Betala med Payson"
|
2 |
-
"
|
|
|
3 |
|
4 |
-
"
|
5 |
"Invoice fee","Fakturaavgift"
|
6 |
-
"If you choose to pay
|
7 |
"The payment was denied by Payson. Please, try a different payment method", "Betalningen blev nekad. Vänligen, försök med en annan betalningsmetod."
|
8 |
"Something went wrong with the payment. Please, try a different payment method", "Något gick fel med betalningen. Vänligen, försök en annan betalningsmetod."
|
9 |
-
"Your payment is being processed by Payson", "Er betalning är under behandling hos Payson"
|
10 |
|
11 |
"Order was activated at Payson","Order aktiverades hos Payson"
|
12 |
"Payment was credited at Payson","Betalningen krediterades hos Payson"
|
@@ -27,7 +27,8 @@
|
|
27 |
"Payson pinged the order with status %s","Payson pingade ordern med status: %s"
|
28 |
"Payson cancelled the order with status %s","Payson avbröt ordern med status: %s"
|
29 |
|
30 |
-
"
|
|
|
31 |
"Enable/disable payment with Payson.","Aktivera eller inaktivera betalning med Payson."
|
32 |
"Email","E-post"
|
33 |
"Email address bound to your Payson account.","E-postadress för ditt Paysonkonto."
|
1 |
+
"Checkout with Payson","Betala med Payson via kort eller bank"
|
2 |
+
"Checkout with Payson. If invoice is choosen as payment method an %s invoice fee will be added.","Betala med Payson. Om ni väljer att betala med Payson faktura då till kommer en fakturaavgfit på %s att adderas till totalsumman"
|
3 |
+
"You will be redirected to Payson's website.","Du kommer att skickas vidare till Paysons webbplats."
|
4 |
|
5 |
+
"Pay with Payson ","Betala med Payson."
|
6 |
"Invoice fee","Fakturaavgift"
|
7 |
+
"If you choose to pay with Payson invoice there will be an additional invoice fee, as seen above. Payment terms are 14 days and the invoice will be sent separately by email to the email address you specify. To pay by Payson invoice You must be 18 years old and be registered in Sweden as well as authorized in the credit assessment carried out at purchase.","Om du väljer att betala med Paysonfaktura då tillkommer ovanstående fakturaavgift. Betalningsvillkor är 14 dagar och fakturan kommer att sändas separat med e-post till den e-postadress Du anger. För att betala mot Paysonfaktura måste Du ha fyllt 18 år och vara folkbokförd i Sverige samt godkännas i den kreditprövning som genomförs vid köpet."
|
8 |
"The payment was denied by Payson. Please, try a different payment method", "Betalningen blev nekad. Vänligen, försök med en annan betalningsmetod."
|
9 |
"Something went wrong with the payment. Please, try a different payment method", "Något gick fel med betalningen. Vänligen, försök en annan betalningsmetod."
|
|
|
10 |
|
11 |
"Order was activated at Payson","Order aktiverades hos Payson"
|
12 |
"Payment was credited at Payson","Betalningen krediterades hos Payson"
|
27 |
"Payson pinged the order with status %s","Payson pingade ordern med status: %s"
|
28 |
"Payson cancelled the order with status %s","Payson avbröt ordern med status: %s"
|
29 |
|
30 |
+
"Enable","Aktivera"
|
31 |
+
"Enable Invoice", "Aktivera Payson faktrura"
|
32 |
"Enable/disable payment with Payson.","Aktivera eller inaktivera betalning med Payson."
|
33 |
"Email","E-post"
|
34 |
"Email address bound to your Payson account.","E-postadress för ditt Paysonkonto."
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Payson</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/bsd-license.php">BSD licence</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Official Payson module for Magento. </summary>
|
10 |
<description>This module integrates with Payson and allows you to charge your customers via Invoice, Card and direct bank transfers.</description>
|
11 |
-
<notes>
|
12 |
-
<authors><author><name>Karl Brundin</name><user>PaysonAB</user><email>integration@payson.se</email></author></authors>
|
13 |
-
<date>2015-02-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Payson"><dir name="Payson"><dir name="Block"><file name="Form.php" hash="74a8967879fbb6af999f0e513bc91323"/><dir name="Invoice"><file name="Form.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Payson</name>
|
4 |
+
<version>1.8.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/bsd-license.php">BSD licence</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Official Payson module for Magento. </summary>
|
10 |
<description>This module integrates with Payson and allows you to charge your customers via Invoice, Card and direct bank transfers.</description>
|
11 |
+
<notes>New Payson module </notes>
|
12 |
+
<authors><author><name>Karl Brundin</name><user>PaysonAB</user><email>integration@payson.se</email></author><author><name>Oscar Villegas</name><user>PaysonAB</user><email>integration@payson.se</email></author></authors>
|
13 |
+
<date>2015-02-25</date>
|
14 |
+
<time>10:54:32</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Payson"><dir name="Payson"><dir name="Block"><file name="Form.php" hash="74a8967879fbb6af999f0e513bc91323"/><dir name="Invoice"><file name="Form.php" hash="88a008948e1231b135ba8a798eeb1c66"/></dir><dir name="Order"><dir name="Totals"><file name="Fee.php" hash="3e8566e634d68d8df9bb70f597916980"/></dir></dir><dir name="Standard"><file name="Form.php" hash="c715cbec95494a9a26d261992429dff0"/></dir></dir><dir name="Helper"><dir name="Api"><dir name="Response"><file name="Interface.php" hash="51d0ffe7eefaa12eb9b4f2551e9f4259"/><dir name="Standard"><file name="Parameters.php" hash="6965b8259867c23a5e1e682e14491eb2"/></dir><file name="Standard.php" hash="cef827896629364fee49671af879adc3"/><file name="Validate.php" hash="34fb6626af3a6ac06e987c9e10a95796"/></dir></dir><file name="Api.php" hash="ecf09f9d553b18903cb9cac82b9d5aa8"/><file name="Data.php" hash="83ff59b1588c0b0ff8d2f7341589ea59"/><file name="FundingConstraint.php" hash="7acf2b5d8c045237aeff6566cd55cca1"/></dir><dir name="Model"><file name="Config.php" hash="7de7a2257df64a5e039de977edbc5492"/><dir name="Method"><file name="Abstract.php" hash="ecb3334750970e08c0580c0d5f384467"/><file name="Standard.php" hash="53ebf0a98fe2b7ee8f1a18c057e10b02"/></dir><dir name="Mysql4"><file name="Setup.php" hash="3075fa047af3d56d6eac609004e6e1cc"/></dir><dir name="Order"><dir name="Creditmemo"><dir name="Total"><file name="Invoice.php" hash="7360009be8a2a1bda368dc53f5f8cdf1"/></dir></dir><dir name="Invoice"><dir name="Total"><file name="Invoice.php" hash="1dee92d87b4a99605187a68ad6ab35b6"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Invoice.php" hash="089ad01db4ffbfd1bdcf96559bca2e8c"/></dir></dir></dir><file name="Standard.php" hash="5dc2e3fa79eab14c384144e71f7e653c"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Paysondirectmethod.php" hash="5f0a8584217204a638d11dbf61891779"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="ShipmentController.php" hash="c9607a2320b7a1070ca584384aba8721"/></dir></dir></dir><file name="CheckoutController.php" hash="4a5dfdb5bac495e84592648989cc18b6"/><file name="IpnController.php" hash="e7b092cdd0011a3a1359a084bbaf14ad"/></dir><dir name="etc"><file name="config.xml" hash="5081636ee3332ad65ec71e3fde0309bf"/><file name="system.xml" hash="89a131db033efc3df9c4112b4731a42b"/><file name="system.xml.bak" hash="8aed0958fb25646831a2a05cce0c07e1"/></dir><dir name="sql"><dir name="payson_setup"><file name="mysql4-install-0.1.0.php" hash="21cd9fd3436ba1eb2fc20eaaadb42106"/><file name="mysql4-upgrade-0.1.0-0.1.2.php" hash="5bbcb930748e3a87a220c0e9f8448a15"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="Payson.xml" hash="1ace2a646cd9a33521e7b392b6c5f3f1"/></dir><dir name="template"><dir name="Payson"><dir name="Payson"><file name="total.phtml" hash="73984e3bd27f5cd1d67550471e4e3da2"/></dir></dir></dir><dir name="Payson"><dir name="Payson"><file name="total.phtml" hash="e05160dad39cd2cbf86decc34fb8d225"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="Payson.xml" hash="22b9b9ae0cc9b1c70f79d690fbb4db41"/></dir><dir name="template"><dir name="Payson"><dir name="Payson"><file name="standard_form.phtml" hash="23c387ef94322de355e00f1a49e243d4"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Payson_Payson.xml" hash="9118f2a12f9a78438b37b4c9bc5c5198"/></dir></target><target name="magelocale"><dir name="sv_SE"><file name="Payson_Payson.csv" hash="f926728c834ad53fb53d098ef61c23a9"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="Payson"><dir name="Payson"><file name="Allinone.png" hash="98f586ec9a3e706d86662796bd776685"/><file name="Allinone3.png" hash="f9a4240a702838136584dc1256104ce5"/><file name="payson.gif" hash="638d0055cbc1a4bdc32e9fa1156b722a"/><file name="payson.png" hash="308916345711a4520313c94218c5bda7"/><file name="payson_faktura.png" hash="fa218c9949c05c6f3452d9f4c541da2c"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php><package><name>Mage_Core_modules</name><channel>community</channel><min>1.8.0</min><max></max></package></required></dependencies>
|
18 |
</package>
|
skin/frontend/base/default/Payson/Payson/Allinone.png
ADDED
Binary file
|
skin/frontend/base/default/Payson/Payson/Allinone3.png
ADDED
Binary file
|