Version Notes
* Fixed so that the order email is sent when payment is accepted by Payson
* Added an option for not activating an invoice when accepted.
Download this release
Release Info
Developer | Oscar Villegas |
Extension | Payson |
Version | 0.1.2 |
Comparing to | |
See all releases |
Version 0.1.2
- app/code/community/Payson/Payson/Block/Form.php +10 -0
- app/code/community/Payson/Payson/Block/Invoice/Form.php +10 -0
- app/code/community/Payson/Payson/Block/Order/Totals/Fee.php +22 -0
- app/code/community/Payson/Payson/Block/Standard/Form.php +10 -0
- app/code/community/Payson/Payson/Helper/Api.php +1145 -0
- app/code/community/Payson/Payson/Helper/Api/Response/Interface.php +19 -0
- app/code/community/Payson/Payson/Helper/Api/Response/Standard.php +153 -0
- app/code/community/Payson/Payson/Helper/Api/Response/Standard/Parameters.php +78 -0
- app/code/community/Payson/Payson/Helper/Api/Response/Validate.php +49 -0
- app/code/community/Payson/Payson/Helper/Data.php +6 -0
- app/code/community/Payson/Payson/Model/Config.php +235 -0
- app/code/community/Payson/Payson/Model/Method/Abstract.php +179 -0
- app/code/community/Payson/Payson/Model/Method/Invoice.php +110 -0
- app/code/community/Payson/Payson/Model/Method/Standard.php +40 -0
- app/code/community/Payson/Payson/Model/Mysql4/Setup.php +5 -0
- app/code/community/Payson/Payson/Model/Order/Creditmemo/Total/Invoice.php +45 -0
- app/code/community/Payson/Payson/Model/Order/Invoice/Total/Invoice.php +45 -0
- app/code/community/Payson/Payson/Model/Quote/Address/Total/Invoice.php +68 -0
- app/code/community/Payson/Payson/Model/Standard.php +131 -0
- app/code/community/Payson/Payson/controllers/Adminhtml/Sales/Order/ShipmentController.php +26 -0
- app/code/community/Payson/Payson/controllers/CheckoutController.php +115 -0
- app/code/community/Payson/Payson/controllers/IpnController.php +29 -0
- app/code/community/Payson/Payson/etc/config.xml +182 -0
- app/code/community/Payson/Payson/etc/system.xml +134 -0
- app/code/community/Payson/Payson/sql/payson_setup/mysql4-install-0.1.0.php +43 -0
- app/code/community/Payson/Payson/sql/payson_setup/mysql4-upgrade-0.1.0-0.1.2.php +7 -0
- app/design/adminhtml/default/default/Payson/Payson/total.phtml +5 -0
- app/design/adminhtml/default/default/layout/Payson.xml +34 -0
- app/design/frontend/base/default/layout/Payson.xml +45 -0
- app/design/frontend/base/default/template/Payson/Payson/invoice_form.phtml +9 -0
- app/design/frontend/base/default/template/Payson/Payson/standard_form.phtml +9 -0
- app/etc/modules/Payson_Payson.xml +14 -0
- app/locale/sv_SE/Payson_Payson.csv +47 -0
- package.xml +24 -0
- skin/frontend/base/default/Payson/Payson/payson.gif +0 -0
- skin/frontend/base/default/Payson/Payson/payson.png +0 -0
- skin/frontend/base/default/Payson/Payson/payson_faktura.png +0 -0
app/code/community/Payson/Payson/Block/Form.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Block_Form extends Mage_Payment_Block_Form
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->setTemplate('Payson/Payson/form.phtml');
|
7 |
+
parent::_construct();
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
app/code/community/Payson/Payson/Block/Invoice/Form.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Block_Invoice_Form extends Mage_Payment_Block_Form
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->setTemplate('Payson/Payson/invoice_form.phtml');
|
7 |
+
parent::_construct();
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
app/code/community/Payson/Payson/Block/Order/Totals/Fee.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Block_Order_Totals_Fee extends Mage_Core_Block_Abstract
|
3 |
+
{
|
4 |
+
public function initTotals()
|
5 |
+
{
|
6 |
+
$parent = $this->getParentBlock();
|
7 |
+
$this->_order = $parent->getOrder();
|
8 |
+
|
9 |
+
if($this->_order->getPayment()->getMethod() === 'payson_invoice')
|
10 |
+
{
|
11 |
+
$parent->addTotalBefore(new Varien_Object(array
|
12 |
+
(
|
13 |
+
'code' => 'payson_invoice',
|
14 |
+
'label' => Mage::helper('payson')->__('Invoice fee'),
|
15 |
+
'value' => $this->_order->getPaysonInvoiceFee()
|
16 |
+
)), 'tax');
|
17 |
+
}
|
18 |
+
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
app/code/community/Payson/Payson/Block/Standard/Form.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Block_Standard_Form extends Mage_Payment_Block_Form
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->setTemplate('Payson/Payson/standard_form.phtml');
|
7 |
+
parent::_construct();
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
app/code/community/Payson/Payson/Helper/Api.php
ADDED
@@ -0,0 +1,1145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Helper_Api
|
3 |
+
{
|
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/';
|
11 |
+
const API_CALL_PAYMENT_DETAILS = '%s://%sapi.payson.%s/%s/%sDetails/';
|
12 |
+
const API_CALL_PAYMENT_UPDATE = '%s://%sapi.payson.%s/%s/%sUpdate/';
|
13 |
+
|
14 |
+
const PAY_FORWARD_URL = '%s://%s%s.payson.%s/paySecure/';
|
15 |
+
|
16 |
+
const APPLICATION_ID = 'Magento Module 0.1.2';
|
17 |
+
const MODULE_NAME = 'payson_magento';
|
18 |
+
const MODULE_VERSION = '1.5';
|
19 |
+
|
20 |
+
const STATUS_CREATED = 'CREATED';
|
21 |
+
const STATUS_PENDING = 'PENDING';
|
22 |
+
const STATUS_PROCESSING = 'PROCESSING';
|
23 |
+
const STATUS_COMPLETED = 'COMPLETED';
|
24 |
+
const STATUS_CREDITED = 'CREDITED';
|
25 |
+
const STATUS_INCOMPLETE = 'INCOMPLETE';
|
26 |
+
const STATUS_ERROR = 'ERROR';
|
27 |
+
const STATUS_EXPIRED = 'EXPIRED';
|
28 |
+
const STATUS_REVERSALERROR = 'REVERSALERROR';
|
29 |
+
|
30 |
+
const PAYMENT_METHOD_BANK = 'BANK';
|
31 |
+
const PAYMENT_METHOD_CREDITCARD = 'CREDITCARD';
|
32 |
+
const PAYMENT_METHOD_INVOICE = 'INVOICE';
|
33 |
+
|
34 |
+
const GUARANTEE_STATUS_WAITINGFORSEND = 'WAITINGFORSEND';
|
35 |
+
const GUARANTEE_STATUS_WAITINGFORACCEPTANCE = 'WAITINGFORACCEPTANCE';
|
36 |
+
const GUARANTEE_STATUS_WAITINGFORRETURN = 'WAITINGFORRETURN';
|
37 |
+
const GUARANTEE_STATUS_WAITINGFORRETURNACCEPTANCE = 'WAITINGFORRETURNACCEPTANCE';
|
38 |
+
const GUARANTEE_STATUS_RETURNNOTACCEPTED = 'RETURNNOTACCEPTED';
|
39 |
+
const GUARANTEE_STATUS_NOTRECEIVED = 'NOTRECEIVED';
|
40 |
+
const GUARANTEE_STATUS_RETURNNOTRECEIVED = 'RETURNNOTRECEIVED';
|
41 |
+
const GUARANTEE_STATUS_MONEYRETURNEDTOSENDER = 'MONEYRETURNEDTOSENDER';
|
42 |
+
const GUARANTEE_STATUS_RETURNACCEPTED = 'RETURNACCEPTED';
|
43 |
+
|
44 |
+
const INVOICE_STATUS_PENDING = 'PENDING';
|
45 |
+
const INVOICE_STATUS_ORDERCREATED = 'ORDERCREATED';
|
46 |
+
const INVOICE_STATUS_ORDERCANCELLED = 'ORDERCANCELLED';
|
47 |
+
const INVOICE_STATUS_SHIPPED = 'SHIPPED';
|
48 |
+
const INVOICE_STATUS_DONE = 'DONE';
|
49 |
+
|
50 |
+
const UPDATE_ACTION_CANCELORDER = 'CANCELORDER';
|
51 |
+
const UPDATE_ACTION_SHIPORDER = 'SHIPORDER';
|
52 |
+
const UPDATE_ACTION_CREDITORDER = 'CREDITORDER';
|
53 |
+
const UPDATE_ACTION_REFUNDORDER = 'REFUND';
|
54 |
+
|
55 |
+
const GUARANTEE_REQUIRED = 'REQUIRED';
|
56 |
+
const GUARANTEE_OPTIONAL = 'OPTIONAL';
|
57 |
+
const GUARANTEE_NO = 'NO';
|
58 |
+
|
59 |
+
/*
|
60 |
+
* Private properties
|
61 |
+
*/
|
62 |
+
|
63 |
+
private $response;
|
64 |
+
|
65 |
+
/*
|
66 |
+
* Private methods
|
67 |
+
*/
|
68 |
+
|
69 |
+
private function GetHttpClient($url)
|
70 |
+
{
|
71 |
+
$config = Mage::getModel('payson/config');
|
72 |
+
|
73 |
+
$http_client = new Zend_Http_Client($url);
|
74 |
+
|
75 |
+
$http_client->setMethod(Zend_Http_Client::POST)
|
76 |
+
->setHeaders(array
|
77 |
+
(
|
78 |
+
'PAYSON-SECURITY-USERID' => $config->Get('agent_id'),
|
79 |
+
'PAYSON-SECURITY-PASSWORD' => $config->Get('md5_key'),
|
80 |
+
'PAYSON-APPLICATION-ID' => self::APPLICATION_ID,
|
81 |
+
'PAYSON-MODULE-INFO' => self::MODULE_NAME.'|'.self::MODULE_VERSION.'|'.Mage::getVersion()
|
82 |
+
));
|
83 |
+
|
84 |
+
return $http_client->resetParameters();
|
85 |
+
}
|
86 |
+
|
87 |
+
private function SetResponse(
|
88 |
+
Payson_Payson_Helper_Api_Response_Interface $response)
|
89 |
+
{
|
90 |
+
$this->response = $response;
|
91 |
+
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Helper for Pay()
|
97 |
+
*
|
98 |
+
* @param object $item
|
99 |
+
* @param int $i
|
100 |
+
* @param int $total
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
private function GetOrderItemInfo($item, $i, &$total)
|
104 |
+
{
|
105 |
+
$product = Mage::getModel('catalog/product')
|
106 |
+
->load($item->getProductId());
|
107 |
+
$children = $item->getChildrenItems();
|
108 |
+
|
109 |
+
if(!$product->isConfigurable() && count($children) &&
|
110 |
+
!$item->isChildrenCalculated())
|
111 |
+
{
|
112 |
+
$args = array();
|
113 |
+
foreach($children as $child)
|
114 |
+
{
|
115 |
+
$args += $this->GetOrderItemInfo($child, $i++, $total);
|
116 |
+
}
|
117 |
+
return $args;
|
118 |
+
}
|
119 |
+
|
120 |
+
if($product->isConfigurable() && (count($children) === 1))
|
121 |
+
{
|
122 |
+
$name = $children[0]->getData('name');
|
123 |
+
$sku = $children[0]->getData('sku');
|
124 |
+
}
|
125 |
+
else
|
126 |
+
{
|
127 |
+
$name = $product->getData('name');
|
128 |
+
$sku = $item->getData('sku');
|
129 |
+
}
|
130 |
+
|
131 |
+
/* TODO: If tax_percent is not set?
|
132 |
+
Mage::getSingleton('tax/calculation')->getRate(
|
133 |
+
$tax_rate_req->setProductClassId($product->getTaxClassId()))
|
134 |
+
*/
|
135 |
+
$tax_mod = (float)$item->getData('tax_percent');
|
136 |
+
$tax_mod /= 100;
|
137 |
+
$tax_mod = round($tax_mod, 5);
|
138 |
+
|
139 |
+
$qty = (float)$item->getData('qty_ordered');
|
140 |
+
$qty = round($qty, 2);
|
141 |
+
|
142 |
+
$price = (float)$item->getData('row_total_incl_tax');
|
143 |
+
$price -= (float)$item->getData('discount_amount');
|
144 |
+
|
145 |
+
$base_price = (($price / (1 + $tax_mod)) / $qty);
|
146 |
+
$base_price = round($base_price, 3);
|
147 |
+
|
148 |
+
$total += (($base_price * (1 + $tax_mod)) * $qty);
|
149 |
+
|
150 |
+
return array
|
151 |
+
(
|
152 |
+
'orderItemList.orderItem(' . $i . ').description' =>
|
153 |
+
$name,
|
154 |
+
'orderItemList.orderItem(' . $i . ').sku' =>
|
155 |
+
$sku,
|
156 |
+
'orderItemList.orderItem(' . $i . ').quantity' =>
|
157 |
+
$qty,
|
158 |
+
'orderItemList.orderItem(' . $i . ').unitPrice' =>
|
159 |
+
$base_price,
|
160 |
+
'orderItemList.orderItem(' . $i . ').taxPercentage' =>
|
161 |
+
$tax_mod
|
162 |
+
);
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Helper for Pay()
|
167 |
+
*
|
168 |
+
* @param object $order
|
169 |
+
* @param object $customer
|
170 |
+
* @param object $store
|
171 |
+
* @param int $i
|
172 |
+
* @param int $total
|
173 |
+
* @return array
|
174 |
+
*/
|
175 |
+
private function GetOrderShippingInfo($order, $customer, $store, $i,
|
176 |
+
&$total)
|
177 |
+
{
|
178 |
+
$tax_calc = Mage::getSingleton('tax/calculation');
|
179 |
+
|
180 |
+
$tax_rate_req = $tax_calc->getRateRequest(
|
181 |
+
$order->getShippingAddress(),
|
182 |
+
$order->getBillingAddress(),
|
183 |
+
$customer->getTaxClassId(),
|
184 |
+
$store);
|
185 |
+
|
186 |
+
$args = array();
|
187 |
+
|
188 |
+
if(($price = (float)$order->getData('shipping_incl_tax')) > 0)
|
189 |
+
{
|
190 |
+
$tax_mod = $tax_calc->getRate($tax_rate_req->setProductClassId(
|
191 |
+
Mage::getStoreConfig('tax/classes/shipping_tax_class')));
|
192 |
+
$tax_mod /= 100;
|
193 |
+
$tax_mod = round($tax_mod, 5);
|
194 |
+
|
195 |
+
$price -= (float)$order->getData('shipping_discount_amount');
|
196 |
+
|
197 |
+
$base_price = ($price / (1 + $tax_mod));
|
198 |
+
$base_price = round($base_price, 3);
|
199 |
+
|
200 |
+
$total += ($base_price * (1 + $tax_mod));
|
201 |
+
|
202 |
+
$args = array
|
203 |
+
(
|
204 |
+
'orderItemList.orderItem(' . $i . ').description' =>
|
205 |
+
$order->getData('shipping_description'),
|
206 |
+
'orderItemList.orderItem(' . $i . ').sku' =>
|
207 |
+
$order->getData('shipping_method'),
|
208 |
+
'orderItemList.orderItem(' . $i . ').quantity' =>
|
209 |
+
1,
|
210 |
+
'orderItemList.orderItem(' . $i . ').unitPrice' =>
|
211 |
+
$base_price,
|
212 |
+
'orderItemList.orderItem(' . $i . ').taxPercentage' =>
|
213 |
+
$tax_mod
|
214 |
+
);
|
215 |
+
}
|
216 |
+
|
217 |
+
return $args;
|
218 |
+
}
|
219 |
+
|
220 |
+
/*
|
221 |
+
* Public methods
|
222 |
+
*/
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get API response
|
226 |
+
*
|
227 |
+
* @return object
|
228 |
+
*/
|
229 |
+
public function GetResponse()
|
230 |
+
{
|
231 |
+
return $this->response;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Get forward/redirect url after a successful Pay() call
|
236 |
+
*
|
237 |
+
* @return string
|
238 |
+
*/
|
239 |
+
public function GetPayForwardUrl()
|
240 |
+
{
|
241 |
+
$url = vsprintf(self::PAY_FORWARD_URL . '?token=' . $this->GetResponse()->TOKEN, $this->GetFormatIfTest(null, true));
|
242 |
+
return $url;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* http://api.payson.se/#title8
|
247 |
+
*
|
248 |
+
* @param object $order
|
249 |
+
* @return object $this
|
250 |
+
*/
|
251 |
+
public function Pay(Mage_Sales_Model_Order $order)
|
252 |
+
{
|
253 |
+
$payment_method = $order->getPayment()->getMethod();
|
254 |
+
$helper = Mage::helper('payson');
|
255 |
+
$config = Mage::getModel('payson/config');
|
256 |
+
$store = Mage::app()->getStore($order->getStoreId());
|
257 |
+
$customer = Mage::getModel('customer/customer')
|
258 |
+
->load($order->getCustomerId());
|
259 |
+
$billing_address = $order->getBillingAddress();
|
260 |
+
|
261 |
+
// Need a two character locale code
|
262 |
+
$locale_code = Mage::getSingleton('core/locale')->getLocaleCode();
|
263 |
+
$locale_code = strtoupper(substr($locale_code, 0, 2));
|
264 |
+
|
265 |
+
if(!in_array($locale_code, array('SV', 'FI', 'EN')))
|
266 |
+
{
|
267 |
+
switch($locale_code)
|
268 |
+
{
|
269 |
+
case 'DA':
|
270 |
+
case 'NO':
|
271 |
+
{
|
272 |
+
$locale_code = 'SV';
|
273 |
+
break;
|
274 |
+
}
|
275 |
+
default:
|
276 |
+
{
|
277 |
+
$locale_code = 'EN';
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
+
// $args will contain the arguments of the API request to Payson
|
283 |
+
$args = array
|
284 |
+
(
|
285 |
+
'returnUrl' =>
|
286 |
+
Mage::getUrl('payson/checkout/return',
|
287 |
+
array('_secure' => true)),
|
288 |
+
'cancelUrl' =>
|
289 |
+
Mage::getUrl('payson/checkout/cancel',
|
290 |
+
array('_secure' => true)),
|
291 |
+
'ipnNotificationUrl' =>
|
292 |
+
Mage::getUrl('payson/ipn/notify',
|
293 |
+
array('_secure' => true)),
|
294 |
+
'localeCode' =>
|
295 |
+
$locale_code,
|
296 |
+
'currencyCode' =>
|
297 |
+
//$order->getOrderCurrency()->getCode(),
|
298 |
+
//$order->getBaseCurrencyCode(),
|
299 |
+
strtoupper(substr($order->getOrderCurrency()->getCode(), 0, 3)),
|
300 |
+
'memo' =>
|
301 |
+
sprintf($helper->__('Order from %s'), $store->getUrl()),
|
302 |
+
'senderEmail' =>
|
303 |
+
$order->getCustomerEmail(),
|
304 |
+
'senderFirstName' =>
|
305 |
+
$billing_address->getFirstname(),
|
306 |
+
'senderLastName' =>
|
307 |
+
$billing_address->getLastname(),
|
308 |
+
'receiverList.receiver(0).email' =>
|
309 |
+
$config->Get('email'),
|
310 |
+
'purchaseId' => $order->getRealOrderId()
|
311 |
+
);
|
312 |
+
|
313 |
+
if(!$config->CanPaymentGuarantee())
|
314 |
+
{
|
315 |
+
$args['guaranteeOffered'] = self::GUARANTEE_NO;
|
316 |
+
}
|
317 |
+
|
318 |
+
if(($payment_method === 'payson_invoice'))
|
319 |
+
{
|
320 |
+
if(!$config->CanInvoicePayment())
|
321 |
+
{
|
322 |
+
Mage::throwException('Invoice payment is disabled');
|
323 |
+
}
|
324 |
+
|
325 |
+
$args['fundingList.fundingConstraint(0).constraint'] =
|
326 |
+
self::PAYMENT_METHOD_INVOICE;
|
327 |
+
}
|
328 |
+
|
329 |
+
$i = 0;
|
330 |
+
$total = 0;
|
331 |
+
|
332 |
+
// Calculate price of each item in the order
|
333 |
+
foreach($order->getAllVisibleItems() as $item)
|
334 |
+
{
|
335 |
+
$args += $this->GetOrderItemInfo($item, $i++, $total);
|
336 |
+
}
|
337 |
+
|
338 |
+
// Calculate price for shipping
|
339 |
+
$args += $this->GetOrderShippingInfo($order, $customer, $store, $i++,
|
340 |
+
$total);
|
341 |
+
|
342 |
+
if($order->getPaysonInvoiceFee() > 0)
|
343 |
+
{
|
344 |
+
$fee = $order->getPaysonInvoiceFee();
|
345 |
+
/*$args += array
|
346 |
+
(
|
347 |
+
'orderItemList.orderItem(' . $i . ').description' =>
|
348 |
+
$helper->__('Invoice fee'),
|
349 |
+
'orderItemList.orderItem(' . $i . ').sku' =>
|
350 |
+
'invoice_fee',
|
351 |
+
'orderItemList.orderItem(' . $i . ').quantity' =>
|
352 |
+
1,
|
353 |
+
'orderItemList.orderItem(' . $i . ').unitPrice' =>
|
354 |
+
$config->GetInvoiceFee($order),
|
355 |
+
'orderItemList.orderItem(' . $i . ').taxPercentage' =>
|
356 |
+
$config->GetInvoiceFeeTaxMod($order)
|
357 |
+
);
|
358 |
+
|
359 |
+
$total += $config->GetInvoiceFeeInclTax($order);*/
|
360 |
+
|
361 |
+
$args['invoiceFee'] = round((float)$fee, 3);
|
362 |
+
$total += $fee;
|
363 |
+
}
|
364 |
+
|
365 |
+
$total = round($total, 2);
|
366 |
+
|
367 |
+
$args['receiverList.receiver(0).amount'] = $total;
|
368 |
+
|
369 |
+
//echo('<pre>');print_r($args);exit(PHP_EOL . $order->getData('grand_total') . '</pre>');
|
370 |
+
$url = vsprintf(self::API_CALL_PAY, $this->GetFormatIfTest($order->getStoreId()));
|
371 |
+
$client = $this->GetHttpClient($url)
|
372 |
+
->setParameterPost($args);
|
373 |
+
|
374 |
+
$response = Payson_Payson_Helper_Api_Response_Standard
|
375 |
+
::FromHttpBody($client->request()->getBody());
|
376 |
+
|
377 |
+
$this->SetResponse($response);
|
378 |
+
|
379 |
+
$resource = Mage::getSingleton('core/resource');
|
380 |
+
$db = $resource->getConnection('core_write');
|
381 |
+
|
382 |
+
$order_table = $resource->getTableName('payson_order');
|
383 |
+
$order_log_table = $resource->getTableName('payson_order_log');
|
384 |
+
|
385 |
+
$db->insert($order_table, array
|
386 |
+
(
|
387 |
+
'order_id' => $order->getRealOrderId(),
|
388 |
+
'added' => new Zend_Db_Expr('NOW()'),
|
389 |
+
'updated' => new Zend_Db_Expr('NOW()'),
|
390 |
+
'valid' => (int)$response->IsValid(),
|
391 |
+
'token' => (isset($response->TOKEN) ? $response->TOKEN :
|
392 |
+
new Zend_Db_Expr('NULL')),
|
393 |
+
'store_id' => $order->getStoreId()
|
394 |
+
));
|
395 |
+
|
396 |
+
$payson_order_id = $db->lastInsertId();
|
397 |
+
|
398 |
+
$db->insert($order_log_table, array
|
399 |
+
(
|
400 |
+
'payson_order_id' => $payson_order_id,
|
401 |
+
'added' => new Zend_Db_Expr('NOW()'),
|
402 |
+
'api_call' => 'pay',
|
403 |
+
'valid' => (int)$response->IsValid(),
|
404 |
+
'response' => serialize($response->ToArray())
|
405 |
+
));
|
406 |
+
|
407 |
+
if(!$response->IsValid())
|
408 |
+
{
|
409 |
+
throw new Mage_Core_Exception(sprintf($helper->__(
|
410 |
+
'Failed to initialize payment. Payson replied: %s'),
|
411 |
+
$response->GetError()), $response->GetErrorId());
|
412 |
+
}
|
413 |
+
|
414 |
+
return $this;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Implements the IPN procedure
|
419 |
+
*
|
420 |
+
* http://api.payson.se/#title11
|
421 |
+
*
|
422 |
+
* @param string $http_body
|
423 |
+
* @param string $content_type
|
424 |
+
* @return object $this
|
425 |
+
*/
|
426 |
+
public function Validate($http_body, $content_type)
|
427 |
+
{
|
428 |
+
$helper = Mage::helper('payson');
|
429 |
+
$config = Mage::getModel('payson/config');
|
430 |
+
// Parse request done by Payson to our IPN controller
|
431 |
+
$ipn_response = Payson_Payson_Helper_Api_Response_Standard
|
432 |
+
::FromHttpBody($http_body);
|
433 |
+
|
434 |
+
// Get the database connection
|
435 |
+
$resource = Mage::getSingleton('core/resource');
|
436 |
+
$db = $resource->getConnection('core_write');
|
437 |
+
|
438 |
+
$order_table = $resource->getTableName('payson_order');
|
439 |
+
$order_log_table = $resource->getTableName('payson_order_log');
|
440 |
+
|
441 |
+
/* Save data sent by Payson, log entry as invalid by default, this
|
442 |
+
value will be changed later in this method if successful. No payson
|
443 |
+
order id is set, because we dont have one yet */
|
444 |
+
$db->insert($order_log_table,
|
445 |
+
array
|
446 |
+
(
|
447 |
+
'added' => new Zend_Db_Expr('NOW()'),
|
448 |
+
'api_call' => 'validate',
|
449 |
+
'valid' => 0,
|
450 |
+
'response' => serialize($ipn_response->ToArray())
|
451 |
+
));
|
452 |
+
|
453 |
+
$order_log_id = $db->lastInsertId();
|
454 |
+
|
455 |
+
/* $ipn_response will never contain responseEnvelope.ack, as I first
|
456 |
+
thought it would */
|
457 |
+
/*if(!$ipn_response->IsValid())
|
458 |
+
{
|
459 |
+
Mage::throwException('Invalid request');
|
460 |
+
}*/
|
461 |
+
|
462 |
+
/* Save fetch mode so that we can reset it and not mess up Magento
|
463 |
+
functionality */
|
464 |
+
$old_fetch_mode = $db->getFetchMode();
|
465 |
+
$db->setFetchMode(Zend_Db::FETCH_OBJ);
|
466 |
+
|
467 |
+
// Get payson order information and validate token
|
468 |
+
$payson_order = $db->fetchRow(
|
469 |
+
'SELECT
|
470 |
+
id,
|
471 |
+
order_id,
|
472 |
+
store_id
|
473 |
+
FROM
|
474 |
+
`' . $order_table . '`
|
475 |
+
WHERE
|
476 |
+
valid = 1
|
477 |
+
AND
|
478 |
+
token = ?
|
479 |
+
LIMIT
|
480 |
+
0,1', $ipn_response->token);
|
481 |
+
|
482 |
+
if($payson_order === false)
|
483 |
+
{
|
484 |
+
Mage::throwException('Invalid token');
|
485 |
+
}
|
486 |
+
|
487 |
+
// Do the validate API call
|
488 |
+
$client = $this->GetHttpClient(vsprintf(self::API_CALL_VALIDATE, $this->GetFormatIfTest($payson_order->store_id)))
|
489 |
+
->setRawData($http_body, $content_type);
|
490 |
+
|
491 |
+
$response = Payson_Payson_Helper_Api_Response_Validate
|
492 |
+
::FromHttpBody($client->request()->getBody());
|
493 |
+
|
494 |
+
$this->SetResponse($response);
|
495 |
+
|
496 |
+
if(!$response->IsValid())
|
497 |
+
{
|
498 |
+
Mage::throwException('Validate call was unsuccessful');
|
499 |
+
}
|
500 |
+
|
501 |
+
|
502 |
+
|
503 |
+
// Update order log with payson order id
|
504 |
+
$db->update($order_log_table,
|
505 |
+
array
|
506 |
+
(
|
507 |
+
'payson_order_id' => $payson_order->id
|
508 |
+
),
|
509 |
+
array
|
510 |
+
(
|
511 |
+
'id = ?' => $order_log_id
|
512 |
+
));
|
513 |
+
|
514 |
+
// the order model does not expect FETCH_OBJ!
|
515 |
+
$db->setFetchMode($old_fetch_mode);
|
516 |
+
|
517 |
+
$order = Mage::getModel('sales/order')
|
518 |
+
->loadByIncrementId($payson_order->order_id);
|
519 |
+
|
520 |
+
// Stop if order dont exist
|
521 |
+
if(is_null($order->getId()))
|
522 |
+
{
|
523 |
+
Mage::throwException('Invalid order');
|
524 |
+
}
|
525 |
+
|
526 |
+
// If its not pending payment its either cancelled or completed
|
527 |
+
//if($order->getState() !== Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
|
528 |
+
// Or... hmm...
|
529 |
+
if($order->getState() === Mage_Sales_Model_Order::STATE_COMPLETE)
|
530 |
+
{
|
531 |
+
Mage::throwException('Order is no longer active');
|
532 |
+
}
|
533 |
+
|
534 |
+
$receivers = $ipn_response->receiverList->receiver->ToArray();
|
535 |
+
|
536 |
+
/* Verify payment amount. floor() since there might be a precision
|
537 |
+
difference */
|
538 |
+
if(floor((float)$receivers[0]['amount']) !==
|
539 |
+
floor((float)$order->getTotalDue()))
|
540 |
+
{
|
541 |
+
Mage::throwException('Invalid amount');
|
542 |
+
}
|
543 |
+
|
544 |
+
switch($ipn_response->status)
|
545 |
+
{
|
546 |
+
case self::STATUS_COMPLETED:
|
547 |
+
{
|
548 |
+
//Changes the status of the order from pending_payment to processing
|
549 |
+
$order->setState(
|
550 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
551 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
552 |
+
$helper->__('Payson completed the order payment'));
|
553 |
+
|
554 |
+
//It creates the invoice to the order
|
555 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
556 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
557 |
+
$invoice->register();
|
558 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
559 |
+
->addObject($invoice)
|
560 |
+
->addObject($invoice->getOrder());
|
561 |
+
$transactionSave->save();
|
562 |
+
/*try
|
563 |
+
{
|
564 |
+
echo('<p>Order id: ' . $order->getId() . '</p>');
|
565 |
+
|
566 |
+
if(!$order->canInvoice())
|
567 |
+
{
|
568 |
+
exit('<p>Cant invoice!</p>');
|
569 |
+
}
|
570 |
+
|
571 |
+
$invoice = Mage::getModel('sales/service_order', $order)
|
572 |
+
->prepareInvoice();
|
573 |
+
|
574 |
+
if(!$invoice->getTotalQty())
|
575 |
+
{
|
576 |
+
exit('<p>No products!</p>');
|
577 |
+
}
|
578 |
+
|
579 |
+
$invoice->setRequestedCaptureCase(
|
580 |
+
Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE)
|
581 |
+
->register();
|
582 |
+
|
583 |
+
$transaction_save = Mage::getModel('core/resource_transaction')
|
584 |
+
->addObject($invoice)
|
585 |
+
->addObject($invoice->getOrder());
|
586 |
+
|
587 |
+
$transaction_save->save();
|
588 |
+
}
|
589 |
+
catch(Exception $e)
|
590 |
+
{
|
591 |
+
exit($e->getMessage());
|
592 |
+
}*/
|
593 |
+
break;
|
594 |
+
}
|
595 |
+
case self::STATUS_CREATED:
|
596 |
+
case self::STATUS_PENDING:
|
597 |
+
case self::STATUS_PROCESSING:
|
598 |
+
case self::STATUS_CREDITED:
|
599 |
+
{
|
600 |
+
if(($ipn_response->status === self::STATUS_PENDING) &&
|
601 |
+
($ipn_response->type === self::PAYMENT_METHOD_INVOICE) &&
|
602 |
+
($ipn_response->invoiceStatus ===
|
603 |
+
self::INVOICE_STATUS_ORDERCREATED))
|
604 |
+
{
|
605 |
+
//Changes the status of the order from pending to processing
|
606 |
+
$order->setState(
|
607 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
608 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
609 |
+
$helper->__('Payson created an invoice'));
|
610 |
+
|
611 |
+
//It creates the invoice to the order
|
612 |
+
if($config->ActivateInvoiceOnPurchase())
|
613 |
+
{
|
614 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
615 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
616 |
+
$invoice->register();
|
617 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
618 |
+
->addObject($invoice)
|
619 |
+
->addObject($invoice->getOrder());
|
620 |
+
$transactionSave->save();
|
621 |
+
}
|
622 |
+
|
623 |
+
if(isset($ipn_response->shippingAddress))
|
624 |
+
{
|
625 |
+
$address_info = $ipn_response->shippingAddress
|
626 |
+
->ToArray();
|
627 |
+
//$address = $order->getBillingAddress();
|
628 |
+
$address = $order->getShippingAddress();
|
629 |
+
|
630 |
+
if(isset($address_info['name']))
|
631 |
+
{
|
632 |
+
$address->setFirstname($address_info['name']);
|
633 |
+
$address->setMiddlename('');
|
634 |
+
$address->setLastname('');
|
635 |
+
}
|
636 |
+
|
637 |
+
if(isset($address_info['streetAddress']))
|
638 |
+
{
|
639 |
+
$address->setStreet($address_info['streetAddress']);
|
640 |
+
}
|
641 |
+
|
642 |
+
if(isset($address_info['postalCode']))
|
643 |
+
{
|
644 |
+
$address->setPostcode($address_info['streetAddress']);
|
645 |
+
}
|
646 |
+
|
647 |
+
if(isset($address_info['city']))
|
648 |
+
{
|
649 |
+
$address->setCity($address_info['city']);
|
650 |
+
}
|
651 |
+
|
652 |
+
if(isset($address_info['country']))
|
653 |
+
{
|
654 |
+
// :(
|
655 |
+
$foo = array
|
656 |
+
(
|
657 |
+
'afghanistan' => 'AF',
|
658 |
+
'albania' => 'AL',
|
659 |
+
'algeria' => 'DZ',
|
660 |
+
'american samoa' => 'AS',
|
661 |
+
'andorra' => 'AD',
|
662 |
+
'angola' => 'AO',
|
663 |
+
'anguilla' => 'AI',
|
664 |
+
'antarctica' => 'AQ',
|
665 |
+
'antigua and barbuda' => 'AG',
|
666 |
+
'argentina' => 'AR',
|
667 |
+
'armenia' => 'AM',
|
668 |
+
'aruba' => 'AW',
|
669 |
+
'australia' => 'AU',
|
670 |
+
'austria' => 'AT',
|
671 |
+
'azerbaijan' => 'AZ',
|
672 |
+
'bahamas' => 'BS',
|
673 |
+
'bahrain' => 'BH',
|
674 |
+
'bangladesh' => 'BD',
|
675 |
+
'barbados' => 'BB',
|
676 |
+
'belarus' => 'BY',
|
677 |
+
'belgium' => 'BE',
|
678 |
+
'belize' => 'BZ',
|
679 |
+
'benin' => 'BJ',
|
680 |
+
'bermuda' => 'BM',
|
681 |
+
'bhutan' => 'BT',
|
682 |
+
'bolivia' => 'BO',
|
683 |
+
'bosnia and herzegovina' => 'BA',
|
684 |
+
'botswana' => 'BW',
|
685 |
+
'bouvet island' => 'BV',
|
686 |
+
'brazil' => 'BR',
|
687 |
+
'british indian ocean territory' => 'IO',
|
688 |
+
'brunei darussalam' => 'BN',
|
689 |
+
'bulgaria' => 'BG',
|
690 |
+
'burkina faso' => 'BF',
|
691 |
+
'burundi' => 'BI',
|
692 |
+
'cambodia' => 'KH',
|
693 |
+
'cameroon' => 'CM',
|
694 |
+
'canada' => 'CA',
|
695 |
+
'cape verde' => 'CV',
|
696 |
+
'cayman islands' => 'KY',
|
697 |
+
'central african republic' => 'CF',
|
698 |
+
'chad' => 'TD',
|
699 |
+
'chile' => 'CL',
|
700 |
+
'china' => 'CN',
|
701 |
+
'christmas island' => 'CX',
|
702 |
+
'cocos (keeling) islands' => 'CC',
|
703 |
+
'colombia' => 'CO',
|
704 |
+
'comoros' => 'KM',
|
705 |
+
'congo' => 'CG',
|
706 |
+
'congo, the democratic republic of the' => 'CD',
|
707 |
+
'cook islands' => 'CK',
|
708 |
+
'costa rica' => 'CR',
|
709 |
+
'cote d ivoire' => 'CI',
|
710 |
+
'croatia' => 'HR',
|
711 |
+
'cuba' => 'CU',
|
712 |
+
'cyprus' => 'CY',
|
713 |
+
'czech republic' => 'CZ',
|
714 |
+
'denmark' => 'DK',
|
715 |
+
'djibouti' => 'DJ',
|
716 |
+
'dominica' => 'DM',
|
717 |
+
'dominican republic' => 'DO',
|
718 |
+
'east timor' => 'TP',
|
719 |
+
'ecuador' => 'EC',
|
720 |
+
'egypt' => 'EG',
|
721 |
+
'el salvador' => 'SV',
|
722 |
+
'equatorial guinea' => 'GQ',
|
723 |
+
'eritrea' => 'ER',
|
724 |
+
'estonia' => 'EE',
|
725 |
+
'ethiopia' => 'ET',
|
726 |
+
'falkland islands (malvinas)' => 'FK',
|
727 |
+
'faroe islands' => 'FO',
|
728 |
+
'fiji' => 'FJ',
|
729 |
+
'finland' => 'FI',
|
730 |
+
'france' => 'FR',
|
731 |
+
'french guiana' => 'GF',
|
732 |
+
'french polynesia' => 'PF',
|
733 |
+
'french southern territories' => 'TF',
|
734 |
+
'gabon' => 'GA',
|
735 |
+
'gambia' => 'GM',
|
736 |
+
'georgia' => 'GE',
|
737 |
+
'germany' => 'DE',
|
738 |
+
'ghana' => 'GH',
|
739 |
+
'gibraltar' => 'GI',
|
740 |
+
'greece' => 'GR',
|
741 |
+
'greenland' => 'GL',
|
742 |
+
'grenada' => 'GD',
|
743 |
+
'guadeloupe' => 'GP',
|
744 |
+
'guam' => 'GU',
|
745 |
+
'guatemala' => 'GT',
|
746 |
+
'guinea' => 'GN',
|
747 |
+
'guinea-bissau' => 'GW',
|
748 |
+
'guyana' => 'GY',
|
749 |
+
'haiti' => 'HT',
|
750 |
+
'heard island and mcdonald islands' => 'HM',
|
751 |
+
'holy see (vatican city state)' => 'VA',
|
752 |
+
'honduras' => 'HN',
|
753 |
+
'hong kong' => 'HK',
|
754 |
+
'hungary' => 'HU',
|
755 |
+
'iceland' => 'IS',
|
756 |
+
'india' => 'IN',
|
757 |
+
'indonesia' => 'ID',
|
758 |
+
'iran, islamic republic of' => 'IR',
|
759 |
+
'iraq' => 'IQ',
|
760 |
+
'ireland' => 'IE',
|
761 |
+
'israel' => 'IL',
|
762 |
+
'italy' => 'IT',
|
763 |
+
'jamaica' => 'JM',
|
764 |
+
'japan' => 'JP',
|
765 |
+
'jordan' => 'JO',
|
766 |
+
'kazakstan' => 'KZ',
|
767 |
+
'kenya' => 'KE',
|
768 |
+
'kiribati' => 'KI',
|
769 |
+
'korea democratic peoples republic of' => 'KP',
|
770 |
+
'korea republic of' => 'KR',
|
771 |
+
'kuwait' => 'KW',
|
772 |
+
'kyrgyzstan' => 'KG',
|
773 |
+
'lao peoples democratic republic' => 'LA',
|
774 |
+
'latvia' => 'LV',
|
775 |
+
'lebanon' => 'LB',
|
776 |
+
'lesotho' => 'LS',
|
777 |
+
'liberia' => 'LR',
|
778 |
+
'libyan arab jamahiriya' => 'LY',
|
779 |
+
'liechtenstein' => 'LI',
|
780 |
+
'lithuania' => 'LT',
|
781 |
+
'luxembourg' => 'LU',
|
782 |
+
'macau' => 'MO',
|
783 |
+
'macedonia, the former yugoslav republic of' => 'MK',
|
784 |
+
'madagascar' => 'MG',
|
785 |
+
'malawi' => 'MW',
|
786 |
+
'malaysia' => 'MY',
|
787 |
+
'maldives' => 'MV',
|
788 |
+
'mali' => 'ML',
|
789 |
+
'malta' => 'MT',
|
790 |
+
'marshall islands' => 'MH',
|
791 |
+
'martinique' => 'MQ',
|
792 |
+
'mauritania' => 'MR',
|
793 |
+
'mauritius' => 'MU',
|
794 |
+
'mayotte' => 'YT',
|
795 |
+
'mexico' => 'MX',
|
796 |
+
'micronesia, federated states of' => 'FM',
|
797 |
+
'moldova, republic of' => 'MD',
|
798 |
+
'monaco' => 'MC',
|
799 |
+
'mongolia' => 'MN',
|
800 |
+
'montserrat' => 'MS',
|
801 |
+
'morocco' => 'MA',
|
802 |
+
'mozambique' => 'MZ',
|
803 |
+
'myanmar' => 'MM',
|
804 |
+
'namibia' => 'NA',
|
805 |
+
'nauru' => 'NR',
|
806 |
+
'nepal' => 'NP',
|
807 |
+
'netherlands' => 'NL',
|
808 |
+
'netherlands antilles' => 'AN',
|
809 |
+
'new caledonia' => 'NC',
|
810 |
+
'new zealand' => 'NZ',
|
811 |
+
'nicaragua' => 'NI',
|
812 |
+
'niger' => 'NE',
|
813 |
+
'nigeria' => 'NG',
|
814 |
+
'niue' => 'NU',
|
815 |
+
'norfolk island' => 'NF',
|
816 |
+
'northern mariana islands' => 'MP',
|
817 |
+
'norway' => 'NO',
|
818 |
+
'oman' => 'OM',
|
819 |
+
'pakistan' => 'PK',
|
820 |
+
'palau' => 'PW',
|
821 |
+
'palestinian territory, occupied' => 'PS',
|
822 |
+
'panama' => 'PA',
|
823 |
+
'papua new guinea' => 'PG',
|
824 |
+
'paraguay' => 'PY',
|
825 |
+
'peru' => 'PE',
|
826 |
+
'philippines' => 'PH',
|
827 |
+
'pitcairn' => 'PN',
|
828 |
+
'poland' => 'PL',
|
829 |
+
'portugal' => 'PT',
|
830 |
+
'puerto rico' => 'PR',
|
831 |
+
'qatar' => 'QA',
|
832 |
+
'reunion' => 'RE',
|
833 |
+
'romania' => 'RO',
|
834 |
+
'russian federation' => 'RU',
|
835 |
+
'rwanda' => 'RW',
|
836 |
+
'saint helena' => 'SH',
|
837 |
+
'saint kitts and nevis' => 'KN',
|
838 |
+
'saint lucia' => 'LC',
|
839 |
+
'saint pierre and miquelon' => 'PM',
|
840 |
+
'saint vincent and the grenadines' => 'VC',
|
841 |
+
'samoa' => 'WS',
|
842 |
+
'san marino' => 'SM',
|
843 |
+
'sao tome and principe' => 'ST',
|
844 |
+
'saudi arabia' => 'SA',
|
845 |
+
'senegal' => 'SN',
|
846 |
+
'seychelles' => 'SC',
|
847 |
+
'sierra leone' => 'SL',
|
848 |
+
'singapore' => 'SG',
|
849 |
+
'slovakia' => 'SK',
|
850 |
+
'slovenia' => 'SI',
|
851 |
+
'solomon islands' => 'SB',
|
852 |
+
'somalia' => 'SO',
|
853 |
+
'south africa' => 'ZA',
|
854 |
+
'south georgia and the south sandwich islands' => 'GS',
|
855 |
+
'spain' => 'ES',
|
856 |
+
'sri lanka' => 'LK',
|
857 |
+
'sudan' => 'SD',
|
858 |
+
'suriname' => 'SR',
|
859 |
+
'svalbard and jan mayen' => 'SJ',
|
860 |
+
'swaziland' => 'SZ',
|
861 |
+
'sweden' => 'SE',
|
862 |
+
'switzerland' => 'CH',
|
863 |
+
'syrian arab republic' => 'SY',
|
864 |
+
'taiwan, province of china' => 'TW',
|
865 |
+
'tajikistan' => 'TJ',
|
866 |
+
'tanzania, united republic of' => 'TZ',
|
867 |
+
'thailand' => 'TH',
|
868 |
+
'togo' => 'TG',
|
869 |
+
'tokelau' => 'TK',
|
870 |
+
'tonga' => 'TO',
|
871 |
+
'trinidad and tobago' => 'TT',
|
872 |
+
'tunisia' => 'TN',
|
873 |
+
'turkey' => 'TR',
|
874 |
+
'turkmenistan' => 'TM',
|
875 |
+
'turks and caicos islands' => 'TC',
|
876 |
+
'tuvalu' => 'TV',
|
877 |
+
'uganda' => 'UG',
|
878 |
+
'ukraine' => 'UA',
|
879 |
+
'united arab emirates' => 'AE',
|
880 |
+
'united kingdom' => 'GB',
|
881 |
+
'united states' => 'US',
|
882 |
+
'united states minor outlying islands' => 'UM',
|
883 |
+
'uruguay' => 'UY',
|
884 |
+
'uzbekistan' => 'UZ',
|
885 |
+
'vanuatu' => 'VU',
|
886 |
+
'venezuela' => 'VE',
|
887 |
+
'viet nam' => 'VN',
|
888 |
+
'virgin islands, british' => 'VG',
|
889 |
+
'virgin islands, u.s.' => 'VI',
|
890 |
+
'wallis and futuna' => 'WF',
|
891 |
+
'western sahara' => 'EH',
|
892 |
+
'yemen' => 'YE',
|
893 |
+
'yugoslavia' => 'YU',
|
894 |
+
'zambia' => 'ZM',
|
895 |
+
'zimbabwe' => 'ZW'
|
896 |
+
);
|
897 |
+
|
898 |
+
$address_info['country'] = strtolower(
|
899 |
+
$address_info['country']);
|
900 |
+
|
901 |
+
if(isset($foo[$address_info['country']]))
|
902 |
+
{
|
903 |
+
$address->setCountryId(
|
904 |
+
$foo[$address_info['country']]);
|
905 |
+
}
|
906 |
+
}
|
907 |
+
|
908 |
+
$address->save();
|
909 |
+
$order->addStatusHistoryComment(sprintf($helper->__(
|
910 |
+
'Payson updated the shipping address')));
|
911 |
+
}
|
912 |
+
}
|
913 |
+
else
|
914 |
+
{
|
915 |
+
$order->addStatusHistoryComment(sprintf(
|
916 |
+
$helper->__('Payson pinged the order with status %s'),
|
917 |
+
$ipn_response->status));
|
918 |
+
}
|
919 |
+
|
920 |
+
break;
|
921 |
+
}
|
922 |
+
case self::STATUS_INCOMPLETE:
|
923 |
+
case self::STATUS_ERROR:
|
924 |
+
case self::STATUS_EXPIRED:
|
925 |
+
case self::STATUS_REVERSALERROR:
|
926 |
+
default:
|
927 |
+
{
|
928 |
+
/*$order->setState(
|
929 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
930 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
931 |
+
sprintf($helper->__(
|
932 |
+
'Payson cancelled the order with status %s'),
|
933 |
+
$ipn_response->status))
|
934 |
+
->cancel();*/
|
935 |
+
$order->cancel();
|
936 |
+
}
|
937 |
+
}
|
938 |
+
|
939 |
+
$order->save();
|
940 |
+
|
941 |
+
// Update the database tables
|
942 |
+
$db->update($order_log_table,
|
943 |
+
array
|
944 |
+
(
|
945 |
+
'valid' => 1
|
946 |
+
),
|
947 |
+
array
|
948 |
+
(
|
949 |
+
'id = ?' => $order_log_id
|
950 |
+
));
|
951 |
+
|
952 |
+
$db->update($order_table,
|
953 |
+
array
|
954 |
+
(
|
955 |
+
'ipn_status' => $ipn_response->status
|
956 |
+
),
|
957 |
+
array
|
958 |
+
(
|
959 |
+
'id = ?' => $payson_order->id
|
960 |
+
));
|
961 |
+
|
962 |
+
return $this;
|
963 |
+
}
|
964 |
+
|
965 |
+
/**
|
966 |
+
* http://api.payson.se/#title12
|
967 |
+
*
|
968 |
+
* @params int $order_id Real order id
|
969 |
+
* @return object $this
|
970 |
+
*/
|
971 |
+
public function PaymentDetails($order_id)
|
972 |
+
{
|
973 |
+
$helper = Mage::helper('payson');
|
974 |
+
|
975 |
+
// Get the database connection
|
976 |
+
$resource = Mage::getSingleton('core/resource');
|
977 |
+
$db = $resource->getConnection('core_write');
|
978 |
+
|
979 |
+
$order_table = $resource->getTableName('payson_order');
|
980 |
+
$order_log_table = $resource->getTableName('payson_order_log');
|
981 |
+
|
982 |
+
/* Save fetch mode so that we can reset it and not mess up Magento
|
983 |
+
functionality */
|
984 |
+
$old_fetch_mode = $db->getFetchMode();
|
985 |
+
$db->setFetchMode(Zend_Db::FETCH_OBJ);
|
986 |
+
|
987 |
+
// Get payson order information and validate token
|
988 |
+
$payson_order = $db->fetchRow(
|
989 |
+
'SELECT
|
990 |
+
id,
|
991 |
+
token,
|
992 |
+
store_id
|
993 |
+
FROM
|
994 |
+
`' . $order_table . '`
|
995 |
+
WHERE
|
996 |
+
valid = 1
|
997 |
+
AND
|
998 |
+
order_id = ?
|
999 |
+
LIMIT
|
1000 |
+
0,1', $order_id);
|
1001 |
+
|
1002 |
+
if($payson_order === false)
|
1003 |
+
{
|
1004 |
+
Mage::throwException('Invalid order id (' . $order_id . ')');
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
$db->setFetchMode($old_fetch_mode);
|
1008 |
+
|
1009 |
+
$args = array
|
1010 |
+
(
|
1011 |
+
'token' => $payson_order->token
|
1012 |
+
);
|
1013 |
+
$url = vsprintf(self::API_CALL_PAYMENT_DETAILS, $this->GetFormatIfTest($payson_order->store_id));
|
1014 |
+
$client = $this->GetHttpClient($url)
|
1015 |
+
->setParameterPost($args);
|
1016 |
+
|
1017 |
+
$response = Payson_Payson_Helper_Api_Response_Standard
|
1018 |
+
::FromHttpBody($client->request()->getBody());
|
1019 |
+
|
1020 |
+
$this->SetResponse($response);
|
1021 |
+
|
1022 |
+
$db->insert($order_log_table, array
|
1023 |
+
(
|
1024 |
+
'payson_order_id' => $payson_order->id,
|
1025 |
+
'added' => new Zend_Db_Expr('NOW()'),
|
1026 |
+
'api_call' => 'payment_details',
|
1027 |
+
'valid' => (int)$response->IsValid(),
|
1028 |
+
'response' => serialize($response->ToArray())
|
1029 |
+
));
|
1030 |
+
|
1031 |
+
if(!$response->IsValid())
|
1032 |
+
{
|
1033 |
+
throw new Mage_Core_Exception(sprintf($helper->__(
|
1034 |
+
'Failed to retrieve payment details. Payson replied: %s'),
|
1035 |
+
$response->GetError()), $response->GetErrorId());
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
return $this;
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
/**
|
1042 |
+
* http://api.payson.se/#title13
|
1043 |
+
*
|
1044 |
+
* @params int $order_id Real order id
|
1045 |
+
* @params string $action
|
1046 |
+
* @return object $this
|
1047 |
+
*/
|
1048 |
+
public function PaymentUpdate($order_id, $action)
|
1049 |
+
{
|
1050 |
+
$helper = Mage::helper('payson');
|
1051 |
+
|
1052 |
+
// Get the database connection
|
1053 |
+
$resource = Mage::getSingleton('core/resource');
|
1054 |
+
$db = $resource->getConnection('core_write');
|
1055 |
+
|
1056 |
+
$order_table = $resource->getTableName('payson_order');
|
1057 |
+
$order_log_table = $resource->getTableName('payson_order_log');
|
1058 |
+
|
1059 |
+
/* Save fetch mode so that we can reset it and not mess up Magento
|
1060 |
+
functionality */
|
1061 |
+
$old_fetch_mode = $db->getFetchMode();
|
1062 |
+
$db->setFetchMode(Zend_Db::FETCH_OBJ);
|
1063 |
+
|
1064 |
+
// Get payson order information and validate token
|
1065 |
+
$payson_order = $db->fetchRow(
|
1066 |
+
'SELECT
|
1067 |
+
id,
|
1068 |
+
token,
|
1069 |
+
store_id
|
1070 |
+
FROM
|
1071 |
+
`' . $order_table . '`
|
1072 |
+
WHERE
|
1073 |
+
valid = 1
|
1074 |
+
AND
|
1075 |
+
order_id = ?
|
1076 |
+
LIMIT
|
1077 |
+
0,1', $order_id);
|
1078 |
+
|
1079 |
+
if($payson_order === false)
|
1080 |
+
{
|
1081 |
+
Mage::throwException('Invalid order id (' . $order_id . ')');
|
1082 |
+
}
|
1083 |
+
|
1084 |
+
$db->setFetchMode($old_fetch_mode);
|
1085 |
+
|
1086 |
+
$args = array
|
1087 |
+
(
|
1088 |
+
'token' => $payson_order->token,
|
1089 |
+
'action' => $action
|
1090 |
+
);
|
1091 |
+
|
1092 |
+
$client = $this->GetHttpClient(vsprintf(self::API_CALL_PAYMENT_UPDATE, $this->GetFormatIfTest($payson_order->store_id)))
|
1093 |
+
->setParameterPost($args);
|
1094 |
+
|
1095 |
+
$response = Payson_Payson_Helper_Api_Response_Standard
|
1096 |
+
::FromHttpBody($client->request()->getBody());
|
1097 |
+
|
1098 |
+
$this->SetResponse($response);
|
1099 |
+
|
1100 |
+
$db->insert($order_log_table, array
|
1101 |
+
(
|
1102 |
+
'payson_order_id' => $payson_order->id,
|
1103 |
+
'added' => new Zend_Db_Expr('NOW()'),
|
1104 |
+
'api_call' => 'payment_update',
|
1105 |
+
'valid' => (int)$response->IsValid(),
|
1106 |
+
'response' => serialize($response->ToArray())
|
1107 |
+
));
|
1108 |
+
|
1109 |
+
/*if(!$response->IsValid())
|
1110 |
+
{
|
1111 |
+
// TODO: don't seem to return an errorList
|
1112 |
+
throw new Mage_Core_Exception(sprintf($helper->__(
|
1113 |
+
'Failed to update payment. Payson replied: %s'),
|
1114 |
+
$response->GetError()), $response->GetErrorId());
|
1115 |
+
}*/
|
1116 |
+
|
1117 |
+
return $this;
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
private function GetFormatIfTest($storeID = null, $isForwardURL = FALSE)
|
1121 |
+
{
|
1122 |
+
$config = Mage::getModel('payson/config');
|
1123 |
+
$stack = array();
|
1124 |
+
/* @var $isTest bool */
|
1125 |
+
$isTest = ($config->get('test_mode', $storeID) == "1");
|
1126 |
+
|
1127 |
+
array_push($stack, self::DEBUG_MODE ? "http" : "https");
|
1128 |
+
array_push($stack, $isTest && !self::DEBUG_MODE ? "test-" : (self::DEBUG_MODE && !$isForwardURL ? "mvc" : ""));
|
1129 |
+
|
1130 |
+
if($isForwardURL == true)
|
1131 |
+
{
|
1132 |
+
array_push($stack, self::DEBUG_MODE ? "app" : "www");
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
array_push($stack, self::DEBUG_MODE ? "local" : "se");
|
1136 |
+
array_push($stack, self::DEBUG_MODE ? "Payment" : "1.0");
|
1137 |
+
|
1138 |
+
array_push($stack, self::DEBUG_MODE ? "" : "Payment");
|
1139 |
+
|
1140 |
+
return $stack;
|
1141 |
+
|
1142 |
+
|
1143 |
+
}
|
1144 |
+
}
|
1145 |
+
|
app/code/community/Payson/Payson/Helper/Api/Response/Interface.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
interface Payson_Payson_Helper_Api_Response_Interface
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Construct a response object from a string
|
6 |
+
*
|
7 |
+
* @param string $body
|
8 |
+
* @return object
|
9 |
+
*/
|
10 |
+
public static function FromHttpBody($body);
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Whether this response is valid
|
14 |
+
*
|
15 |
+
* @return bool
|
16 |
+
*/
|
17 |
+
public function IsValid();
|
18 |
+
}
|
19 |
+
|
app/code/community/Payson/Payson/Helper/Api/Response/Standard.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Helper_Api_Response_Standard
|
3 |
+
extends Payson_Payson_Helper_Api_Response_Standard_Parameters
|
4 |
+
implements Payson_Payson_Helper_Api_Response_Interface
|
5 |
+
{
|
6 |
+
/*
|
7 |
+
* Constants
|
8 |
+
*/
|
9 |
+
|
10 |
+
const ACK_SUCCESS = 'SUCCESS';
|
11 |
+
const ACK_FAILURE = 'FAILURE';
|
12 |
+
|
13 |
+
/*
|
14 |
+
* Public methods
|
15 |
+
*/
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Parse response object and instantiate
|
19 |
+
*
|
20 |
+
* @param string $response
|
21 |
+
* @return object
|
22 |
+
*/
|
23 |
+
static public function FromHttpBody($body)
|
24 |
+
{
|
25 |
+
$params = array();
|
26 |
+
parse_str($body, $params);
|
27 |
+
|
28 |
+
foreach($params as $key => $value)
|
29 |
+
{
|
30 |
+
$sub_key = strtok($key, '_');
|
31 |
+
|
32 |
+
if($sub_key === $key)
|
33 |
+
{
|
34 |
+
continue;
|
35 |
+
}
|
36 |
+
|
37 |
+
$current = &$params;
|
38 |
+
|
39 |
+
do
|
40 |
+
{
|
41 |
+
$matches = array();
|
42 |
+
|
43 |
+
if(preg_match('/\((\d)\)$/', $sub_key, $matches) === 1)
|
44 |
+
{
|
45 |
+
$sub_key = substr($sub_key, 0, -3);
|
46 |
+
|
47 |
+
if(!strlen($sub_key))
|
48 |
+
{
|
49 |
+
continue;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
if(!isset($current[$sub_key]) || !is_array($current[$sub_key]))
|
54 |
+
{
|
55 |
+
$current[$sub_key] = array();
|
56 |
+
}
|
57 |
+
|
58 |
+
$current = &$current[$sub_key];
|
59 |
+
|
60 |
+
if(isset($matches[1]))
|
61 |
+
{
|
62 |
+
if(!isset($current[$matches[1]]) ||
|
63 |
+
!is_array($current[$matches[1]]))
|
64 |
+
{
|
65 |
+
$current[$matches[1]] = array();
|
66 |
+
}
|
67 |
+
|
68 |
+
$current = &$current[$matches[1]];
|
69 |
+
}
|
70 |
+
}
|
71 |
+
while(($sub_key = strtok('_')) !== false);
|
72 |
+
|
73 |
+
$current = $value;
|
74 |
+
|
75 |
+
unset($params[$key]);
|
76 |
+
}
|
77 |
+
|
78 |
+
return new self($params);
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Populate parameters
|
83 |
+
*
|
84 |
+
* @param array $params
|
85 |
+
* @return void
|
86 |
+
*/
|
87 |
+
public function __construct(array $params)
|
88 |
+
{
|
89 |
+
if(empty($params))
|
90 |
+
{
|
91 |
+
Mage::throwException('Invalid response');
|
92 |
+
}
|
93 |
+
|
94 |
+
parent::__construct($params);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @inheritDoc
|
99 |
+
*/
|
100 |
+
public function IsValid()
|
101 |
+
{
|
102 |
+
return (isset($this->responseEnvelope->ack) &&
|
103 |
+
($this->responseEnvelope->ack === self::ACK_SUCCESS));
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Compile all errors into a string
|
108 |
+
*
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
public function GetError()
|
112 |
+
{
|
113 |
+
$ret = '';
|
114 |
+
|
115 |
+
if(isset($this->errorList->error))
|
116 |
+
{
|
117 |
+
foreach($this->errorList->error->ToArray() as $error)
|
118 |
+
{
|
119 |
+
if(isset($error['parameter']))
|
120 |
+
{
|
121 |
+
$ret .= $error['parameter'] . ' ';
|
122 |
+
}
|
123 |
+
|
124 |
+
$ret .= '(' . $error['errorId'] . ') ' .
|
125 |
+
$error['message'] . ' ';
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return rtrim($ret);
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Get first error id
|
134 |
+
*
|
135 |
+
* @return int|null
|
136 |
+
*/
|
137 |
+
public function GetErrorId()
|
138 |
+
{
|
139 |
+
if(isset($this->errorList->error))
|
140 |
+
{
|
141 |
+
foreach($this->errorList->error->ToArray() as $error)
|
142 |
+
{
|
143 |
+
if(isset($error['errorId']))
|
144 |
+
{
|
145 |
+
return (int)$error['errorId'];
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
return null;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
app/code/community/Payson/Payson/Helper/Api/Response/Standard/Parameters.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Helper_Api_Response_Standard_Parameters
|
3 |
+
{
|
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 |
+
{
|
27 |
+
foreach($params as $key => $value)
|
28 |
+
{
|
29 |
+
if(is_array($value))
|
30 |
+
{
|
31 |
+
$this->params[$key] = new self($value);
|
32 |
+
}
|
33 |
+
else
|
34 |
+
{
|
35 |
+
$this->params[$key] = $value;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
public function __get($name)
|
41 |
+
{
|
42 |
+
return (isset($this->params[$name]) ? $this->params[$name] : null);
|
43 |
+
}
|
44 |
+
|
45 |
+
public function __set($name, $value)
|
46 |
+
{
|
47 |
+
$this->params[$name] = $value;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function __isset($name)
|
51 |
+
{
|
52 |
+
return isset($this->params[$name]);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Compile the parameters into an array
|
57 |
+
*
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
public function ToArray()
|
61 |
+
{
|
62 |
+
foreach($this->params as $key => $value)
|
63 |
+
{
|
64 |
+
if($value instanceof
|
65 |
+
Payson_Payson_Helper_Api_Response_Standard_Parameters)
|
66 |
+
{
|
67 |
+
$arr[$key] = $value->ToArray();
|
68 |
+
}
|
69 |
+
else
|
70 |
+
{
|
71 |
+
$arr[$key] = $value;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
return $arr;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
app/code/community/Payson/Payson/Helper/Api/Response/Validate.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Helper_Api_Response_Validate
|
3 |
+
implements Payson_Payson_Helper_Api_Response_Interface
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* Constants
|
7 |
+
*/
|
8 |
+
|
9 |
+
const VERIFIED = 'VERIFIED';
|
10 |
+
const INVALID = 'INVALID';
|
11 |
+
|
12 |
+
/*
|
13 |
+
* Private properties
|
14 |
+
*/
|
15 |
+
|
16 |
+
private $data;
|
17 |
+
|
18 |
+
/*
|
19 |
+
* Public methods
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @inheritDoc
|
24 |
+
*/
|
25 |
+
static public function FromHttpBody($data)
|
26 |
+
{
|
27 |
+
return new self($data);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Constructor!
|
32 |
+
*
|
33 |
+
* @param string $data
|
34 |
+
* @return void
|
35 |
+
*/
|
36 |
+
public function __construct($data)
|
37 |
+
{
|
38 |
+
$this->data = $data;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @inheritDoc
|
43 |
+
*/
|
44 |
+
public function IsValid()
|
45 |
+
{
|
46 |
+
return ($this->data === self::VERIFIED);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
app/code/community/Payson/Payson/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Payson/Payson/Model/Config.php
ADDED
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Config
|
3 |
+
{
|
4 |
+
/*
|
5 |
+
* Constants
|
6 |
+
*/
|
7 |
+
|
8 |
+
//const PAYMENT_GUARANTEE = 'payment_guarantee';
|
9 |
+
const PAYMENT_GUARANTEE = 'NO';
|
10 |
+
|
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 |
+
public function __construct()
|
46 |
+
{
|
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 |
+
{
|
81 |
+
return in_array(strtoupper($currency), $this->supported_currencies);
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Get configuration value
|
86 |
+
*
|
87 |
+
* @param mixed $name
|
88 |
+
* @param int|null $store [optional]
|
89 |
+
* @param mixed $default [optional]
|
90 |
+
* @param string $prefix [optional]
|
91 |
+
*/
|
92 |
+
public function GetConfig($name, $store = null, $default = null,
|
93 |
+
$prefix = 'payment/payson_standard/')
|
94 |
+
{
|
95 |
+
if(!isset($store))
|
96 |
+
{
|
97 |
+
$store = $this->GetDefaultStoreId();
|
98 |
+
}
|
99 |
+
|
100 |
+
$name = $prefix . $name;
|
101 |
+
// Mage::getStoreConfigFlag
|
102 |
+
$value = Mage::getStoreConfig($name, $store);
|
103 |
+
|
104 |
+
return (isset($value) ? $value : $default);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @see GetConfig
|
109 |
+
*/
|
110 |
+
public function Get($name, $store = null, $default = null,
|
111 |
+
$prefix = 'payment/payson_standard/')
|
112 |
+
{
|
113 |
+
return $this->GetConfig($name, $store, $default, $prefix);
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Get Payson specific invoice fee excluding tax
|
118 |
+
*
|
119 |
+
* @param object $order
|
120 |
+
* @return float
|
121 |
+
*/
|
122 |
+
public function GetInvoiceFee($order)
|
123 |
+
{
|
124 |
+
$currency = $order->getBaseCurrencyCode();
|
125 |
+
$currency = strtolower($currency);
|
126 |
+
|
127 |
+
if(!$this->IsCurrencySupported($currency))
|
128 |
+
{
|
129 |
+
return 0;
|
130 |
+
}
|
131 |
+
|
132 |
+
$store = Mage::app()->getStore($order->getStoreId());
|
133 |
+
|
134 |
+
$fee = $this->GetConfig('invoice_fee_' . $currency, $store->getId(), 0,
|
135 |
+
'payment/payson_invoice/');
|
136 |
+
$fee = round((float)$fee, 3);
|
137 |
+
|
138 |
+
return $fee;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Get Payson specific invoice fee including tax
|
143 |
+
*
|
144 |
+
* @param object $order
|
145 |
+
* @return float
|
146 |
+
*/
|
147 |
+
public function GetInvoiceFeeInclTax($order)
|
148 |
+
{
|
149 |
+
$fee = $this->GetInvoiceFee($order);
|
150 |
+
$fee *= (1 + $this->GetInvoiceFeeTaxMod($order));
|
151 |
+
$fee = round($fee, 3);
|
152 |
+
|
153 |
+
return $fee;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Get Payson specific invoice fee tax modifier
|
158 |
+
*
|
159 |
+
* @param object $order
|
160 |
+
* @return float
|
161 |
+
*/
|
162 |
+
public function GetInvoiceFeeTaxMod($order)
|
163 |
+
{
|
164 |
+
$store = Mage::app()->getStore($order->getStoreId());
|
165 |
+
|
166 |
+
$tax_calc = Mage::getSingleton('tax/calculation');
|
167 |
+
$customer = Mage::getModel('customer/customer')
|
168 |
+
->load($order->getCustomerId());
|
169 |
+
|
170 |
+
$tax_class = $this->GetConfig('invoice_fee_tax', $store->getId(), 0,
|
171 |
+
'payment/payson_invoice/');
|
172 |
+
|
173 |
+
$tax_rate_req = $tax_calc->getRateRequest(
|
174 |
+
$order->getShippingAddress(),
|
175 |
+
$order->getBillingAddress(),
|
176 |
+
$customer->getTaxClassId(),
|
177 |
+
$store)
|
178 |
+
->setProductClassId($tax_class);
|
179 |
+
|
180 |
+
$tax_mod = (float)$tax_calc->getRate($tax_rate_req);
|
181 |
+
$tax_mod /= 100;
|
182 |
+
$tax_mod = round($tax_mod, 5);
|
183 |
+
|
184 |
+
return $tax_mod;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Does this store support payment guarantee?
|
189 |
+
*
|
190 |
+
* @param int|null $store [optional]
|
191 |
+
* @return bool
|
192 |
+
*/
|
193 |
+
public function CanPaymentGuarantee($store = null)
|
194 |
+
{
|
195 |
+
return (bool)$this->GetConfig(self::PAYMENT_GUARANTEE, $store, false);
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Is standard payment enabled?
|
200 |
+
*
|
201 |
+
* @param int|null $store [optional]
|
202 |
+
* @return bool
|
203 |
+
*/
|
204 |
+
public function CanStandardPayment($store = null)
|
205 |
+
{
|
206 |
+
return $this->GetConfig('active', $store, false,
|
207 |
+
'payment/payson_standard/');
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Is invoice payment enabled?
|
212 |
+
*
|
213 |
+
* @param int|null $store [optional]
|
214 |
+
* @return bool
|
215 |
+
*/
|
216 |
+
public function CanInvoicePayment($store = null)
|
217 |
+
{
|
218 |
+
/*if(!$this->CanStandardPayment($store))
|
219 |
+
{
|
220 |
+
return false;
|
221 |
+
}*/
|
222 |
+
|
223 |
+
return $this->GetConfig('active', $store, false,
|
224 |
+
'payment/payson_invoice/');
|
225 |
+
}
|
226 |
+
|
227 |
+
public function ActivateInvoiceOnPurchase($store = null)
|
228 |
+
{
|
229 |
+
return $this->GetConfig('activate_invoice', $store, false,
|
230 |
+
'payment/payson_invoice/');
|
231 |
+
}
|
232 |
+
|
233 |
+
|
234 |
+
}
|
235 |
+
|
app/code/community/Payson/Payson/Model/Method/Abstract.php
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
abstract class Payson_Payson_Model_Method_Abstract
|
3 |
+
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 = false;
|
28 |
+
|
29 |
+
/*
|
30 |
+
* Protected methods
|
31 |
+
*/
|
32 |
+
|
33 |
+
protected function GetCheckout()
|
34 |
+
{
|
35 |
+
return Mage::getSingleton('checkout/session');
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function GetQuote()
|
39 |
+
{
|
40 |
+
return $this->GetCheckout()->getQuote();
|
41 |
+
}
|
42 |
+
|
43 |
+
/*
|
44 |
+
* Public methods
|
45 |
+
*/
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Redirect url when user place order
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function getOrderPlaceRedirectUrl()
|
53 |
+
{
|
54 |
+
return Mage::getUrl('payson/checkout/redirect',
|
55 |
+
array('_secure' => true));
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @inheritDoc
|
60 |
+
*/
|
61 |
+
/*public function initialize($payment_action, $state_object)
|
62 |
+
{
|
63 |
+
$state_object->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
64 |
+
$state_object->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
65 |
+
$state_object->setIsNotified(false);
|
66 |
+
|
67 |
+
return $this;
|
68 |
+
}*/
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Whether this paymend method is available for specified currency
|
72 |
+
*
|
73 |
+
* @param string $currency
|
74 |
+
* @return bool
|
75 |
+
*/
|
76 |
+
public function canUseForCurrency($currency)
|
77 |
+
{
|
78 |
+
return Mage::getModel('payson/config')->IsCurrencySupported($currency);
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @inheritDoc
|
83 |
+
*/
|
84 |
+
public function refund(Varien_Object $payment, $amount)
|
85 |
+
{
|
86 |
+
|
87 |
+
/* @var $order Mage_Sales_Model_Order */
|
88 |
+
$order = $payment->getOrder();
|
89 |
+
|
90 |
+
$method = $payment->getMethod();
|
91 |
+
|
92 |
+
if($order->getBaseGrandTotal() != $amount)
|
93 |
+
{
|
94 |
+
Mage::throwException('Invalid amount');
|
95 |
+
}
|
96 |
+
|
97 |
+
$helper = Mage::helper('payson');
|
98 |
+
$order_id = $order->getData('increment_id');
|
99 |
+
$api = Mage::helper('payson/api');
|
100 |
+
|
101 |
+
$api->PaymentUpdate($order_id, $method == "payson_invoice" ?
|
102 |
+
Payson_Payson_Helper_Api::UPDATE_ACTION_CREDITORDER :
|
103 |
+
Payson_Payson_Helper_Api::UPDATE_ACTION_REFUNDORDER);
|
104 |
+
|
105 |
+
$order->addStatusHistoryComment($helper->__(
|
106 |
+
'Payment was credited at Payson'));
|
107 |
+
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @inheritDoc
|
113 |
+
*/
|
114 |
+
public function void(Varien_Object $payment)
|
115 |
+
{
|
116 |
+
$payment->setTransactionId('auth')
|
117 |
+
->setIsTransactionClosed(0);
|
118 |
+
return $this;
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @inheritDoc
|
124 |
+
*/
|
125 |
+
public function cancel(Varien_Object $payment)
|
126 |
+
{
|
127 |
+
$order = $payment->getOrder();
|
128 |
+
$order_id = $order->getData('increment_id');
|
129 |
+
|
130 |
+
$api = Mage::helper('payson/api');
|
131 |
+
$helper = Mage::helper('payson');
|
132 |
+
$api->PaymentDetails($order_id);
|
133 |
+
$details = $api->GetResponse();
|
134 |
+
|
135 |
+
if(($details->type === Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE) ||
|
136 |
+
($details->invoiceStatus === Payson_Payson_Helper_Api::INVOICE_STATUS_ORDERCREATED) ||
|
137 |
+
($details->type !== Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE && $details->status === Payson_Payson_Helper_Api::STATUS_CREATED) ||
|
138 |
+
$order->getState() === Mage_Sales_Model_Order::STATE_PROCESSING)
|
139 |
+
{
|
140 |
+
$api->PaymentUpdate($order_id,
|
141 |
+
Payson_Payson_Helper_Api::UPDATE_ACTION_CANCELORDER);
|
142 |
+
|
143 |
+
$order->addStatusHistoryComment($helper->__(
|
144 |
+
'Order was canceled at Payson'));
|
145 |
+
|
146 |
+
$payment->setTransactionId('auth')
|
147 |
+
->setIsTransactionClosed(1);
|
148 |
+
//->setShouldCloseParentTransaction(1);
|
149 |
+
}
|
150 |
+
else
|
151 |
+
{
|
152 |
+
Mage::throwException($helper->__('Payson is not ready to cancel the order. Please try again later.'));
|
153 |
+
}
|
154 |
+
|
155 |
+
return $this;
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Is run when payment method is selected
|
161 |
+
*
|
162 |
+
* @return void
|
163 |
+
*/
|
164 |
+
/*public function validate()
|
165 |
+
{
|
166 |
+
$session = Mage::getSingleton('checkout/session');
|
167 |
+
|
168 |
+
if(isset($_POST['payment']['method']))
|
169 |
+
{
|
170 |
+
$session->setData('payson_payment_method',
|
171 |
+
$_POST['payment']['method']);
|
172 |
+
}
|
173 |
+
else
|
174 |
+
{
|
175 |
+
$session->unsetData('payson_payment_method');
|
176 |
+
}
|
177 |
+
}*/
|
178 |
+
}
|
179 |
+
|
app/code/community/Payson/Payson/Model/Method/Invoice.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Method_Invoice
|
3 |
+
extends Payson_Payson_Model_Method_Abstract
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* Protected properties
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @inheritDoc
|
11 |
+
*/
|
12 |
+
protected $_code = 'payson_invoice';
|
13 |
+
protected $_formBlockType = 'payson/invoice_form';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @inheritDoc
|
17 |
+
*/
|
18 |
+
protected $_canCapture = true;
|
19 |
+
protected $_canRefund = true;
|
20 |
+
protected $_canVoid = true;
|
21 |
+
|
22 |
+
/*
|
23 |
+
* Public methods
|
24 |
+
*/
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @inheritDoc
|
28 |
+
*/
|
29 |
+
public function capture(Varien_Object $payment, $amount)
|
30 |
+
{
|
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 |
+
{
|
44 |
+
$api->PaymentUpdate($order_id,
|
45 |
+
Payson_Payson_Helper_Api::UPDATE_ACTION_SHIPORDER);
|
46 |
+
|
47 |
+
$order->addStatusHistoryComment($helper->__(
|
48 |
+
'Order was activated at Payson'));
|
49 |
+
}
|
50 |
+
else
|
51 |
+
{
|
52 |
+
Mage::throwException($helper->__('Payson is not ready to create an invoice. Please try again later.'));
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @inheritDoc
|
60 |
+
*/
|
61 |
+
public function authorize(Varien_Object $payment, $amount)
|
62 |
+
{
|
63 |
+
$payment->setTransactionId('auth')->setIsTransactionClosed(0);
|
64 |
+
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @inheritDoc
|
72 |
+
*/
|
73 |
+
public function getTitle()
|
74 |
+
{
|
75 |
+
$order = Mage::registry('current_order');
|
76 |
+
|
77 |
+
if(!isset($order) && ($invoice = Mage::registry('current_invoice')))
|
78 |
+
{
|
79 |
+
$order = $invoice->getOrder();
|
80 |
+
}
|
81 |
+
|
82 |
+
if(isset($order))
|
83 |
+
{
|
84 |
+
$invoice_fee = $order->getPaysonInvoiceFee();
|
85 |
+
|
86 |
+
if($invoice_fee)
|
87 |
+
{
|
88 |
+
$invoice_fee = $order->formatPrice($invoice_fee);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
else
|
92 |
+
{
|
93 |
+
$invoice_fee = Mage::getModel('payson/config')
|
94 |
+
->GetInvoiceFeeInclTax($this->getQuote());
|
95 |
+
|
96 |
+
if($invoice_fee)
|
97 |
+
{
|
98 |
+
$invoice_fee = Mage::app()->getStore()
|
99 |
+
->formatPrice($invoice_fee);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
$invoice_fee = strip_tags($invoice_fee);
|
104 |
+
|
105 |
+
return sprintf(Mage::helper('payson')
|
106 |
+
->__('Checkout with Payson invoice %s'),
|
107 |
+
($invoice_fee ? '(+' . $invoice_fee . ')' : ''));
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
app/code/community/Payson/Payson/Model/Method/Standard.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Method_Standard
|
3 |
+
extends Payson_Payson_Model_Method_Abstract
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* Protected properties
|
7 |
+
*/
|
8 |
+
protected $_canCapture = true;
|
9 |
+
protected $_canRefund = true;
|
10 |
+
protected $_canVoid = true;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @inheritDoc
|
14 |
+
*/
|
15 |
+
protected $_code = 'payson_standard';
|
16 |
+
protected $_formBlockType = 'payson/standard_form';
|
17 |
+
|
18 |
+
/*
|
19 |
+
* Public methods
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @inheritDoc
|
24 |
+
*/
|
25 |
+
public function getTitle()
|
26 |
+
{
|
27 |
+
return Mage::helper('payson')->__('Checkout with Payson');
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @inheritDoc
|
32 |
+
*/
|
33 |
+
public function authorize(Varien_Object $payment, $amount)
|
34 |
+
{
|
35 |
+
$payment->setTransactionId('auth')->setIsTransactionClosed(0);
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
app/code/community/Payson/Payson/Model/Mysql4/Setup.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/community/Payson/Payson/Model/Order/Creditmemo/Total/Invoice.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Order_Creditmemo_Total_Invoice extends
|
3 |
+
Mage_Sales_Model_Order_Creditmemo_Total_Abstract
|
4 |
+
{
|
5 |
+
protected $_code = 'payson_invoice';
|
6 |
+
|
7 |
+
public function collect(Mage_Sales_Model_Order_Creditmemo $invoice)
|
8 |
+
{
|
9 |
+
$order = $invoice->getOrder();
|
10 |
+
|
11 |
+
$method = $order->getPayment()->getMethodInstance()->getCode(); /* Should be getMethod() */
|
12 |
+
|
13 |
+
if($method !== 'payson_invoice')
|
14 |
+
{
|
15 |
+
return $this;
|
16 |
+
}
|
17 |
+
|
18 |
+
/*if($order->hasInvoices() !== 0)
|
19 |
+
{
|
20 |
+
return $this;
|
21 |
+
}*/
|
22 |
+
|
23 |
+
$base_fee = $order->getBasePaysonInvoiceFee();
|
24 |
+
$fee = $order->getPaysonInvoiceFee();
|
25 |
+
|
26 |
+
if(!$base_fee || !$fee)
|
27 |
+
{
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
$base_grand_total = $invoice->getBaseGrandTotal();
|
32 |
+
$base_grand_total += $base_fee;
|
33 |
+
$grand_total = $invoice->getGrandTotal();
|
34 |
+
$grand_total += $fee;
|
35 |
+
|
36 |
+
$invoice->setBasePaysonInvoiceFee($base_fee);
|
37 |
+
$invoice->setPaysonInvoiceFee($fee);
|
38 |
+
|
39 |
+
$invoice->setBaseGrandTotal($base_grand_total);
|
40 |
+
$invoice->setGrandTotal($grand_total);
|
41 |
+
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
app/code/community/Payson/Payson/Model/Order/Invoice/Total/Invoice.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Order_Invoice_Total_Invoice extends
|
3 |
+
Mage_Sales_Model_Order_Invoice_Total_Abstract
|
4 |
+
{
|
5 |
+
protected $_code = 'payson_invoice';
|
6 |
+
|
7 |
+
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
|
8 |
+
{
|
9 |
+
$order = $invoice->getOrder();
|
10 |
+
|
11 |
+
$method = $order->getPayment()->getMethodInstance()->getCode(); /* Should be getMethod() */
|
12 |
+
|
13 |
+
if($method !== 'payson_invoice')
|
14 |
+
{
|
15 |
+
return $this;
|
16 |
+
}
|
17 |
+
|
18 |
+
if($order->hasInvoices() !== 0)
|
19 |
+
{
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
$base_fee = $order->getBasePaysonInvoiceFee();
|
24 |
+
$fee = $order->getPaysonInvoiceFee();
|
25 |
+
|
26 |
+
if(!$base_fee || !$fee)
|
27 |
+
{
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
$base_grand_total = $invoice->getBaseGrandTotal();
|
32 |
+
$base_grand_total += $base_fee;
|
33 |
+
$grand_total = $invoice->getGrandTotal();
|
34 |
+
$grand_total += $fee;
|
35 |
+
|
36 |
+
$invoice->setBasePaysonInvoiceFee($base_fee);
|
37 |
+
$invoice->setPaysonInvoiceFee($fee);
|
38 |
+
|
39 |
+
$invoice->setBaseGrandTotal($base_grand_total);
|
40 |
+
$invoice->setGrandTotal($grand_total);
|
41 |
+
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
app/code/community/Payson/Payson/Model/Quote/Address/Total/Invoice.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Quote_Address_Total_Invoice extends
|
3 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract
|
4 |
+
{
|
5 |
+
protected $_code = 'payson_invoice';
|
6 |
+
|
7 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
8 |
+
{
|
9 |
+
if($address->getAddressType() !== 'shipping')
|
10 |
+
{
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
$address->setBasePaysonInvoiceFee(0);
|
15 |
+
$address->setPaysonInvoiceFee(0);
|
16 |
+
|
17 |
+
$quote = $address->getQuote();
|
18 |
+
|
19 |
+
if(is_null($quote->getId()))
|
20 |
+
{
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
|
24 |
+
$method = $address->getQuote()->getPayment()->getMethod();
|
25 |
+
|
26 |
+
if($method !== 'payson_invoice')
|
27 |
+
{
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
$store = $quote->getStore();
|
32 |
+
$config = Mage::getModel('payson/config');
|
33 |
+
|
34 |
+
$fee = $config->GetInvoiceFeeInclTax($quote);
|
35 |
+
|
36 |
+
$base_grand_total = $address->getBaseGrandTotal();
|
37 |
+
$base_grand_total += $fee;
|
38 |
+
|
39 |
+
// TODO: update tax in another model?
|
40 |
+
|
41 |
+
$address->setBasePaysonInvoiceFee($fee);
|
42 |
+
$address->setPaysonInvoiceFee($store->convertPrice($fee, false));
|
43 |
+
|
44 |
+
$address->setBaseGrandTotal($base_grand_total);
|
45 |
+
$address->setGrandTotal($store->convertPrice($base_grand_total, false));
|
46 |
+
|
47 |
+
//$this->_addBaseAmount($fee);
|
48 |
+
//$this->_addAmount($fee);
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
54 |
+
{
|
55 |
+
if(($fee = $address->getPaysonInvoiceFee()) > 0)
|
56 |
+
{
|
57 |
+
$address->addTotal(array
|
58 |
+
(
|
59 |
+
'code' => $this->getCode(),
|
60 |
+
'title' => Mage::helper('payson')->__('Invoice fee'),
|
61 |
+
'value' => $fee
|
62 |
+
));
|
63 |
+
}
|
64 |
+
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
app/code/community/Payson/Payson/Model/Standard.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_Model_Standard extends Mage_Payment_Model_Method_Abstract
|
3 |
+
{
|
4 |
+
/*
|
5 |
+
* Protected properties
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @inheritDoc
|
10 |
+
*/
|
11 |
+
protected $_code = 'payson';
|
12 |
+
protected $_formBlockType = 'payson/form';
|
13 |
+
//protected $_infoBlockType = 'payson/info';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @inheritDoc
|
17 |
+
*/
|
18 |
+
protected $_isGateway = false;
|
19 |
+
protected $_canAuthorize = false;
|
20 |
+
protected $_canCapture = true;
|
21 |
+
protected $_canCapturePartial = false;
|
22 |
+
protected $_canRefund = false;
|
23 |
+
protected $_canRefundInvoicePartial = false;
|
24 |
+
protected $_canVoid = false;
|
25 |
+
protected $_canUseInternal = true;
|
26 |
+
protected $_canUseCheckout = true;
|
27 |
+
protected $_canUseForMultishipping = false;
|
28 |
+
protected $_isInitializeNeeded = true;
|
29 |
+
protected $_canFetchTransactionInfo = false;
|
30 |
+
protected $_canReviewPayment = false;
|
31 |
+
protected $_canCreateBillingAgreement = false;
|
32 |
+
protected $_canManageRecurringProfiles = false;
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @inheritDoc
|
37 |
+
*/
|
38 |
+
protected $_canCancelInvoice = false;
|
39 |
+
|
40 |
+
/*
|
41 |
+
* Public methods
|
42 |
+
*/
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @inheritDoc
|
46 |
+
*/
|
47 |
+
public function initialize($payment_action, $state_object)
|
48 |
+
{
|
49 |
+
$state_object->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
50 |
+
$state_object->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
51 |
+
$state_object->setIsNotified(false);
|
52 |
+
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @inheritDoc
|
58 |
+
*/
|
59 |
+
public function capture(Varien_Object $payment, $amount)
|
60 |
+
{
|
61 |
+
$order = $payment->getOrder();
|
62 |
+
$order_id = $order->getData('increment_id');
|
63 |
+
|
64 |
+
$api = Mage::helper('payson/api');
|
65 |
+
|
66 |
+
$api->PaymentDetails($order_id);
|
67 |
+
$details = $api->GetResponse();
|
68 |
+
|
69 |
+
if(($details->type ===
|
70 |
+
Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE) ||
|
71 |
+
($details->invoiceStatus ===
|
72 |
+
Payson_Payson_Helper_Api::INVOICE_STATUS_ORDERCREATED))
|
73 |
+
{
|
74 |
+
$api->PaymentUpdate($order_id,
|
75 |
+
Payson_Payson_Helper_Api::UPDATE_ACTION_SHIPORDER);
|
76 |
+
}
|
77 |
+
|
78 |
+
return $this;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Redirect url when user place order
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function getOrderPlaceRedirectUrl()
|
87 |
+
{
|
88 |
+
return Mage::getUrl('payson/checkout/redirect',
|
89 |
+
array('_secure' => true));
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Whether this paymend method is available for specified currency
|
94 |
+
*
|
95 |
+
* @param string $currency
|
96 |
+
* @return bool
|
97 |
+
*/
|
98 |
+
public function canUseForCurrency($currency)
|
99 |
+
{
|
100 |
+
return Mage::getModel('payson/config')->IsCurrencySupported($currency);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Is run when payment method is selected
|
105 |
+
*
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
public function validate()
|
109 |
+
{
|
110 |
+
$session = Mage::getSingleton('checkout/session');
|
111 |
+
|
112 |
+
if(isset($_POST['payment']['payson_payment_method']))
|
113 |
+
{
|
114 |
+
$session->setData('payson_payment_method',
|
115 |
+
$_POST['payment']['payson_payment_method']);
|
116 |
+
}
|
117 |
+
else
|
118 |
+
{
|
119 |
+
$session->unsetData('payson_payment_method');
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @inheritDoc
|
125 |
+
*/
|
126 |
+
public function getTitle()
|
127 |
+
{
|
128 |
+
return Mage::Helper('payson')->__('Checkout with Payson');
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
app/code/community/Payson/Payson/controllers/Adminhtml/Sales/Order/ShipmentController.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
|
4 |
+
|
5 |
+
class Payson_Payson_Adminhtml_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController {
|
6 |
+
|
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_invoice") {
|
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 |
+
|
26 |
+
?>
|
app/code/community/Payson/Payson/controllers/CheckoutController.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
/*
|
5 |
+
* Private properties
|
6 |
+
*/
|
7 |
+
|
8 |
+
private $session;
|
9 |
+
private $order = null;
|
10 |
+
|
11 |
+
/*
|
12 |
+
* Private methods
|
13 |
+
*/
|
14 |
+
|
15 |
+
private function GetSession()
|
16 |
+
{
|
17 |
+
if(!isset($this->session))
|
18 |
+
{
|
19 |
+
$this->session = Mage::getSingleton('checkout/session');
|
20 |
+
}
|
21 |
+
|
22 |
+
return $this->session;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
*
|
27 |
+
* @return Mage_Sales_Model_Order
|
28 |
+
*/
|
29 |
+
private function GetOrder()
|
30 |
+
{
|
31 |
+
if(!isset($this->order))
|
32 |
+
{
|
33 |
+
$increment_id = $this->GetSession()->getData('last_real_order_id');
|
34 |
+
|
35 |
+
if($increment_id)
|
36 |
+
{
|
37 |
+
$this->order = Mage::getModel('sales/order')
|
38 |
+
->loadByIncrementId($increment_id);
|
39 |
+
|
40 |
+
if(is_null($this->order->getId()))
|
41 |
+
{
|
42 |
+
$this->order = null;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $this->order;
|
48 |
+
}
|
49 |
+
|
50 |
+
private function CancelOrder($message = '')
|
51 |
+
{
|
52 |
+
$order = $this->GetOrder();
|
53 |
+
|
54 |
+
if(!is_null($order = $this->GetOrder()))
|
55 |
+
{
|
56 |
+
/*$order->setState(
|
57 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
58 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
59 |
+
$message)
|
60 |
+
->cancel()->save();*/
|
61 |
+
$order->cancel()->save();
|
62 |
+
}
|
63 |
+
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/*
|
68 |
+
* Public methods
|
69 |
+
*/
|
70 |
+
|
71 |
+
public function redirectAction()
|
72 |
+
{
|
73 |
+
$order = $this->GetOrder();
|
74 |
+
|
75 |
+
if(is_null($order))
|
76 |
+
{
|
77 |
+
$this->_redirect('checkout/cart');
|
78 |
+
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
try
|
83 |
+
{
|
84 |
+
$api = Mage::helper('payson/api')->Pay($order);
|
85 |
+
|
86 |
+
$order->addStatusHistoryComment(Mage::helper('payson')->__(
|
87 |
+
'The customer was redirected to Payson'))
|
88 |
+
->save();
|
89 |
+
|
90 |
+
$this->GetResponse()->setRedirect($api->GetPayForwardUrl());
|
91 |
+
}
|
92 |
+
catch(Exception $e)
|
93 |
+
{
|
94 |
+
$this->CancelOrder($e->getMessage());
|
95 |
+
|
96 |
+
Mage::logException($e);
|
97 |
+
|
98 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
99 |
+
$this->_redirect('checkout/cart');
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
public function returnAction()
|
104 |
+
{
|
105 |
+
// Send a new order email when we are back from Payson
|
106 |
+
$this->GetOrder()->sendNewOrderEmail();
|
107 |
+
|
108 |
+
$this->_redirect('checkout/onepage/success');
|
109 |
+
}
|
110 |
+
|
111 |
+
public function cancelAction()
|
112 |
+
{
|
113 |
+
$this->CancelOrder()->_redirect('checkout/cart');
|
114 |
+
}
|
115 |
+
}
|
app/code/community/Payson/Payson/controllers/IpnController.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Payson_Payson_IpnController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function notifyAction()
|
5 |
+
{
|
6 |
+
$request = $this->getRequest();
|
7 |
+
$response = $this->getResponse();
|
8 |
+
|
9 |
+
if(!$request->isPost())
|
10 |
+
{
|
11 |
+
$response->setHttpResponseCode(503)->setBody('No!');
|
12 |
+
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
|
16 |
+
try
|
17 |
+
{
|
18 |
+
$api = Mage::helper('payson/api')->Validate($request->getRawBody(),
|
19 |
+
$request->getHeader('Content-Type'));
|
20 |
+
}
|
21 |
+
catch(Exception $e)
|
22 |
+
{
|
23 |
+
$response->setHttpResponseCode(503)->setBody($e->getMessage());
|
24 |
+
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
app/code/community/Payson/Payson/etc/config.xml
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Payson_Payson>
|
5 |
+
<version>0.1.2</version>
|
6 |
+
</Payson_Payson>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<adminhtml>
|
11 |
+
<args>
|
12 |
+
<modules>
|
13 |
+
<Payson_Payson before="Mage_Adminhtml">Payson_Payson_Adminhtml</Payson_Payson>
|
14 |
+
</modules>
|
15 |
+
</args>
|
16 |
+
</adminhtml>
|
17 |
+
</routers>
|
18 |
+
</admin>
|
19 |
+
<global>
|
20 |
+
<blocks>
|
21 |
+
<payson>
|
22 |
+
<class>Payson_Payson_Block</class>
|
23 |
+
</payson>
|
24 |
+
</blocks>
|
25 |
+
<models>
|
26 |
+
<payson>
|
27 |
+
<class>Payson_Payson_Model</class>
|
28 |
+
</payson>
|
29 |
+
</models>
|
30 |
+
<helpers>
|
31 |
+
<payson>
|
32 |
+
<class>Payson_Payson_Helper</class>
|
33 |
+
</payson>
|
34 |
+
</helpers>
|
35 |
+
<resources>
|
36 |
+
<payson_setup>
|
37 |
+
<setup>
|
38 |
+
<module>Payson_Payson</module>
|
39 |
+
<class>Payson_Payson_Model_Mysql4_Setup</class>
|
40 |
+
</setup>
|
41 |
+
<connection>
|
42 |
+
<use>core_setup</use>
|
43 |
+
</connection>
|
44 |
+
</payson_setup>
|
45 |
+
<payson_write>
|
46 |
+
<connection>
|
47 |
+
<use>core_write</use>
|
48 |
+
</connection>
|
49 |
+
</payson_write>
|
50 |
+
<payson_read>
|
51 |
+
<connection>
|
52 |
+
<use>core_read</use>
|
53 |
+
</connection>
|
54 |
+
</payson_read>
|
55 |
+
</resources>
|
56 |
+
<sales>
|
57 |
+
<quote>
|
58 |
+
<totals>
|
59 |
+
<payson_invoice>
|
60 |
+
<class>payson/quote_address_total_invoice</class>
|
61 |
+
<after>subtotal,discount,shipping</after>
|
62 |
+
<before>tax,grand_total</before>
|
63 |
+
</payson_invoice>
|
64 |
+
</totals>
|
65 |
+
</quote>
|
66 |
+
<order_invoice>
|
67 |
+
<totals>
|
68 |
+
<payson_invoice>
|
69 |
+
<class>payson/order_invoice_total_invoice</class>
|
70 |
+
<after>subtotal,discount,shipping</after>
|
71 |
+
<before>tax,grand_total</before>
|
72 |
+
</payson_invoice>
|
73 |
+
</totals>
|
74 |
+
</order_invoice>
|
75 |
+
<order_creditmemo>
|
76 |
+
<totals>
|
77 |
+
<payson_invoice>
|
78 |
+
<class>payson/order_creditmemo_total_invoice</class>
|
79 |
+
<after>subtotal,discount,shipping</after>
|
80 |
+
<before>tax,grand_total</before>
|
81 |
+
</payson_invoice>
|
82 |
+
</totals>
|
83 |
+
</order_creditmemo>
|
84 |
+
</sales>
|
85 |
+
<fieldsets>
|
86 |
+
<sales_convert_quote_address>
|
87 |
+
<base_payson_invoice_fee>
|
88 |
+
<to_order>*</to_order>
|
89 |
+
</base_payson_invoice_fee>
|
90 |
+
<payson_invoice_fee>
|
91 |
+
<to_order>*</to_order>
|
92 |
+
</payson_invoice_fee>
|
93 |
+
</sales_convert_quote_address>
|
94 |
+
<!--<sales_convert_order>
|
95 |
+
<base_payson_invoice_fee>
|
96 |
+
<to_quote>*</to_quote>
|
97 |
+
</base_payson_invoice_fee>
|
98 |
+
<payson_invoice_fee>
|
99 |
+
<to_quote>*</to_quote>
|
100 |
+
</payson_invoice_fee>
|
101 |
+
</sales_convert_order>
|
102 |
+
<sales_convert_quote>
|
103 |
+
<base_payson_invoice_fee>
|
104 |
+
<to_order>*</to_order>
|
105 |
+
</base_payson_invoice_fee>
|
106 |
+
<payson_invoice_fee>
|
107 |
+
<to_order>*</to_order>
|
108 |
+
</payson_invoice_fee>
|
109 |
+
</sales_convert_quote>-->
|
110 |
+
</fieldsets>
|
111 |
+
</global>
|
112 |
+
<frontend>
|
113 |
+
<secure_url>
|
114 |
+
<payson_checkout>/payson/checkout</payson_checkout>
|
115 |
+
</secure_url>
|
116 |
+
<routers>
|
117 |
+
<payson>
|
118 |
+
<use>standard</use>
|
119 |
+
<args>
|
120 |
+
<module>Payson_Payson</module>
|
121 |
+
<frontName>payson</frontName>
|
122 |
+
</args>
|
123 |
+
</payson>
|
124 |
+
</routers>
|
125 |
+
<translate>
|
126 |
+
<modules>
|
127 |
+
<Payson_Payson>
|
128 |
+
<files>
|
129 |
+
<default>Payson_Payson.csv</default>
|
130 |
+
</files>
|
131 |
+
</Payson_Payson>
|
132 |
+
</modules>
|
133 |
+
</translate>
|
134 |
+
<layout>
|
135 |
+
<updates>
|
136 |
+
<Payson_Payson>
|
137 |
+
<file>Payson.xml</file>
|
138 |
+
</Payson_Payson>
|
139 |
+
</updates>
|
140 |
+
</layout>
|
141 |
+
</frontend>
|
142 |
+
<adminhtml>
|
143 |
+
<translate>
|
144 |
+
<modules>
|
145 |
+
<Payson_Payson>
|
146 |
+
<files>
|
147 |
+
<default>Payson_Payson.csv</default>
|
148 |
+
</files>
|
149 |
+
</Payson_Payson>
|
150 |
+
</modules>
|
151 |
+
</translate>
|
152 |
+
<layout>
|
153 |
+
<updates>
|
154 |
+
<Payson_Payson>
|
155 |
+
<file>Payson.xml</file>
|
156 |
+
</Payson_Payson>
|
157 |
+
</updates>
|
158 |
+
</layout>
|
159 |
+
</adminhtml>
|
160 |
+
<default>
|
161 |
+
<payment>
|
162 |
+
<payson_standard>
|
163 |
+
<test_mode>0</test_mode>
|
164 |
+
<active>0</active>
|
165 |
+
<model>payson/method_standard</model>
|
166 |
+
<payment_action>authorize</payment_action>
|
167 |
+
<order_status>pending_payment</order_status>
|
168 |
+
<payment_guarantee>1</payment_guarantee>
|
169 |
+
</payson_standard>
|
170 |
+
<payson_invoice>
|
171 |
+
<active>0</active>
|
172 |
+
<activate_invoice>1</activate_invoice>
|
173 |
+
<model>payson/method_invoice</model>
|
174 |
+
<payment_action>authorize</payment_action>
|
175 |
+
<order_status>pending</order_status>
|
176 |
+
<invoice_fee_sek>0</invoice_fee_sek>
|
177 |
+
<invoice_fee_eur>0</invoice_fee_eur>
|
178 |
+
</payson_invoice>
|
179 |
+
</payment>
|
180 |
+
</default>
|
181 |
+
</config>
|
182 |
+
|
app/code/community/Payson/Payson/etc/system.xml
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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</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>
|
15 |
+
<comment>Enable/disable test mode.</comment>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>5</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>1</show_in_store>
|
22 |
+
</test_mode>
|
23 |
+
<active translate="label,comment">
|
24 |
+
<label>Enabled</label>
|
25 |
+
<comment>Enable/disable payment with Payson.</comment>
|
26 |
+
<frontend_type>select</frontend_type>
|
27 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
28 |
+
<sort_order>10</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
</active>
|
33 |
+
<email translate="label,comment">
|
34 |
+
<label>Email</label>
|
35 |
+
<comment>Email address bound to your Payson account.</comment>
|
36 |
+
<frontend_type>text</frontend_type>
|
37 |
+
<validate>validate-email</validate>
|
38 |
+
<sort_order>20</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>0</show_in_website>
|
41 |
+
<show_in_store>0</show_in_store>
|
42 |
+
</email>
|
43 |
+
<agent_id translate="label,comment">
|
44 |
+
<label>Agent ID</label>
|
45 |
+
<comment>Agent ID is found on your Payson profile page.</comment>
|
46 |
+
<frontend_type>text</frontend_type>
|
47 |
+
<sort_order>30</sort_order>
|
48 |
+
<show_in_default>1</show_in_default>
|
49 |
+
<show_in_website>0</show_in_website>
|
50 |
+
<show_in_store>0</show_in_store>
|
51 |
+
</agent_id>
|
52 |
+
<md5_key translate="label,comment">
|
53 |
+
<label>MD5 key</label>
|
54 |
+
<comment>MD5 key is found on your Payson profile page.</comment>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<sort_order>40</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>0</show_in_website>
|
59 |
+
<show_in_store>0</show_in_store>
|
60 |
+
</md5_key>
|
61 |
+
<payment_guarantee translate="label,comment">
|
62 |
+
<label>Enable payment guarantee</label>
|
63 |
+
<comment>Enable/disable payment guarantee.</comment>
|
64 |
+
<frontend_type>select</frontend_type>
|
65 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
66 |
+
<sort_order>50</sort_order>
|
67 |
+
<show_in_default>0</show_in_default>
|
68 |
+
<show_in_website>0</show_in_website>
|
69 |
+
<show_in_store>0</show_in_store>
|
70 |
+
</payment_guarantee>
|
71 |
+
</fields>
|
72 |
+
</payson_standard>
|
73 |
+
<payson_invoice translate="label" module="payson">
|
74 |
+
<label>Payson invoice</label>
|
75 |
+
<sort_order>-99</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>1</show_in_store>
|
79 |
+
<fields>
|
80 |
+
<active translate="label,comment">
|
81 |
+
<label>Enabled</label>
|
82 |
+
<comment>Enable/disable invoice payment with Payson.</comment>
|
83 |
+
<frontend_type>select</frontend_type>
|
84 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
85 |
+
<sort_order>10</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
</active>
|
90 |
+
<activate_invoice translate="label,comment">
|
91 |
+
<label>Activate invoice on purchase</label>
|
92 |
+
<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>
|
93 |
+
<frontend_type>select</frontend_type>
|
94 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
95 |
+
<sort_order>15</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>1</show_in_store>
|
99 |
+
</activate_invoice>
|
100 |
+
<invoice_fee_tax translate="label,comment">
|
101 |
+
<label>Invoice fee tax</label>
|
102 |
+
<comment>Tax class for invoice fees.</comment>
|
103 |
+
<frontend_type>select</frontend_type>
|
104 |
+
<source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
|
105 |
+
<sort_order>20</sort_order>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>1</show_in_store>
|
109 |
+
</invoice_fee_tax>
|
110 |
+
<invoice_fee_sek translate="label,comment">
|
111 |
+
<label>Invoice fee (SEK)</label>
|
112 |
+
<comment>Invoice fee for SEK excluding tax.</comment>
|
113 |
+
<frontend_type>text</frontend_type>
|
114 |
+
<sort_order>30</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>1</show_in_website>
|
117 |
+
<show_in_store>1</show_in_store>
|
118 |
+
</invoice_fee_sek>
|
119 |
+
<invoice_fee_eur translate="label,comment">
|
120 |
+
<label>Invoice fee (EUR)</label>
|
121 |
+
<comment>Invoice fee for EUR excluding tax.</comment>
|
122 |
+
<frontend_type>text</frontend_type>
|
123 |
+
<sort_order>40</sort_order>
|
124 |
+
<show_in_default>1</show_in_default>
|
125 |
+
<show_in_website>1</show_in_website>
|
126 |
+
<show_in_store>1</show_in_store>
|
127 |
+
</invoice_fee_eur>
|
128 |
+
</fields>
|
129 |
+
</payson_invoice>
|
130 |
+
</groups>
|
131 |
+
</payment>
|
132 |
+
</sections>
|
133 |
+
</config>
|
134 |
+
|
app/code/community/Payson/Payson/sql/payson_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$this->startSetup();
|
3 |
+
$this->run('
|
4 |
+
CREATE TABLE IF NOT EXISTS `' . $this->getTable('payson_order') . '`
|
5 |
+
(
|
6 |
+
`id` INT NOT NULL AUTO_INCREMENT,
|
7 |
+
`order_id` INT NOT NULL,
|
8 |
+
`added` DATETIME DEFAULT NULL,
|
9 |
+
`updated` DATETIME DEFAULT NULL,
|
10 |
+
`valid` TINYINT(1) NOT NULL,
|
11 |
+
`ipn_status` VARCHAR(32) DEFAULT NULL,
|
12 |
+
`token` VARCHAR(255) DEFAULT NULL,
|
13 |
+
PRIMARY KEY (`id`)
|
14 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
15 |
+
|
16 |
+
CREATE TABLE IF NOT EXISTS `' . $this->getTable('payson_order_log') . '`
|
17 |
+
(
|
18 |
+
`id` INT NOT NULL AUTO_INCREMENT,
|
19 |
+
`payson_order_id` INT DEFAULT NULL,
|
20 |
+
`added` DATETIME DEFAULT NULL,
|
21 |
+
`api_call` VARCHAR(32) NOT NULL,
|
22 |
+
`valid` TINYINT(1) NOT NULL,
|
23 |
+
`response` TEXT NOT NULL,
|
24 |
+
PRIMARY KEY (`id`)
|
25 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
|
26 |
+
|
27 |
+
/*$this->addAttribute('quote', 'payson_invoice_fee',
|
28 |
+
array('type' => 'decimal(12,4)', 'grid' => false));
|
29 |
+
$this->addAttribute('quote', 'base_payson_invoice_fee',
|
30 |
+
array('type' => 'decimal(12,4)', 'grid' => false));*/
|
31 |
+
|
32 |
+
$this->addAttribute('order', 'payson_invoice_fee',
|
33 |
+
array('type' => 'decimal', 'grid' => false));
|
34 |
+
$this->addAttribute('order', 'base_payson_invoice_fee',
|
35 |
+
array('type' => 'decimal', 'grid' => false));
|
36 |
+
|
37 |
+
/*$this->addAttribute('invoice', 'payson_invoice_fee',
|
38 |
+
array('type' => 'decimal', 'grid' => false));
|
39 |
+
$this->addAttribute('invoice', 'base_payson_invoice_fee',
|
40 |
+
array('type' => 'decimal', 'grid' => false));*/
|
41 |
+
|
42 |
+
$this->endSetup();
|
43 |
+
|
app/code/community/Payson/Payson/sql/payson_setup/mysql4-upgrade-0.1.0-0.1.2.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$this->startSetup();
|
3 |
+
$this->run('alter table `' . $this->getTable('payson_order') . '` add store_id int;
|
4 |
+
');
|
5 |
+
|
6 |
+
$this->endSetup();
|
7 |
+
|
app/design/adminhtml/default/default/Payson/Payson/total.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<tr>
|
2 |
+
<td class="label"><?php echo($this->__('Invoice Fee')); ?></td>
|
3 |
+
<td><?php echo($this->displayPriceAttribute('payson_invoice_fee')); ?></td>
|
4 |
+
</tr>
|
5 |
+
|
app/design/adminhtml/default/default/layout/Payson.xml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout>
|
3 |
+
<!--<adminhtml_sales_order_new>
|
4 |
+
<reference name="order_totals">
|
5 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
6 |
+
</reference>
|
7 |
+
</adminhtml_sales_order_new>-->
|
8 |
+
<adminhtml_sales_order_view>
|
9 |
+
<reference name="order_totals">
|
10 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
11 |
+
</reference>
|
12 |
+
</adminhtml_sales_order_view>
|
13 |
+
<adminhtml_sales_order_invoice_new>
|
14 |
+
<reference name="invoice_totals">
|
15 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
16 |
+
</reference>
|
17 |
+
</adminhtml_sales_order_invoice_new>
|
18 |
+
<adminhtml_sales_order_invoice_view>
|
19 |
+
<reference name="invoice_totals">
|
20 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
21 |
+
</reference>
|
22 |
+
</adminhtml_sales_order_invoice_view>
|
23 |
+
<adminhtml_sales_order_creditmemo_new>
|
24 |
+
<reference name="creditmemo_totals">
|
25 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
26 |
+
</reference>
|
27 |
+
</adminhtml_sales_order_creditmemo_new>
|
28 |
+
<!--<adminhtml_sales_order_creditmemo_view>
|
29 |
+
<reference name="creditmemo_totals">
|
30 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
31 |
+
</reference>
|
32 |
+
</adminhtml_sales_order_creditmemo_view>-->
|
33 |
+
</layout>
|
34 |
+
|
app/design/frontend/base/default/layout/Payson.xml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<sales_order_print>
|
4 |
+
<reference name="order_totals">
|
5 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
6 |
+
</reference>
|
7 |
+
</sales_order_print>
|
8 |
+
<sales_order_view>
|
9 |
+
<reference name="order_totals">
|
10 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
11 |
+
</reference>
|
12 |
+
</sales_order_view>
|
13 |
+
<sales_order_invoice>
|
14 |
+
<reference name="invoice_totals">
|
15 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
16 |
+
</reference>
|
17 |
+
</sales_order_invoice>
|
18 |
+
<sales_order_printinvoice>
|
19 |
+
<reference name="invoice_totals">
|
20 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
21 |
+
</reference>
|
22 |
+
</sales_order_printinvoice>
|
23 |
+
<sales_order_creditmemo>
|
24 |
+
<reference name="creditmemo_totals">
|
25 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
26 |
+
</reference>
|
27 |
+
</sales_order_creditmemo>
|
28 |
+
<sales_order_printcreditmemo>
|
29 |
+
<reference name="creditmemo_totals">
|
30 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
31 |
+
</reference>
|
32 |
+
</sales_order_printcreditmemo>
|
33 |
+
<sales_email_order_items>
|
34 |
+
<reference name="order_totals">
|
35 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
36 |
+
</reference>
|
37 |
+
</sales_email_order_items>
|
38 |
+
<sales_email_order_invoice_items>
|
39 |
+
<reference name="invoice_totals">
|
40 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
41 |
+
</reference>
|
42 |
+
</sales_email_order_invoice_items>
|
43 |
+
<!-- sales_email_order_shipment_items sales_email_order_creditmemo_items -->
|
44 |
+
</layout>
|
45 |
+
|
app/design/frontend/base/default/template/Payson/Payson/invoice_form.phtml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"><?php echo($helper->__('You will be redirected to Payson\'s website.')); ?></p>
|
8 |
+
</fieldset>
|
9 |
+
|
app/design/frontend/base/default/template/Payson/Payson/standard_form.phtml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
7 |
+
<p id="payment_form_<?php echo($code); ?>" style="display: none"><?php echo($helper->__('You will be redirected to Payson\'s website.')); ?></p>
|
8 |
+
</fieldset>
|
9 |
+
|
app/etc/modules/Payson_Payson.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Payson_Payson>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>0.1.2</version>
|
8 |
+
<depends>
|
9 |
+
<Mage_Payment />
|
10 |
+
</depends>
|
11 |
+
</Payson_Payson>
|
12 |
+
</modules>
|
13 |
+
</config>
|
14 |
+
|
app/locale/sv_SE/Payson_Payson.csv
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Checkout with Payson","Betala med Payson"
|
2 |
+
"You will be redirected to Payson's website.","Du kommer att skickas vidare till Paysons webbplats."
|
3 |
+
|
4 |
+
"Checkout with Payson invoice %s","Betala med Payson faktura %s"
|
5 |
+
"Invoice fee","Fakturaavgift"
|
6 |
+
|
7 |
+
"Order was activated at Payson","Order aktiverades hos Payson"
|
8 |
+
"Payment was credited at Payson","Betalningen krediterades hos Payson"
|
9 |
+
"Order was canceled at Payson","Beställningen avbröts hos Payson"
|
10 |
+
|
11 |
+
"Payson is not ready to create an invoice. Please try again later.","Payson är inte redo att skapa en faktura. Försök igen senare."
|
12 |
+
"Payson is not ready to cancel the order. Please try again later.","Payson är inte redo att avbryta beställningen. Försök igen senare."
|
13 |
+
|
14 |
+
"Order from %s","Order från %s"
|
15 |
+
"No description","Ingen beskrivning"
|
16 |
+
"Failed to initialize payment. Payson replied: %s","Misslyckades med att initiera betalning. Payson svarade med: %s"
|
17 |
+
"Failed to retrieve payment details. Payson replied: %s","Misslyckades med att hämta betalningsdetaljer. Payson svarade med: %s"
|
18 |
+
"Failed to update payment. Payson replied: %s","Misslyckades med att uppdatera betalning. Payson svarade med: %s"
|
19 |
+
"The customer was redirected to Payson","Kunden omdirigerades till Payson"
|
20 |
+
"Payson completed the order payment","Payson färdigställde betalningen"
|
21 |
+
"Payson created an invoice","Payson skapade en faktura"
|
22 |
+
"Payson updated the shipping address","Payson uppdaterade leveransadressen"
|
23 |
+
"Payson pinged the order with status %s","Payson pingade ordern med status: %s"
|
24 |
+
"Payson cancelled the order with status %s","Payson avbröt ordern med status: %s"
|
25 |
+
|
26 |
+
"Enabled","Aktiverad"
|
27 |
+
"Enable/disable payment with Payson.","Aktivera eller inaktivera betalning med Payson."
|
28 |
+
"Email","E-post"
|
29 |
+
"Email address bound to your Payson account.","E-postadress för ditt Paysonkonto."
|
30 |
+
"Agent ID","Agent ID"
|
31 |
+
"Agent ID is found on your Payson profile page.","Logga in på Paysons webbplats för att hämta ditt Agent ID."
|
32 |
+
"MD5 key","MD5-nyckel"
|
33 |
+
"MD5 key is found on your Payson profile page.","Logga in på Paysons webbplats för att hämta din MD5-nyckel."
|
34 |
+
"Enable payment guarantee","Aktivera Paysongaranti"
|
35 |
+
"Enable/disable payment guarantee.","Aktivera eller inaktivera Paysongaranti."
|
36 |
+
|
37 |
+
"Payson invoice","Payson faktura"
|
38 |
+
"Enable/disable invoice payment with Payson.","Aktivera eller inaktivera faktura med Payson."
|
39 |
+
"Invoice fee tax","Momsklass för fakturaavgift"
|
40 |
+
"Tax class for invoice fees.","Momsklass för fakturaavgift."
|
41 |
+
"Invoice fee (SEK)","Fakturaavgift (SEK)"
|
42 |
+
"Invoice fee for SEK excluding tax.","Fakturaavgift för SEK utan moms."
|
43 |
+
"Invoice fee (EUR)","Fakturaavgift (EUR)"
|
44 |
+
"Invoice fee for EUR excluding tax.","Fakturaavgift för EUR utan moms."
|
45 |
+
"Enable/disable test mode.","Slå på/av testläge"
|
46 |
+
"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","Aktivera detta för att skicka Payson-fakturan direkt när ett köp accepterats. Stängs denna funktion av måste ordern markeras som Skickad i Magento Admin eller Payson Admin"
|
47 |
+
|
package.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Payson</name>
|
4 |
+
<version>0.1.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>BSD</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Official Payson module for Magento. Use this to be able to handle invoice, card and direct bank transfers in your store. 
|
10 |
+

|
11 |
+
! Requires a contract with Payson. Read more here (https://www.payson.se/ebutik)</summary>
|
12 |
+
<description>Make it easy to charge your customers. Chose Payson.
|
13 |
+

|
14 |
+
This module integrates with Payson and allows you to charge your customers via Invoice, Card and direct bank transfers.</description>
|
15 |
+
<notes>* Fixed so that the order email is sent when payment is accepted by Payson
|
16 |
+

|
17 |
+
* Added an option for not activating an invoice when accepted.</notes>
|
18 |
+
<authors><author><name>Daniel Hansen</name><user>PaysonAB</user><email>integration@payson.se</email></author></authors>
|
19 |
+
<date>2013-02-19</date>
|
20 |
+
<time>15:09:14</time>
|
21 |
+
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Payson"><dir name="Payson"><dir name="Block"><file name="Form.php" hash="7a7c6e5ae4e2e8e72fa2c40a22c88440"/><dir name="Invoice"><file name="Form.php" hash="11483752cd4555f47445a92371e7c1b5"/></dir><dir name="Order"><dir name="Totals"><file name="Fee.php" hash="808261ee19df9146756160cb6cd53b6a"/></dir></dir><dir name="Standard"><file name="Form.php" hash="9d013602be74f2c74de0ccdb6dbf8675"/></dir></dir><dir name="Helper"><dir name="Api"><dir name="Response"><file name="Interface.php" hash="9e4776fe054757f2d2739bcd9616e2fb"/><dir name="Standard"><file name="Parameters.php" hash="626604b19b85f17d1be40f3623cedc43"/></dir><file name="Standard.php" hash="06999c14ae62726117b0c37a0e974b5f"/><file name="Validate.php" hash="aa3a364583c8d75c2faa22f43142db19"/></dir></dir><file name="Api.php" hash="fbbf3ebeff30227954308d0af91d1052"/><file name="Data.php" hash="89f829357cfdbefdabb46dff8d52228c"/></dir><dir name="Model"><file name="Config.php" hash="3934878903e7b80dcfb97f102e30ba73"/><dir name="Method"><file name="Abstract.php" hash="c4b83dd7d16e2a409d4be0345e6f30e5"/><file name="Invoice.php" hash="4bdf5c763832dca36c030d3f84eedc92"/><file name="Standard.php" hash="a0d41d559429cf7713ee6bba59733cb9"/></dir><dir name="Mysql4"><file name="Setup.php" hash="9023463718548c8a5ed7faed6aa40a3c"/></dir><dir name="Order"><dir name="Creditmemo"><dir name="Total"><file name="Invoice.php" hash="86748e75794e73df7d0b25091a19fbad"/></dir></dir><dir name="Invoice"><dir name="Total"><file name="Invoice.php" hash="3d485a07c9ef8dc83532303db1eb6c9b"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Invoice.php" hash="09522f6537a78461cf737e232317463e"/></dir></dir></dir><file name="Standard.php" hash="12e47b6b3e338104bcb8a06c5f3b8953"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="ShipmentController.php" hash="56118704e788b2b53086f7c9be71c996"/></dir></dir></dir><file name="CheckoutController.php" hash="9e6421d09b3f1bafc218bf355ee14833"/><file name="IpnController.php" hash="48e3d7683632647568817548c9bd0a66"/></dir><dir name="etc"><file name="config.xml" hash="7cce0791629bac74fc20993160c4d815"/><file name="system.xml" hash="64d941d6fe99e7a56ea9468367cc59a5"/></dir><dir name="sql"><dir name="payson_setup"><file name="mysql4-install-0.1.0.php" hash="98b5bdd98a21255e334b843ecd998dc3"/><file name="mysql4-upgrade-0.1.0-0.1.2.php" hash="a18c999031bce6579e6fc0add977ea04"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="Payson"><dir name="Payson"><file name="total.phtml" hash="a6f06816114cda260573492e4db22238"/></dir></dir><dir name="layout"><file name="Payson.xml" hash=""/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="Payson"><dir name="Payson"><file name="invoice_form.phtml" hash="8e9ab8155d502cc24ffad2e5c25e6e56"/><file name="standard_form.phtml" hash="5b9a8817c94fcbced0ce06edbaf5c3b9"/></dir></dir></dir><dir name="layout"><file name="Payson.xml" hash=""/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Payson_Payson.xml" hash=""/></dir></dir><dir name="locale"><dir name="sv_SE"><file name="Payson_Payson.csv" hash=""/></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="Payson"><dir name="Payson"><file name="payson.gif" hash="638d0055cbc1a4bdc32e9fa1156b722a"/><file name="payson.png" hash="308916345711a4520313c94218c5bda7"/><file name="payson_faktura.png" hash="fa218c9949c05c6f3452d9f4c541da2c"/></dir></dir></dir></dir></dir></dir></target></contents>
|
22 |
+
<compatible/>
|
23 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
24 |
+
</package>
|
skin/frontend/base/default/Payson/Payson/payson.gif
ADDED
Binary file
|
skin/frontend/base/default/Payson/Payson/payson.png
ADDED
Binary file
|
skin/frontend/base/default/Payson/Payson/payson_faktura.png
ADDED
Binary file
|