Version Notes
This version is properly tested on the following Magento CE versions: 1.5, 1.6, 1.7,1.8,1.9.* . In this particular version we are supporting it to run on PHP V 5.5.X.
Download this release
Release Info
Developer | Rave Infosys |
Extension | Raveinfosys_Sagepay |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- app/code/community/Raveinfosys/Sagepay/Block/Adminhtml/Sagepay.php +13 -10
- app/code/community/Raveinfosys/Sagepay/Block/Adminhtml/Sagepay/Grid.php +101 -100
- app/code/community/Raveinfosys/Sagepay/Controller/Observer.php +8 -6
- app/code/community/Raveinfosys/Sagepay/Helper/Data.php +1 -1
- app/code/community/Raveinfosys/Sagepay/Model/Config.php +79 -71
- app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Sagepay.php +4 -2
- app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Sagepay/Collection.php +3 -1
- app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Transaction.php +5 -3
- app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Transaction/Collection.php +3 -1
- app/code/community/Raveinfosys/Sagepay/Model/Observer.php +29 -25
- app/code/community/Raveinfosys/Sagepay/Model/Payment.php +764 -733
- app/code/community/Raveinfosys/Sagepay/Model/Sagepay.php +125 -119
- app/code/community/Raveinfosys/Sagepay/Model/Status.php +7 -5
- app/code/community/Raveinfosys/Sagepay/Model/System/Config/Source/Dropdown/Values.php +4 -2
- app/code/community/Raveinfosys/Sagepay/Model/Transaction.php +28 -27
- app/code/community/Raveinfosys/Sagepay/controllers/Adminhtml/SagepayController.php +50 -47
- app/code/community/Raveinfosys/Sagepay/controllers/Checkout/OnepageController.php +67 -69
- app/code/community/Raveinfosys/Sagepay/sql/sagepay_setup/mysql4-install-0.1.0.php +9 -9
- app/design/frontend/base/default/layout/sagepay.xml +3 -3
- package.xml +7 -7
app/code/community/Raveinfosys/Sagepay/Block/Adminhtml/Sagepay.php
CHANGED
@@ -1,13 +1,16 @@
|
|
1 |
<?php
|
|
|
2 |
class Raveinfosys_Sagepay_Block_Adminhtml_Sagepay extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
}
|
|
|
|
1 |
<?php
|
2 |
+
|
3 |
class Raveinfosys_Sagepay_Block_Adminhtml_Sagepay extends Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_controller = 'adminhtml_sagepay';
|
9 |
+
$this->_blockGroup = 'sagepay';
|
10 |
+
$this->_headerText = Mage::helper('sagepay')->__('Sagepay Transaction Details');
|
11 |
+
$this->_addButtonLabel = Mage::helper('sagepay')->__('Add Item');
|
12 |
+
parent::__construct();
|
13 |
+
$this->_removeButton('add');
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Block/Adminhtml/Sagepay/Grid.php
CHANGED
@@ -2,101 +2,102 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Block_Adminhtml_Sagepay_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
39 |
'header' => Mage::helper('sagepay')->__('Security Key'),
|
40 |
'align' =>'right',
|
41 |
'width' => '50px',
|
42 |
'index' => 'security_key',
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
protected function _prepareMassaction()
|
102 |
{
|
@@ -104,18 +105,18 @@ class Raveinfosys_Sagepay_Block_Adminhtml_Sagepay_Grid extends Mage_Adminhtml_Bl
|
|
104 |
$this->getMassactionBlock()->setFormFieldName('sagepay');
|
105 |
|
106 |
$this->getMassactionBlock()->addItem('delete', array(
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
));
|
111 |
|
112 |
-
|
113 |
return $this;
|
114 |
}
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
|
121 |
-
}
|
2 |
|
3 |
class Raveinfosys_Sagepay_Block_Adminhtml_Sagepay_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('sagepayGrid');
|
10 |
+
$this->setDefaultSort('transaction_id');
|
11 |
+
$this->setDefaultDir('ASC');
|
12 |
+
$this->setSaveParametersInSession(true);
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$collection = Mage::getModel('sagepay/transaction')->getCollection();
|
18 |
+
$this->setCollection($collection);
|
19 |
+
return parent::_prepareCollection();
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _prepareColumns()
|
23 |
+
{
|
24 |
+
|
25 |
+
$this->addColumn('order_id', array(
|
26 |
+
'header' => Mage::helper('sagepay')->__('Order Id'),
|
27 |
+
'align' => 'right',
|
28 |
+
'width' => '50px',
|
29 |
+
'index' => 'order_id',
|
30 |
+
));
|
31 |
+
|
32 |
+
$this->addColumn('vendor_tx_code', array(
|
33 |
+
'header' => Mage::helper('sagepay')->__('Vendor Tx Code'),
|
34 |
+
'align' => 'right',
|
35 |
+
'width' => '50px',
|
36 |
+
'index' => 'vendor_tx_code',
|
37 |
+
));
|
38 |
+
|
39 |
+
/* $this->addColumn('security_key', array(
|
40 |
'header' => Mage::helper('sagepay')->__('Security Key'),
|
41 |
'align' =>'right',
|
42 |
'width' => '50px',
|
43 |
'index' => 'security_key',
|
44 |
+
)); */
|
45 |
+
|
46 |
+
$this->addColumn('order_status', array(
|
47 |
+
'header' => Mage::helper('sagepay')->__('Status'),
|
48 |
+
'align' => 'right',
|
49 |
+
'width' => '50px',
|
50 |
+
'index' => 'order_status',
|
51 |
+
));
|
52 |
+
|
53 |
+
$this->addColumn('customer_name', array(
|
54 |
+
'header' => Mage::helper('sagepay')->__('Customer Name'),
|
55 |
+
'align' => 'right',
|
56 |
+
'width' => '50px',
|
57 |
+
'index' => 'customer_name',
|
58 |
+
));
|
59 |
+
|
60 |
+
$this->addColumn('mode', array(
|
61 |
+
'header' => Mage::helper('sagepay')->__('Transaction Type'),
|
62 |
+
'align' => 'right',
|
63 |
+
'width' => '50px',
|
64 |
+
'index' => 'mode',
|
65 |
+
));
|
66 |
+
|
67 |
+
$this->addColumn('customer_email', array(
|
68 |
+
'header' => Mage::helper('sagepay')->__('Email'),
|
69 |
+
'align' => 'right',
|
70 |
+
'width' => '50px',
|
71 |
+
'index' => 'customer_email',
|
72 |
+
));
|
73 |
+
|
74 |
+
$this->addColumn('threed_secure', array(
|
75 |
+
'header' => Mage::helper('sagepay')->__('3D Auth'),
|
76 |
+
'align' => 'right',
|
77 |
+
'width' => '50px',
|
78 |
+
'index' => 'threed_secure',
|
79 |
+
));
|
80 |
+
|
81 |
+
$this->addColumn('card_holder_name', array(
|
82 |
+
'header' => Mage::helper('sagepay')->__('Card Holder Name'),
|
83 |
+
'align' => 'right',
|
84 |
+
'width' => '50px',
|
85 |
+
'index' => 'card_holder_name',
|
86 |
+
));
|
87 |
+
|
88 |
+
$this->addColumn('card_type', array(
|
89 |
+
'header' => Mage::helper('sagepay')->__('Card Type'),
|
90 |
+
'align' => 'right',
|
91 |
+
'width' => '50px',
|
92 |
+
'index' => 'card_type',
|
93 |
+
));
|
94 |
+
|
95 |
+
|
96 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sagepay')->__('CSV'));
|
97 |
+
$this->addExportType('*/*/exportXml', Mage::helper('sagepay')->__('XML'));
|
98 |
+
|
99 |
+
return parent::_prepareColumns();
|
100 |
+
}
|
101 |
|
102 |
protected function _prepareMassaction()
|
103 |
{
|
105 |
$this->getMassactionBlock()->setFormFieldName('sagepay');
|
106 |
|
107 |
$this->getMassactionBlock()->addItem('delete', array(
|
108 |
+
'label' => Mage::helper('sagepay')->__('Delete'),
|
109 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
110 |
+
'confirm' => Mage::helper('sagepay')->__('Are you sure?')
|
111 |
));
|
112 |
|
113 |
+
|
114 |
return $this;
|
115 |
}
|
116 |
|
117 |
+
public function getRowUrl($row)
|
118 |
+
{
|
119 |
+
return '';
|
120 |
+
}
|
121 |
|
122 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Controller/Observer.php
CHANGED
@@ -2,10 +2,12 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Controller_Observer
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
}
|
2 |
|
3 |
class Raveinfosys_Sagepay_Controller_Observer
|
4 |
{
|
5 |
+
|
6 |
+
//Event: adminhtml_controller_action_predispatch_start
|
7 |
+
public function overrideTheme()
|
8 |
+
{
|
9 |
+
Mage::getDesign()->setArea('adminhtml')
|
10 |
+
->setTheme('sagepay');
|
11 |
+
}
|
12 |
+
|
13 |
}
|
app/code/community/Raveinfosys/Sagepay/Helper/Data.php
CHANGED
@@ -3,4 +3,4 @@
|
|
3 |
class Raveinfosys_Sagepay_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
|
6 |
-
}
|
3 |
class Raveinfosys_Sagepay_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
|
6 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Model/Config.php
CHANGED
@@ -1,73 +1,81 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Raveinfosys_Sagepay_Model_Config extends Mage_Core_Model_Abstract
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
+
class Raveinfosys_Sagepay_Model_Config extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
private $config = array();
|
7 |
+
|
8 |
+
public function _construct()
|
9 |
+
{
|
10 |
+
$sage_pay_urls = array(
|
11 |
+
'live' => array(
|
12 |
+
'register' => 'https://live.sagepay.com/gateway/service/vspdirect-register.vsp',
|
13 |
+
'refund' => 'https://live.sagepay.com/gateway/service/refund.vsp',
|
14 |
+
'void' => 'https://live.sagepay.com/gateway/service/void.vsp',
|
15 |
+
'cancel' => 'https://live.sagepay.com/gateway/service/cancel.vsp',
|
16 |
+
'authorise' => 'https://live.sagepay.com/gateway/service/authorise.vsp',
|
17 |
+
'3dsecure' => 'https://live.sagepay.com/gateway/service/direct3dcallback.vsp'
|
18 |
+
),
|
19 |
+
'test' => array(
|
20 |
+
'register' => 'https://test.sagepay.com/gateway/service/vspdirect-register.vsp',
|
21 |
+
'refund' => 'https://test.sagepay.com/gateway/service/refund.vsp',
|
22 |
+
'void' => 'https://test.sagepay.com/gateway/service/void.vsp',
|
23 |
+
'cancel' => 'https://test.sagepay.com/gateway/service/cancel.vsp',
|
24 |
+
'authorise' => 'https://test.sagepay.com/gateway/service/authorise.vsp',
|
25 |
+
'3dsecure' => 'https://test.sagepay.com/gateway/service/direct3dcallback.vsp'
|
26 |
+
),
|
27 |
+
'simulator' => array(
|
28 |
+
'register' => 'https://test.sagepay.com/Simulator/VSPDirectGateway.asp',
|
29 |
+
'refund' => 'https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorRefundTx',
|
30 |
+
'void' => 'https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorVoidTx',
|
31 |
+
'cancel' => 'https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorCancelTx',
|
32 |
+
'release' => 'https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorReleaseTx',
|
33 |
+
'authorise' => 'https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorAuthoriseTx',
|
34 |
+
'3dsecure' => 'https://test.sagepay.com/Simulator/VSPDirectCallback.asp'
|
35 |
+
)
|
36 |
+
);
|
37 |
+
$this->config = $sage_pay_urls;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getVendor()
|
41 |
+
{
|
42 |
+
return Mage::getStoreConfig('payment/sagepay/vendor_name');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getGatewayURL()
|
46 |
+
{
|
47 |
+
$mode = Mage::getStoreConfig('payment/sagepay/mode');
|
48 |
+
if (in_array($mode, array('live', 'test', 'simulator')))
|
49 |
+
return $this->config[$mode];
|
50 |
+
else
|
51 |
+
return $this->config['test'];
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getExpectedError()
|
55 |
+
{
|
56 |
+
return array('INVALID', 'MALFORMED', 'REJECTED', 'NOTAUTHED', 'ERROR', 'FAIL');
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getExpectedSuccess()
|
60 |
+
{
|
61 |
+
return array('OK', 'AUTHENTICATED', 'REGISTERED');
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getCcCode($code)
|
65 |
+
{
|
66 |
+
$data = array(
|
67 |
+
'VI' => 'VISA',
|
68 |
+
'AE' => 'AMEX',
|
69 |
+
'MC' => 'MC',
|
70 |
+
'DI' => 'DC',
|
71 |
+
'JCB' => 'JCB',
|
72 |
+
'SM' => 'MAESTRO',
|
73 |
+
'SO' => 'SOLO',
|
74 |
+
'OT' => 'Other',
|
75 |
+
);
|
76 |
+
return $data[$code];
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
?>
|
app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Sagepay.php
CHANGED
@@ -2,8 +2,10 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Sagepay extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
|
|
5 |
public function _construct()
|
6 |
-
{
|
7 |
$this->_init('sagepay/sagepay', 'sagepay_id');
|
8 |
}
|
9 |
-
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Sagepay extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
5 |
+
|
6 |
public function _construct()
|
7 |
+
{
|
8 |
$this->_init('sagepay/sagepay', 'sagepay_id');
|
9 |
}
|
10 |
+
|
11 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Sagepay/Collection.php
CHANGED
@@ -2,9 +2,11 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Sagepay_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
{
|
|
|
5 |
public function _construct()
|
6 |
{
|
7 |
parent::_construct();
|
8 |
$this->_init('sagepay/sagepay');
|
9 |
}
|
10 |
-
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Sagepay_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
{
|
5 |
+
|
6 |
public function _construct()
|
7 |
{
|
8 |
parent::_construct();
|
9 |
$this->_init('sagepay/sagepay');
|
10 |
}
|
11 |
+
|
12 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Transaction.php
CHANGED
@@ -2,8 +2,10 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Transaction extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
|
|
5 |
public function _construct()
|
6 |
-
{
|
7 |
-
|
8 |
}
|
9 |
-
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Transaction extends Mage_Core_Model_Mysql4_Abstract
|
4 |
{
|
5 |
+
|
6 |
public function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('sagepay/transaction', 'transaction_id');
|
9 |
}
|
10 |
+
|
11 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Model/Mysql4/Transaction/Collection.php
CHANGED
@@ -2,9 +2,11 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Transaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
{
|
|
|
5 |
public function _construct()
|
6 |
{
|
7 |
parent::_construct();
|
8 |
$this->_init('sagepay/transaction');
|
9 |
}
|
10 |
-
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Mysql4_Transaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
{
|
5 |
+
|
6 |
public function _construct()
|
7 |
{
|
8 |
parent::_construct();
|
9 |
$this->_init('sagepay/transaction');
|
10 |
}
|
11 |
+
|
12 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Model/Observer.php
CHANGED
@@ -1,29 +1,33 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Raveinfosys_Sagepay_Model_Observer
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
28 |
}
|
|
|
29 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
class Raveinfosys_Sagepay_Model_Observer
|
4 |
+
{
|
5 |
+
|
6 |
+
public function disableMethod(Varien_Event_Observer $observer)
|
7 |
+
{
|
8 |
+
$moduleName = "Raveinfosys_Sagepay";
|
9 |
+
if ('sagepay' == $observer->getMethodInstance()->getCode()) {
|
10 |
+
if (!Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) {
|
11 |
+
//nothing here, as module is ENABLE
|
12 |
+
} else {
|
13 |
+
$observer->getResult()->isAvailable = false;
|
14 |
+
}
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
public function layoutUpdate(Varien_Event_Observer $observer)
|
19 |
+
{
|
20 |
+
if (!Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName) && !Mage::getStoreConfigFlag('payment/sagepay/active')) {
|
21 |
+
return $observer;
|
22 |
+
}
|
23 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getData();
|
24 |
+
if ($quote['method'] == 'sagepay') {
|
25 |
+
$updates = $observer->getEvent()->getUpdates();
|
26 |
+
$updates->addChild('sagepay_checkout_review')
|
27 |
+
->file = 'sagepay_checkout2.xml';
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
}
|
32 |
+
|
33 |
?>
|
app/code/community/Raveinfosys/Sagepay/Model/Payment.php
CHANGED
@@ -1,89 +1,91 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Raveinfosys_Sagepay_Model_Payment extends Mage_Payment_Model_Method_Ccsave
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
protected $
|
8 |
-
protected $
|
9 |
-
protected $
|
10 |
-
protected $
|
11 |
-
|
12 |
-
protected $
|
13 |
-
protected $
|
14 |
-
protected $
|
15 |
-
protected $
|
16 |
-
protected $
|
17 |
-
protected $
|
|
|
18 |
protected $_infoBlockType = 'payment/info_cc';
|
19 |
-
protected $_canSaveCc
|
20 |
-
|
21 |
-
|
22 |
const ACTION_VOID = 'VOID';
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
private $urls;
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
public function isMsOnOverview() {
|
79 |
return ($this->_getQuote()->getIsMultiShipping() && $this->getMsActiveStep() == 'multishipping_overview');
|
80 |
}
|
81 |
-
|
82 |
-
|
|
|
83 |
return Mage::getSingleton('checkout/type_multishipping_state')->getActiveStep();
|
84 |
}
|
85 |
-
|
86 |
-
|
|
|
87 |
|
88 |
if ($this->isMsOnOverview() && ($this->_getQuote()->getPayment()->getMethod() == 'sagepay')) {
|
89 |
return null;
|
@@ -97,7 +99,7 @@ class Raveinfosys_Sagepay_Model_Payment extends Mage_Payment_Model_Method_Ccsave
|
|
97 |
$this->_getQuote()->unsReservedOrderId();
|
98 |
$this->_getQuote()->reserveOrderId()->save();
|
99 |
}
|
100 |
-
|
101 |
$this->getSagepayModel()->setReservedId($orderId);
|
102 |
}
|
103 |
|
@@ -106,8 +108,9 @@ class Raveinfosys_Sagepay_Model_Payment extends Mage_Payment_Model_Method_Ccsave
|
|
106 |
}
|
107 |
return $orderId;
|
108 |
}
|
109 |
-
|
110 |
-
|
|
|
111 |
if (!$orderId)
|
112 |
return false;
|
113 |
|
@@ -116,10 +119,11 @@ class Raveinfosys_Sagepay_Model_Payment extends Mage_Payment_Model_Method_Ccsave
|
|
116 |
if (!$existingOrder->getId()) {
|
117 |
return false;
|
118 |
}
|
119 |
-
|
120 |
}
|
121 |
-
|
122 |
-
|
|
|
123 |
|
124 |
$opQuote = Mage::getSingleton('checkout/type_onepage')->getQuote();
|
125 |
$adminQuote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
@@ -128,664 +132,687 @@ class Raveinfosys_Sagepay_Model_Payment extends Mage_Payment_Model_Method_Ccsave
|
|
128 |
if ($adminQuote->hasItems() === false && (int) $rqQuoteId) {
|
129 |
$opQuote->setQuote(Mage::getModel('sales/quote')->loadActive($rqQuoteId));
|
130 |
}
|
131 |
-
|
132 |
}
|
133 |
|
134 |
-
|
135 |
-
|
136 |
return $this->_getReservedOid();
|
137 |
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
$order_amount=(double)$info->getQuote()->getBaseGrandTotal();
|
145 |
} elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
|
146 |
-
$order_amount=(double)$info->getOrder()->getQuoteBaseGrandTotal();
|
147 |
-
}
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
parent::validate();
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
$
|
215 |
-
$
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
232 |
-
|
233 |
-
$data = $this->getSagepayModel()->getCollection()->addFieldToFilter('order_id',$payment->getOrder()->getIncrementId())->getFirstItem();
|
234 |
-
|
235 |
-
if($data->getOrderId() == $payment->getOrder()->getIncrementId()){
|
236 |
-
$this->authorizePayment($payment, number_format($amount, 2, '.', ''),$data);
|
237 |
-
|
238 |
-
if(in_array($this->result['Status'],$this->getConfigModel()->getExpectedSuccess())){
|
239 |
-
$orderId = $payment->getOrder()->getIncrementId();
|
240 |
-
$sagepay_id = $this->getSagepayModel()->saveAuthorisedDetail($this->result,$this->VendorTxCode,$data, $payment->getOrder()->getIncrementId());
|
241 |
-
$this->getTransactionModel()->saveTransactionDetail($orderId ,$this->result, $this->VendorTxCode, self::ACTION_PAYMENT, $sagepay_id);
|
242 |
-
$payment->setStatus(self::STATUS_APPROVED);
|
243 |
-
$payment->setLastTransId((string)$this->VendorTxCode);
|
244 |
-
if (!$payment->getParentTransactionId() || (string)$this->VendorTxCode != $payment->getParentTransactionId()) {
|
245 |
-
$payment->setTransactionId((string)$this->VendorTxCode);
|
246 |
-
}
|
247 |
-
return $this;
|
248 |
-
}
|
249 |
-
else{
|
250 |
-
$payment->setSkipTransactionCreation(true);
|
251 |
-
if(in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())){
|
252 |
-
$error = $this->result;
|
253 |
-
Mage::throwException($error['Errors'][0]);
|
254 |
-
}
|
255 |
-
}
|
256 |
-
|
257 |
-
}
|
258 |
-
$this->Amount = number_format($amount, 2, '.', '');
|
259 |
-
$this->TxType = self::ACTION_PAYMENT;
|
260 |
-
$this->AccountType = 'M';
|
261 |
-
$this->Apply3DSecure = 2;
|
262 |
-
$result = $this->__processPayment($payment);
|
263 |
-
|
264 |
-
if (in_array($this->result['Status'],$this->getConfigModel()->getExpectedSuccess())) {
|
265 |
-
$orderId = $payment->getOrder()->getIncrementId();
|
266 |
-
$this->result['CustomerEmail'] = $this->CustomerEmail;
|
267 |
-
$this->result['CustomerName'] = $this->BillingFirstnames.' '.$this->BillingSurname;
|
268 |
-
$this->result['CardType'] = $this->CardType;
|
269 |
-
$this->result['CardHolderName'] = $this->CardHolder;
|
270 |
-
$this->result['CustomerContact'] = $this->BillingPhone;
|
271 |
-
$this->result['VendorTxCode'] = $this->VendorTxCode;
|
272 |
-
$sagepay_id = $this->getSagepayModel()->saveOrderDetail($this->result,$orderId);
|
273 |
-
$this->getSagepayModel()->saveCardDetail($sagepay_id,$this->result);
|
274 |
-
$this->getTransactionModel()->saveTransactionDetail($orderId ,$this->result, $this->VendorTxCode, self::ACTION_PAYMENT, $sagepay_id);
|
275 |
-
$payment->setStatus(self::STATUS_APPROVED);
|
276 |
-
$payment->setLastTransId((string)$this->VendorTxCode);
|
277 |
-
if (!$payment->getParentTransactionId() || (string)$this->VendorTxCode != $payment->getParentTransactionId()) {
|
278 |
-
$payment->setTransactionId((string)$this->VendorTxCode);
|
279 |
-
}
|
280 |
-
return $this;
|
281 |
-
}
|
282 |
-
else{
|
283 |
-
$payment->setSkipTransactionCreation(true);
|
284 |
-
if($result=='ERROR'){
|
285 |
-
$error = $this->result;
|
286 |
-
Mage::throwException($error['Errors'][0]);
|
287 |
-
}
|
288 |
-
else if(in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
289 |
-
Mage::throwException("Gateway error : {".(string)$this->result['Errors'][0]."}");
|
290 |
-
}
|
291 |
-
}
|
292 |
-
}
|
293 |
-
else{
|
294 |
-
$session = Mage::getSingleton('core/session');
|
295 |
-
if ($data = $session->getGatewayResult()) {
|
296 |
-
$payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
|
297 |
-
$orderId = $payment->getOrder()->getIncrementId();
|
298 |
-
$sagepay_id = $this->getSagepayModel()->saveOrderDetail($data,$orderId);
|
299 |
-
$this->getSagepayModel()->saveCardDetail($sagepay_id,$data);
|
300 |
-
$this->getTransactionModel()->saveTransactionDetail($orderId ,$data, $data['VendorTxCode'], $data['TxType'], $sagepay_id);
|
301 |
-
$payment->setStatus(self::STATUS_APPROVED);
|
302 |
-
$payment->setLastTransId((string)$data['VendorTxCode']);
|
303 |
-
if (!$payment->getParentTransactionId() || (string)$data['VendorTxCode'] != $payment->getParentTransactionId()) {
|
304 |
-
$payment->setTransactionId((string)$data['VendorTxCode']);
|
305 |
-
}
|
306 |
-
$session->unsGatewayResult()->unsPaymentdata();
|
307 |
-
}
|
308 |
-
return $this;
|
309 |
-
}
|
310 |
-
}
|
311 |
-
|
312 |
-
public function authorizePayment(Varien_Object $payment, $amount, $data) {
|
313 |
-
$params = array();
|
314 |
-
$params['VPSProtocol'] = urlencode('2.23');
|
315 |
-
$params['TxType'] = self::ACTION_AUTHORISE;
|
316 |
-
$params['Vendor'] = urlencode(Mage::getStoreConfig('payment/sagepay/vendor_name'));
|
317 |
-
$params['VendorTxCode'] = time() . rand(0, 9999).'-'.$payment->getOrder()->getIncrementId();
|
318 |
-
$this->VendorTxCode = $params['VendorTxCode'];
|
319 |
-
$params['Amount'] = urlencode($amount);
|
320 |
-
$params['Description'] = $this->Description;
|
321 |
-
$params['RelatedVPSTxId'] = $data->getVpsTxId(); //VPSTxId of main transaction
|
322 |
-
$params['RelatedVendorTxCode'] = urlencode($data->getVendorTxCode()); //VendorTxCode of main transaction
|
323 |
-
$params['RelatedSecurityKey'] = urlencode($data->getSecurityKey()); //securitykey of main transaction
|
324 |
-
|
325 |
-
$this->result = $this->requestPost($this->urls['authorise'], $params);
|
326 |
-
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
327 |
-
$this->result['Errors'] = array();
|
328 |
-
foreach(split("\n", $this->result['StatusDetail']) as $error) {
|
329 |
-
$this->result['Errors'] = array_merge($this->result['Errors'], $this->getError($error));
|
330 |
-
}
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
public function refund(Varien_Object $payment, $amount) {
|
335 |
-
if ($payment->getRefundTransactionId() && $amount > 0) {
|
336 |
-
$data = $this->getSagepayModel()->getCollection()->addFieldToFilter('vendor_tx_code',trim($payment->getRefundTransactionId()))->getFirstItem();
|
337 |
-
|
338 |
-
$params = array();
|
339 |
-
$params['VPSProtocol'] = urlencode('2.23');
|
340 |
-
$params['TxType'] = self::ACTION_REFUND;
|
341 |
-
$params['Vendor'] = urlencode(Mage::getStoreConfig('payment/sagepay/vendor_name'));
|
342 |
-
$params['VendorTxCode'] = time() . rand(0, 9999).'-'.$payment->getOrder()->getIncrementId();
|
343 |
-
$params['Amount'] = urlencode(number_format($amount, 2, '.', ''));
|
344 |
-
$params['Currency'] = urlencode(Mage::app()->getStore()->getCurrentCurrencyCode());
|
345 |
-
$params['Description'] = $this->Description;
|
346 |
-
$params['RelatedVPSTxId'] = $data->getVpsTxId();
|
347 |
-
$params['RelatedVendorTxCode'] = urlencode($data->getVendorTxCode());
|
348 |
-
$params['RelatedSecurityKey'] = urlencode($data->getSecurityKey());
|
349 |
-
$params['RelatedTxAuthNo'] = urlencode($data->getTxAuthNo());
|
350 |
-
|
351 |
-
$this->result = $this->requestPost($this->urls['refund'], $params);
|
352 |
-
|
353 |
-
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
354 |
-
$this->result['Errors'] = array();
|
355 |
-
foreach(split("\n", $this->result['StatusDetail']) as $error) {
|
356 |
-
$this->result['Errors'] = array_merge($this->result['Errors'], $this->getError($error));
|
357 |
-
}
|
358 |
-
}
|
359 |
-
if (in_array($this->result['Status'],$this->getConfigModel()->getExpectedSuccess())){
|
360 |
-
$orderId = $payment->getOrder()->getIncrementId();
|
361 |
-
$this->getSagepayModel()->saveRefundDetail($this->result,$data->getSagepayId());
|
362 |
-
$this->getTransactionModel()->saveTransactionDetail($orderId ,$this->result, $params['VendorTxCode'], self::ACTION_REFUND, $data->getSagepayId());
|
363 |
-
$payment->setStatus(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
|
364 |
-
$payment->setLastTransId((string)$params['VendorTxCode']);
|
365 |
-
if (!$payment->getParentTransactionId() || (string)$params['VendorTxCode'] != $payment->getParentTransactionId()) {
|
366 |
-
$payment->setTransactionId((string)$params['VendorTxCode']);
|
367 |
-
}
|
368 |
-
return $this;
|
369 |
-
}
|
370 |
-
else{
|
371 |
-
if($result=='ERROR'){
|
372 |
-
$error = $this->result;
|
373 |
-
Mage::throwException($error['Errors'][0]);
|
374 |
-
}
|
375 |
-
else if(in_array($result, $this->getConfigModel()->getExpectedError())) {
|
376 |
-
Mage::throwException("Gateway error : {".(string)$this->result['Errors'][0]."}");
|
377 |
-
}
|
378 |
-
}
|
379 |
-
}
|
380 |
Mage::throwException(Mage::helper('paygate')->__('Error in refunding the payment.'));
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
}
|
423 |
-
}
|
424 |
return $this;
|
425 |
}
|
426 |
-
|
427 |
-
public function cancel(Varien_Object $payment)
|
|
|
428 |
$orderId = $payment->getOrder()->getIncrementId();
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
}
|
465 |
-
}
|
466 |
return $this;
|
467 |
-
}
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
744 |
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for transaction.'));
|
745 |
}
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
$payment->setTransactionId($transactionId);
|
783 |
$payment->resetTransactionAdditionalInfo();
|
784 |
foreach ($transactionDetails as $key => $value) {
|
785 |
$payment->setData($key, $value);
|
786 |
}
|
787 |
-
|
788 |
-
$transaction = $payment->addTransaction($transactionType, null, false
|
789 |
foreach ($transactionDetails as $key => $value) {
|
790 |
$payment->unsetData($key);
|
791 |
}
|
@@ -795,18 +822,22 @@ class Raveinfosys_Sagepay_Model_Payment extends Mage_Payment_Model_Method_Ccsave
|
|
795 |
|
796 |
return $transaction;
|
797 |
}
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
|
|
|
|
|
|
810 |
|
811 |
}
|
|
|
812 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
class Raveinfosys_Sagepay_Model_Payment extends Mage_Payment_Model_Method_Ccsave
|
4 |
+
{
|
5 |
+
|
6 |
+
protected $_code = 'sagepay';
|
7 |
+
protected $_isGateway = true; //Is this payment method a gateway (online auth/charge) ?
|
8 |
+
protected $_canAuthorize = true; //Can authorize online?
|
9 |
+
protected $_canCapture = true; //Can capture funds online?
|
10 |
+
protected $_canCapturePartial = true; //Can capture partial amounts online?
|
11 |
+
protected $_canRefund = true; //Can refund online?
|
12 |
+
protected $_canRefundInvoicePartial = true; //Can refund invoices partially?
|
13 |
+
protected $_canVoid = true; //Can void transactions online?
|
14 |
+
protected $_canUseInternal = true; //Can use this payment method in administration panel?
|
15 |
+
protected $_canUseCheckout = true; //Can show this payment method as an option on checkout payment page?
|
16 |
+
protected $_canUseForMultishipping = true; //Is this payment method suitable for multi-shipping checkout?
|
17 |
+
protected $_canFetchTransactionInfo = false;
|
18 |
+
protected $_canReviewPayment = true;
|
19 |
protected $_infoBlockType = 'payment/info_cc';
|
20 |
+
protected $_canSaveCc = false;
|
21 |
+
|
22 |
+
const ACTION_PAYMENT = 'PAYMENT';
|
23 |
const ACTION_VOID = 'VOID';
|
24 |
+
const ACTION_AUTHORISE = 'AUTHORISE';
|
25 |
+
const ACTION_AUTHENTICATE = 'AUTHENTICATE';
|
26 |
+
const ACTION_REFUND = 'REFUND';
|
27 |
+
const ACTION_CANCEL = 'CANCEL';
|
28 |
+
|
29 |
private $urls;
|
30 |
+
private $Vendor;
|
31 |
+
private $Basket = array();
|
32 |
+
public $AccountType = 'E';
|
33 |
+
public $GiftAidPayment = 0;
|
34 |
+
public $ApplyAVSCV2 = 0;
|
35 |
+
public $Apply3DSecure = 0;
|
36 |
+
public $Description = "Sagepay Direct Transaction.";
|
37 |
+
public $VendorTxCode;
|
38 |
+
public $TxType;
|
39 |
+
public $Amount;
|
40 |
+
public $Currency;
|
41 |
+
public $CardHolder;
|
42 |
+
public $CardNumber;
|
43 |
+
public $StartDate;
|
44 |
+
public $ExpiryDate;
|
45 |
+
public $IssueNumber;
|
46 |
+
public $CV2;
|
47 |
+
public $CardType;
|
48 |
+
public $BillingSurname;
|
49 |
+
public $BillingFirstnames;
|
50 |
+
public $BillingAddress1;
|
51 |
+
public $BillingAddress2;
|
52 |
+
public $BillingCity;
|
53 |
+
public $BillingPostCode;
|
54 |
+
public $BillingCountry;
|
55 |
+
public $BillingState;
|
56 |
+
public $BillingPhone;
|
57 |
+
public $DeliverySurname;
|
58 |
+
public $DeliveryFirstnames;
|
59 |
+
public $DeliveryAddress1;
|
60 |
+
public $DeliveryAddress2;
|
61 |
+
public $DeliveryCity;
|
62 |
+
public $DeliveryPostCode;
|
63 |
+
public $DeliveryCountry;
|
64 |
+
public $DeliveryState;
|
65 |
+
public $DeliveryPhone;
|
66 |
+
public $CustomerEmail;
|
67 |
+
public $OrderIncrementId;
|
68 |
+
public $result = array('Status' => 'BEGIN');
|
69 |
+
|
70 |
+
public function __construct($vendor, $mode = 'simulator')
|
71 |
+
{
|
72 |
+
|
73 |
+
$this->urls = $this->getConfigModel()->getGatewayURL();
|
74 |
+
$this->Vendor = $this->getConfigModel()->getVendor();
|
75 |
+
}
|
76 |
+
|
77 |
+
public function isMsOnOverview()
|
78 |
+
{
|
|
|
79 |
return ($this->_getQuote()->getIsMultiShipping() && $this->getMsActiveStep() == 'multishipping_overview');
|
80 |
}
|
81 |
+
|
82 |
+
public function getMsActiveStep()
|
83 |
+
{
|
84 |
return Mage::getSingleton('checkout/type_multishipping_state')->getActiveStep();
|
85 |
}
|
86 |
+
|
87 |
+
protected function _getReservedOid()
|
88 |
+
{
|
89 |
|
90 |
if ($this->isMsOnOverview() && ($this->_getQuote()->getPayment()->getMethod() == 'sagepay')) {
|
91 |
return null;
|
99 |
$this->_getQuote()->unsReservedOrderId();
|
100 |
$this->_getQuote()->reserveOrderId()->save();
|
101 |
}
|
102 |
+
$orderId = $this->_getQuote()->getReservedOrderId();
|
103 |
$this->getSagepayModel()->setReservedId($orderId);
|
104 |
}
|
105 |
|
108 |
}
|
109 |
return $orderId;
|
110 |
}
|
111 |
+
|
112 |
+
protected function _orderIdAlreadyUsed($orderId)
|
113 |
+
{
|
114 |
if (!$orderId)
|
115 |
return false;
|
116 |
|
119 |
if (!$existingOrder->getId()) {
|
120 |
return false;
|
121 |
}
|
122 |
+
return true;
|
123 |
}
|
124 |
+
|
125 |
+
protected function _getQuote()
|
126 |
+
{
|
127 |
|
128 |
$opQuote = Mage::getSingleton('checkout/type_onepage')->getQuote();
|
129 |
$adminQuote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
132 |
if ($adminQuote->hasItems() === false && (int) $rqQuoteId) {
|
133 |
$opQuote->setQuote(Mage::getModel('sales/quote')->loadActive($rqQuoteId));
|
134 |
}
|
135 |
+
return ($adminQuote->hasItems() === true) ? $adminQuote : $opQuote;
|
136 |
}
|
137 |
|
138 |
+
protected function _getTrnVendorTxCode()
|
139 |
+
{
|
140 |
return $this->_getReservedOid();
|
141 |
}
|
142 |
+
|
143 |
+
public function validate()
|
144 |
+
{
|
145 |
+
$info = $this->getInfoInstance();
|
146 |
+
$order_amount = 0;
|
147 |
+
if ($info instanceof Mage_Sales_Model_Quote_Payment) {
|
148 |
+
$order_amount = (double) $info->getQuote()->getBaseGrandTotal();
|
149 |
} elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
|
150 |
+
$order_amount = (double) $info->getOrder()->getQuoteBaseGrandTotal();
|
151 |
+
}
|
152 |
+
|
153 |
+
$order_min = $this->getConfigData('min_order_total');
|
154 |
+
$order_max = $this->getConfigData('max_order_total');
|
155 |
+
if (!empty($order_max) && (double) $order_max < $order_amount) {
|
156 |
+
Mage::throwException("Order amount greater than permissible Maximum order amount.");
|
157 |
+
}
|
158 |
+
if (!empty($order_min) && (double) $order_min > $order_amount) {
|
159 |
+
Mage::throwException("Order amount less than required Minimum order amount.");
|
160 |
+
}
|
161 |
+
|
162 |
parent::validate();
|
163 |
+
}
|
164 |
+
|
165 |
+
public function authorize(Varien_Object $payment, $amount)
|
166 |
+
{
|
167 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
168 |
+
if ($amount <= 0) {
|
169 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for transaction.'));
|
170 |
+
}
|
171 |
+
|
172 |
+
$this->Amount = number_format($amount, 2, '.', '');
|
173 |
+
$this->TxType = self::ACTION_AUTHENTICATE;
|
174 |
+
$this->AccountType = 'M';
|
175 |
+
$this->Apply3DSecure = 2;
|
176 |
+
$result = $this->__processPayment($payment);
|
177 |
+
|
178 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedSuccess())) {
|
179 |
+
$payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
|
180 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
181 |
+
$this->result['CustomerEmail'] = $this->CustomerEmail;
|
182 |
+
$this->result['CustomerName'] = $this->BillingFirstnames . ' ' . $this->BillingSurname;
|
183 |
+
$this->result['CardType'] = $this->CardType;
|
184 |
+
$this->result['CardHolderName'] = $this->CardHolder;
|
185 |
+
$this->result['CustomerContact'] = $this->BillingPhone;
|
186 |
+
$this->result['VendorTxCode'] = $this->VendorTxCode;
|
187 |
+
$sagepay_id = $this->getSagepayModel()->saveAuthDetail($this->result, $orderId);
|
188 |
+
$this->getSagepayModel()->saveCardDetail($sagepay_id, $this->result);
|
189 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $this->result, $this->VendorTxCode, self::ACTION_AUTHENTICATE, $sagepay_id);
|
190 |
+
$this->_addTransaction(
|
191 |
+
$payment, $this->VendorTxCode, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, array('is_transaction_closed' => 0));
|
192 |
+
|
193 |
+
$payment->setSkipTransactionCreation(true);
|
194 |
+
return $this;
|
195 |
+
} else {
|
196 |
+
$payment->setSkipTransactionCreation(true);
|
197 |
+
if ($result == 'ERROR') {
|
198 |
+
$error = $this->result;
|
199 |
+
Mage::throwException($error['Errors'][0]);
|
200 |
+
} else if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
201 |
+
Mage::throwException("Gateway error : {" . (string) $this->result['Errors'][0] . "}");
|
202 |
+
}
|
203 |
+
}
|
204 |
+
} else {
|
205 |
+
$session = Mage::getSingleton('core/session');
|
206 |
+
if ($data = $session->getGatewayResult()) {
|
207 |
+
$payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
|
208 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
209 |
+
$sagepay_id = $this->getSagepayModel()->saveAuthDetail($data, $orderId);
|
210 |
+
$this->getSagepayModel()->saveCardDetail($sagepay_id, $data);
|
211 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $data, $data['VendorTxCode'], self::ACTION_AUTHENTICATE, $sagepay_id);
|
212 |
+
$this->_addTransaction(
|
213 |
+
$payment, $data['VendorTxCode'], Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, array('is_transaction_closed' => 0));
|
214 |
+
$session->unsGatewayResult()->unsPaymentdata();
|
215 |
+
$payment->setSkipTransactionCreation(true);
|
216 |
+
}
|
217 |
+
return $this;
|
218 |
}
|
219 |
+
}
|
220 |
+
|
221 |
+
public function capture(Varien_Object $payment, $amount)
|
222 |
+
{
|
223 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
224 |
+
if ($amount <= 0) {
|
225 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for transaction.'));
|
226 |
+
}
|
227 |
+
|
228 |
+
$data = $this->getSagepayModel()->getCollection()->addFieldToFilter('order_id', $payment->getOrder()->getIncrementId())->getFirstItem();
|
229 |
+
|
230 |
+
if ($data->getOrderId() == $payment->getOrder()->getIncrementId()) {
|
231 |
+
$this->authorizePayment($payment, number_format($amount, 2, '.', ''), $data);
|
232 |
+
|
233 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedSuccess())) {
|
234 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
235 |
+
$sagepay_id = $this->getSagepayModel()->saveAuthorisedDetail($this->result, $this->VendorTxCode, $data, $payment->getOrder()->getIncrementId());
|
236 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $this->result, $this->VendorTxCode, self::ACTION_PAYMENT, $sagepay_id);
|
237 |
+
$payment->setStatus(self::STATUS_APPROVED);
|
238 |
+
$payment->setLastTransId((string) $this->VendorTxCode);
|
239 |
+
if (!$payment->getParentTransactionId() || (string) $this->VendorTxCode != $payment->getParentTransactionId()) {
|
240 |
+
$payment->setTransactionId((string) $this->VendorTxCode);
|
241 |
+
}
|
242 |
+
return $this;
|
243 |
+
} else {
|
244 |
+
$payment->setSkipTransactionCreation(true);
|
245 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
246 |
+
$error = $this->result;
|
247 |
+
Mage::throwException($error['Errors'][0]);
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
$this->Amount = number_format($amount, 2, '.', '');
|
252 |
+
$this->TxType = self::ACTION_PAYMENT;
|
253 |
+
$this->AccountType = 'M';
|
254 |
+
$this->Apply3DSecure = 2;
|
255 |
+
$result = $this->__processPayment($payment);
|
256 |
+
|
257 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedSuccess())) {
|
258 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
259 |
+
$this->result['CustomerEmail'] = $this->CustomerEmail;
|
260 |
+
$this->result['CustomerName'] = $this->BillingFirstnames . ' ' . $this->BillingSurname;
|
261 |
+
$this->result['CardType'] = $this->CardType;
|
262 |
+
$this->result['CardHolderName'] = $this->CardHolder;
|
263 |
+
$this->result['CustomerContact'] = $this->BillingPhone;
|
264 |
+
$this->result['VendorTxCode'] = $this->VendorTxCode;
|
265 |
+
$sagepay_id = $this->getSagepayModel()->saveOrderDetail($this->result, $orderId);
|
266 |
+
$this->getSagepayModel()->saveCardDetail($sagepay_id, $this->result);
|
267 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $this->result, $this->VendorTxCode, self::ACTION_PAYMENT, $sagepay_id);
|
268 |
+
$payment->setStatus(self::STATUS_APPROVED);
|
269 |
+
$payment->setLastTransId((string) $this->VendorTxCode);
|
270 |
+
if (!$payment->getParentTransactionId() || (string) $this->VendorTxCode != $payment->getParentTransactionId()) {
|
271 |
+
$payment->setTransactionId((string) $this->VendorTxCode);
|
272 |
+
}
|
273 |
+
return $this;
|
274 |
+
} else {
|
275 |
+
$payment->setSkipTransactionCreation(true);
|
276 |
+
if ($result == 'ERROR') {
|
277 |
+
$error = $this->result;
|
278 |
+
Mage::throwException($error['Errors'][0]);
|
279 |
+
} else if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
280 |
+
Mage::throwException("Gateway error : {" . (string) $this->result['Errors'][0] . "}");
|
281 |
+
}
|
282 |
+
}
|
283 |
+
} else {
|
284 |
+
$session = Mage::getSingleton('core/session');
|
285 |
+
if ($data = $session->getGatewayResult()) {
|
286 |
+
$payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
|
287 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
288 |
+
$sagepay_id = $this->getSagepayModel()->saveOrderDetail($data, $orderId);
|
289 |
+
$this->getSagepayModel()->saveCardDetail($sagepay_id, $data);
|
290 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $data, $data['VendorTxCode'], $data['TxType'], $sagepay_id);
|
291 |
+
$payment->setStatus(self::STATUS_APPROVED);
|
292 |
+
$payment->setLastTransId((string) $data['VendorTxCode']);
|
293 |
+
if (!$payment->getParentTransactionId() || (string) $data['VendorTxCode'] != $payment->getParentTransactionId()) {
|
294 |
+
$payment->setTransactionId((string) $data['VendorTxCode']);
|
295 |
+
}
|
296 |
+
$session->unsGatewayResult()->unsPaymentdata();
|
297 |
+
}
|
298 |
+
return $this;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
public function authorizePayment(Varien_Object $payment, $amount, $data)
|
303 |
+
{
|
304 |
+
$params = array();
|
305 |
+
$params['VPSProtocol'] = urlencode('2.23');
|
306 |
+
$params['TxType'] = self::ACTION_AUTHORISE;
|
307 |
+
$params['Vendor'] = urlencode(Mage::getStoreConfig('payment/sagepay/vendor_name'));
|
308 |
+
$params['VendorTxCode'] = time() . rand(0, 9999) . '-' . $payment->getOrder()->getIncrementId();
|
309 |
+
$this->VendorTxCode = $params['VendorTxCode'];
|
310 |
+
$params['Amount'] = urlencode($amount);
|
311 |
+
$params['Description'] = $this->Description;
|
312 |
+
$params['RelatedVPSTxId'] = $data->getVpsTxId(); //VPSTxId of main transaction
|
313 |
+
$params['RelatedVendorTxCode'] = urlencode($data->getVendorTxCode()); //VendorTxCode of main transaction
|
314 |
+
$params['RelatedSecurityKey'] = urlencode($data->getSecurityKey()); //securitykey of main transaction
|
315 |
+
|
316 |
+
$this->result = $this->requestPost($this->urls['authorise'], $params);
|
317 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
318 |
+
$this->result['Errors'] = array();
|
319 |
+
foreach (preg_split("\n", $this->result['StatusDetail']) as $error) {
|
320 |
+
$this->result['Errors'] = array_merge($this->result['Errors'], $this->getError($error));
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
public function refund(Varien_Object $payment, $amount)
|
326 |
+
{
|
327 |
+
if ($payment->getRefundTransactionId() && $amount > 0) {
|
328 |
+
$data = $this->getSagepayModel()->getCollection()->addFieldToFilter('vendor_tx_code', trim($payment->getRefundTransactionId()))->getFirstItem();
|
329 |
+
|
330 |
+
$params = array();
|
331 |
+
$params['VPSProtocol'] = urlencode('2.23');
|
332 |
+
$params['TxType'] = self::ACTION_REFUND;
|
333 |
+
$params['Vendor'] = urlencode(Mage::getStoreConfig('payment/sagepay/vendor_name'));
|
334 |
+
$params['VendorTxCode'] = time() . rand(0, 9999) . '-' . $payment->getOrder()->getIncrementId();
|
335 |
+
$params['Amount'] = urlencode(number_format($amount, 2, '.', ''));
|
336 |
+
$params['Currency'] = urlencode(Mage::app()->getStore()->getCurrentCurrencyCode());
|
337 |
+
$params['Description'] = $this->Description;
|
338 |
+
$params['RelatedVPSTxId'] = $data->getVpsTxId();
|
339 |
+
$params['RelatedVendorTxCode'] = urlencode($data->getVendorTxCode());
|
340 |
+
$params['RelatedSecurityKey'] = urlencode($data->getSecurityKey());
|
341 |
+
$params['RelatedTxAuthNo'] = urlencode($data->getTxAuthNo());
|
342 |
+
|
343 |
+
$this->result = $this->requestPost($this->urls['refund'], $params);
|
344 |
+
|
345 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
346 |
+
$this->result['Errors'] = array();
|
347 |
+
foreach (preg_split("\n", $this->result['StatusDetail']) as $error) {
|
348 |
+
$this->result['Errors'] = array_merge($this->result['Errors'], $this->getError($error));
|
349 |
+
}
|
350 |
+
}
|
351 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedSuccess())) {
|
352 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
353 |
+
$this->getSagepayModel()->saveRefundDetail($this->result, $data->getSagepayId());
|
354 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $this->result, $params['VendorTxCode'], self::ACTION_REFUND, $data->getSagepayId());
|
355 |
+
$payment->setStatus(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
|
356 |
+
$payment->setLastTransId((string) $params['VendorTxCode']);
|
357 |
+
if (!$payment->getParentTransactionId() || (string) $params['VendorTxCode'] != $payment->getParentTransactionId()) {
|
358 |
+
$payment->setTransactionId((string) $params['VendorTxCode']);
|
359 |
+
}
|
360 |
+
return $this;
|
361 |
+
} else {
|
362 |
+
if ($result == 'ERROR') {
|
363 |
+
$error = $this->result;
|
364 |
+
Mage::throwException($error['Errors'][0]);
|
365 |
+
} else if (in_array($result, $this->getConfigModel()->getExpectedError())) {
|
366 |
+
Mage::throwException("Gateway error : {" . (string) $this->result['Errors'][0] . "}");
|
367 |
+
}
|
368 |
+
}
|
369 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
Mage::throwException(Mage::helper('paygate')->__('Error in refunding the payment.'));
|
371 |
+
}
|
372 |
+
|
373 |
+
public function void(Varien_Object $payment)
|
374 |
+
{
|
375 |
+
|
376 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
377 |
+
$data = $this->getSagepayModel()->getCollection()->addFieldToFilter('order_id', $orderId)->getFirstItem();
|
378 |
+
$params = array();
|
379 |
+
$params['VPSProtocol'] = urlencode('2.23');
|
380 |
+
$params['TxType'] = self::ACTION_VOID;
|
381 |
+
$params['Vendor'] = urlencode(Mage::getStoreConfig('payment/sagepay/vendor_name'));
|
382 |
+
$params['VendorTxCode'] = urlencode($data->getVendorTxCode());
|
383 |
+
$params['VPSTxId'] = $data->getVpsTxId();
|
384 |
+
$params['SecurityKey'] = urlencode($data->getSecurityKey());
|
385 |
+
$params['TxAuthNo'] = urlencode($data->getTxAuthNo());
|
386 |
+
|
387 |
+
$this->result = $this->requestPost($this->urls['void'], $params);
|
388 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
389 |
+
$this->result['Errors'] = array();
|
390 |
+
foreach (preg_split("\n", $this->result['StatusDetail']) as $error) {
|
391 |
+
$this->result['Errors'] = array_merge($this->result['Errors'], $this->getError($error));
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedSuccess())) {
|
396 |
+
$this->getSagepayModel()->saveVoidDetail($this->result, $data->getSagepayId());
|
397 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $this->result, $params['VendorTxCode'], self::ACTION_VOID, $data->getSagepayId());
|
398 |
+
$payment->setStatus(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
|
399 |
+
$payment->setLastTransId((string) $params['VendorTxCode']);
|
400 |
+
if (!$payment->getParentTransactionId() || (string) $params['VendorTxCode'] != $payment->getParentTransactionId()) {
|
401 |
+
$payment->setTransactionId((string) $params['VendorTxCode']);
|
402 |
+
}
|
403 |
+
return $this;
|
404 |
+
} else {
|
405 |
+
if ($result == 'ERROR') {
|
406 |
+
$error = $this->result;
|
407 |
+
Mage::throwException($error['Errors'][0]);
|
408 |
+
} else if (in_array($result, $this->getConfigModel()->getExpectedError())) {
|
409 |
+
Mage::throwException("Gateway error : {" . (string) $this->result['Errors'][0] . "}");
|
410 |
+
}
|
411 |
+
}
|
|
|
|
|
412 |
return $this;
|
413 |
}
|
414 |
+
|
415 |
+
public function cancel(Varien_Object $payment)
|
416 |
+
{
|
417 |
$orderId = $payment->getOrder()->getIncrementId();
|
418 |
+
$data = $this->getSagepayModel()->getCollection()->addFieldToFilter('order_id', $orderId)->getFirstItem();
|
419 |
+
$params = array();
|
420 |
+
$params['VPSProtocol'] = urlencode('2.23');
|
421 |
+
$params['TxType'] = self::ACTION_CANCEL;
|
422 |
+
$params['Vendor'] = urlencode(Mage::getStoreConfig('payment/sagepay/vendor_name'));
|
423 |
+
$params['VendorTxCode'] = urlencode($data->getVendorTxCode());
|
424 |
+
$params['VPSTxId'] = $data->getVpsTxId();
|
425 |
+
$params['SecurityKey'] = urlencode($data->getSecurityKey());
|
426 |
+
$params['TxAuthNo'] = urlencode($data->getTxAuthNo());
|
427 |
+
|
428 |
+
$this->result = $this->requestPost($this->urls['cancel'], $params);
|
429 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
430 |
+
$this->result['Errors'] = array();
|
431 |
+
foreach (preg_split("\n", $this->result['StatusDetail']) as $error) {
|
432 |
+
$this->result['Errors'] = array_merge($this->result['Errors'], $this->getError($error));
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedSuccess())) {
|
437 |
+
$this->getSagepayModel()->saveVoidDetail($this->result, $data->getSagepayId());
|
438 |
+
$this->getTransactionModel()->saveTransactionDetail($orderId, $this->result, $params['VendorTxCode'], self::ACTION_CANCEL, $data->getSagepayId());
|
439 |
+
$payment->setStatus(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
|
440 |
+
$payment->setLastTransId((string) $params['VendorTxCode']);
|
441 |
+
if (!$payment->getParentTransactionId() || (string) $params['VendorTxCode'] != $payment->getParentTransactionId()) {
|
442 |
+
$payment->setTransactionId((string) $params['VendorTxCode']);
|
443 |
+
}
|
444 |
+
return $this;
|
445 |
+
} else {
|
446 |
+
if ($result == 'ERROR') {
|
447 |
+
$error = $this->result;
|
448 |
+
Mage::throwException($error['Errors'][0]);
|
449 |
+
} else if (in_array($result, $this->getConfigModel()->getExpectedError())) {
|
450 |
+
Mage::throwException("Gateway error : {" . (string) $this->result['Errors'][0] . "}");
|
451 |
+
}
|
452 |
+
}
|
|
|
|
|
453 |
return $this;
|
454 |
+
}
|
455 |
+
|
456 |
+
public function __processPayment(Varien_Object $payment)
|
457 |
+
{
|
458 |
+
|
459 |
+
$this->Currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
460 |
+
$payment->setAmount($amount);
|
461 |
+
$this->CardHolder = $payment->getCcOwner();
|
462 |
+
$this->CardNumber = $payment->getCcNumber();
|
463 |
+
$this->ExpiryDate = date("my", strtotime('01-' . $payment->getCcExpMonth() . '-' . $payment->getCcExpYear()));
|
464 |
+
$this->IssueNumber = $payment->getCcSsIssue();
|
465 |
+
$this->CV2 = $payment->getCcCid();
|
466 |
+
$this->CardType = $this->getConfigModel()->getCcCode($payment->getCcType());
|
467 |
+
$order = $this->_getQuote();
|
468 |
+
$this->setGatewayOrderData($order);
|
469 |
+
return $this->register();
|
470 |
+
}
|
471 |
+
|
472 |
+
public function setGatewayOrderData($order)
|
473 |
+
{
|
474 |
+
|
475 |
+
if (!empty($order)) {
|
476 |
+
$BillingAddress = $order->getBillingAddress();
|
477 |
+
$this->BillingSurname = $BillingAddress->getLastname();
|
478 |
+
$this->BillingFirstnames = $BillingAddress->getFirstname();
|
479 |
+
$this->BillingAddress1 = $BillingAddress->getStreet(1);
|
480 |
+
$this->BillingAddress2;
|
481 |
+
$this->BillingCity = $BillingAddress->getCity();
|
482 |
+
$this->BillingPostCode = $BillingAddress->getPostcode();
|
483 |
+
$this->BillingCountry = $BillingAddress->getCountry();
|
484 |
+
$this->BillingState = Mage::getModel('directory/region')->load($BillingAddress->getRegionId())->getCode();
|
485 |
+
$this->BillingPhone = $BillingAddress->getTelephone();
|
486 |
+
if (!$order->getIsVirtual())
|
487 |
+
$ShippingAddress = $order->getShippingAddress();
|
488 |
+
else
|
489 |
+
$ShippingAddress = $order->getBillingAddress();
|
490 |
+
$this->DeliverySurname = $ShippingAddress->getLastname();
|
491 |
+
$this->DeliveryFirstnames = $ShippingAddress->getFirstname();
|
492 |
+
$this->DeliveryAddress1 = $ShippingAddress->getStreet(1);
|
493 |
+
$this->DeliveryAddress2;
|
494 |
+
$this->DeliveryCity = $ShippingAddress->getCity();
|
495 |
+
$this->DeliveryPostCode = $ShippingAddress->getPostcode();
|
496 |
+
$this->DeliveryCountry = $ShippingAddress->getCountry();
|
497 |
+
$this->DeliveryState = Mage::getModel('directory/region')->load($ShippingAddress->getRegionId())->getCode();
|
498 |
+
$this->DeliveryPhone = $ShippingAddress->getTelephone();
|
499 |
+
|
500 |
+
$this->CustomerEmail = $order->getCustomerEmail();
|
501 |
+
$this->VendorTxCode = time() . rand(0, 9999) . '-' . $this->_getTrnVendorTxCode(); //$this->_getQuote()->getReservedOrderId();
|
502 |
+
$product_array = array();
|
503 |
+
foreach ($order->getAllItems() as $item) {
|
504 |
+
if (!$item->getParentItemId())
|
505 |
+
$this->addLine($item->getName(), $item->getQty(), $item->getPrice(), $item->getTaxAmount());
|
506 |
+
}
|
507 |
+
foreach ($order->getAllAddresses() as $address) {
|
508 |
+
//Add shipping amount
|
509 |
+
if ($ship_amount = $address->getData('shipping_amount'))
|
510 |
+
$this->addLine($address->getData('shipping_description'), 1, $ship_amount, 0);
|
511 |
+
|
512 |
+
//Add discount amount
|
513 |
+
if ($address->getData('discount_amount') < 0)
|
514 |
+
$this->addLine('Discount', 1, $address->getData('discount_amount'), 0);
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
public function register()
|
520 |
+
{
|
521 |
+
|
522 |
+
$errors = array();
|
523 |
+
if (!$this->Vendor)
|
524 |
+
$errors[] = 'The Vendor must be provided';
|
525 |
+
if (!$this->VendorTxCode)
|
526 |
+
$errors[] = 'The VendorTxCode must be provided';
|
527 |
+
if (!is_numeric($this->Amount))
|
528 |
+
$errors[] = 'The Amount field must be specified, and must be numeric.';
|
529 |
+
if (!$this->Currency)
|
530 |
+
$errors[] = 'Currency must be specified, eg GBP.';
|
531 |
+
if (!$this->CardHolder)
|
532 |
+
$errors[] = 'CardHolder must be specified.';
|
533 |
+
if (!$this->CardNumber)
|
534 |
+
$errors[] = 'CardNumber must be specified.';
|
535 |
+
if (!$this->ExpiryDate)
|
536 |
+
$errors[] = 'ExpiryDate must be specified.';
|
537 |
+
if ($this->IssueNumber and ! preg_match("/^\d{1,2}$/", $this->IssueNumber))
|
538 |
+
$errors[] = 'IssueNumber is invalid.';
|
539 |
+
if ($this->CardType == 'AMEX' and ! preg_match("/^\d{4}$/", $this->CV2))
|
540 |
+
$errors[] = 'CV2 must be 4 numbers long.';
|
541 |
+
if ($this->CardType != 'AMEX' and ! preg_match("/^\d{3}$/", $this->CV2))
|
542 |
+
$errors[] = 'CV2 must be 3 numbers long.';
|
543 |
+
if (!in_array($this->CardType, array('VISA', 'MC', 'DELTA', 'SOLO', 'MAESTRO', 'UKE', 'AMEX', 'DC', 'JCB', 'LASER')))
|
544 |
+
$errors[] = 'CardType must be one of VISA, MC, DELTA, SOLO, MAESTRO, UKE, AMEX, DC, JCB, LASER';
|
545 |
+
if (!$this->BillingSurname)
|
546 |
+
$errors[] = 'BillingSurname must be specified.';
|
547 |
+
if (!$this->BillingFirstnames)
|
548 |
+
$errors[] = 'BillingFirstnames must be specified.';
|
549 |
+
if (!$this->BillingAddress1)
|
550 |
+
$errors[] = 'BillingAddress1 must be specified.';
|
551 |
+
if (!$this->BillingCity)
|
552 |
+
$errors[] = 'BillingCity must be specified.';
|
553 |
+
if (!$this->BillingPostCode)
|
554 |
+
$errors[] = 'BillingPostCode must be specified.';
|
555 |
+
if (!$this->BillingCountry)
|
556 |
+
$errors[] = 'BillingCountry must be specified.';
|
557 |
+
if ($this->BillingCountry == 'US' and ! $this->BillingState)
|
558 |
+
$errors['BillingState'] = 'BillingState mut be specified.';
|
559 |
+
if (!$this->DeliverySurname)
|
560 |
+
$errors[] = 'DeliverySurname must be specified.';
|
561 |
+
if (!$this->DeliveryFirstnames)
|
562 |
+
$errors[] = 'DeliveryFirstnames must be specified.';
|
563 |
+
if (!$this->DeliveryAddress1)
|
564 |
+
$errors[] = 'DeliveryAddress1 must be specified.';
|
565 |
+
if (!$this->DeliveryCity)
|
566 |
+
$errors[] = 'DeliveryCity must be specified.';
|
567 |
+
if (!$this->DeliveryPostCode)
|
568 |
+
$errors[] = 'DeliveryPostCode must be specified.';
|
569 |
+
if (!$this->DeliveryCountry)
|
570 |
+
$errors[] = 'DeliveryCountry must be specified.';
|
571 |
+
if ($this->DeliveryCountry == 'US' and ! $this->DeliveryState)
|
572 |
+
$errors[] = 'DeliveryState mut be specified.';
|
573 |
+
if ($this->CustomerEmail and ! preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+\.([a-zA-Z0-9\._-]+)+$/", $this->CustomerEmail))
|
574 |
+
$errors[] = 'CustomerEmail is invalid.';
|
575 |
+
|
576 |
+
if (count($errors)) {
|
577 |
+
$this->result = array('Status' => 'ERRORCHECKFAIL', 'Errors' => $errors);
|
578 |
+
return 'ERROR';
|
579 |
+
}
|
580 |
+
|
581 |
+
$data = array(
|
582 |
+
'VPSProtocol' => 2.23,
|
583 |
+
'TxType' => $this->TxType,
|
584 |
+
'Vendor' => $this->Vendor,
|
585 |
+
'VendorTxCode' => $this->VendorTxCode,
|
586 |
+
'Amount' => number_format($this->Amount, 2, '.', ''),
|
587 |
+
'Currency' => $this->Currency,
|
588 |
+
'Description' => $this->Description,
|
589 |
+
'CardHolder' => $this->CardHolder,
|
590 |
+
'CardNumber' => $this->CardNumber,
|
591 |
+
'ExpiryDate' => $this->ExpiryDate,
|
592 |
+
'IssueNumber' => $this->IssueNumber,
|
593 |
+
'CV2' => $this->CV2,
|
594 |
+
'CardType' => $this->CardType,
|
595 |
+
'BillingSurname' => $this->BillingSurname,
|
596 |
+
'BillingFirstnames' => $this->BillingFirstnames,
|
597 |
+
'BillingAddress1' => $this->BillingAddress1,
|
598 |
+
'BillingAddress2' => $this->BillingAddress2,
|
599 |
+
'BillingCity' => $this->BillingCity,
|
600 |
+
'BillingPostCode' => $this->BillingPostCode,
|
601 |
+
'BillingCountry' => $this->BillingCountry,
|
602 |
+
'BillingState' => $this->BillingCountry == 'US' ? $this->BillingState : '',
|
603 |
+
'BillingPhone' => $this->BillingPhone,
|
604 |
+
'DeliverySurname' => $this->DeliverySurname,
|
605 |
+
'DeliveryFirstnames' => $this->DeliveryFirstnames,
|
606 |
+
'DeliveryAddress1' => $this->DeliveryAddress1,
|
607 |
+
'DeliveryAddress2' => $this->DeliveryAddress2,
|
608 |
+
'DeliveryCity' => $this->DeliveryCity,
|
609 |
+
'DeliveryPostCode' => $this->DeliveryPostCode,
|
610 |
+
'DeliveryCountry' => $this->DeliveryCountry,
|
611 |
+
'DeliveryState' => $this->DeliveryCountry == 'US' ? $this->DeliveryState : '',
|
612 |
+
'DeliveryPhone' => $this->DeliveryPhone,
|
613 |
+
'CustomerEmail' => $this->CustomerEmail,
|
614 |
+
'GiftAidPayment' => $this->GiftAidPayment,
|
615 |
+
'AccountType' => $this->AccountType,
|
616 |
+
'ClientIPAddress' => $_SERVER['REMOTE_ADDR'],
|
617 |
+
'ApplyAVSCV2' => $this->ApplyAVSCV2,
|
618 |
+
'Apply3DSecure' => $this->Apply3DSecure
|
619 |
+
);
|
620 |
+
|
621 |
+
if (sizeof($this->Basket)) {
|
622 |
+
$data['Basket'] = count($this->Basket);
|
623 |
+
foreach ($this->Basket as $line) {
|
624 |
+
$data['Basket'] .= ':' . $line['description'];
|
625 |
+
$data['Basket'] .= ':' . $line['quantity'];
|
626 |
+
$data['Basket'] .= ':' . number_format($line['value'], 2, '.', '');
|
627 |
+
$data['Basket'] .= ':' . number_format($line['tax'], 2, '.', '');
|
628 |
+
$data['Basket'] .= ':' . number_format(($line['value'] + $line['tax']), 2, '.', '');
|
629 |
+
$data['Basket'] .= ':' . number_format(($line['quantity'] * ($line['value'] + $line['tax'])), 2, '.', '');
|
630 |
+
}
|
631 |
+
}
|
632 |
+
|
633 |
+
$this->result = $this->requestPost($this->urls['register'], $data);
|
634 |
+
|
635 |
+
if (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
636 |
+
$this->result['Errors'] = array();
|
637 |
+
foreach (preg_split("\n", $this->result['StatusDetail']) as $error) {
|
638 |
+
$this->result['Errors'] = array_merge($this->result['Errors'], $this->getError($error));
|
639 |
+
}
|
640 |
+
}
|
641 |
+
if ($this->result['Status'] == '3DAUTH') {
|
642 |
+
|
643 |
+
$this->result['VendorTxCode'] = $this->VendorTxCode;
|
644 |
+
return $this->result;
|
645 |
+
}
|
646 |
+
return $this->result;
|
647 |
+
}
|
648 |
+
|
649 |
+
public function addLine($description, $quantity, $value, $tax = 0)
|
650 |
+
{
|
651 |
+
$this->Basket[] = array(
|
652 |
+
'description' => $description,
|
653 |
+
'quantity' => $quantity,
|
654 |
+
'value' => $value,
|
655 |
+
'tax' => $tax
|
656 |
+
);
|
657 |
+
}
|
658 |
+
|
659 |
+
public static function recover3d()
|
660 |
+
{
|
661 |
+
$sagepay = unserialize($_SESSION['sagepay_obj']);
|
662 |
+
unset($_SESSION['sagepay_obj']);
|
663 |
+
return $sagepay;
|
664 |
+
}
|
665 |
+
|
666 |
+
public static function is3dResponse()
|
667 |
+
{
|
668 |
+
if (isset($_REQUEST['PaRes']) and isset($_REQUEST['MD']) and isset($_SESSION['sagepay_obj'])) {
|
669 |
+
return true;
|
670 |
+
} else {
|
671 |
+
return false;
|
672 |
+
}
|
673 |
+
}
|
674 |
+
|
675 |
+
public function complete3d($post_data)
|
676 |
+
{
|
677 |
+
$session = Mage::getSingleton('core/session');
|
678 |
+
$data = array(
|
679 |
+
'PARes' => $post_data['PaRes'],
|
680 |
+
'MD' => $post_data['MD']
|
681 |
+
);
|
682 |
+
|
683 |
+
$result = $this->requestPost($this->urls['3dsecure'], $data);
|
684 |
+
$vendor = $session->getGatewayResult();
|
685 |
+
$result['VendorTxCode'] = $vendor['VendorTxCode'];
|
686 |
+
$result['CustomerEmail'] = $vendor['CustomerEmail'];
|
687 |
+
$result['CustomerName'] = $vendor['CustomerName'];
|
688 |
+
$result['CardType'] = $vendor['CardType'];
|
689 |
+
$result['CardHolderName'] = $vendor['CardHolderName'];
|
690 |
+
$result['CustomerContact'] = $vendor['CustomerContact'];
|
691 |
+
$result['TxType'] = $vendor['TxType'];
|
692 |
+
return $result;
|
693 |
+
}
|
694 |
+
|
695 |
+
public function status()
|
696 |
+
{
|
697 |
+
return $this->result['Status'];
|
698 |
+
}
|
699 |
+
|
700 |
+
private function getError($message)
|
701 |
+
{
|
702 |
+
$chunks = preg_split(' : ', $message, 2);
|
703 |
+
if ($chunks[0] == '3048') {
|
704 |
+
return array('CardNumber' => 'The card number is invalid.');
|
705 |
+
}
|
706 |
+
if ($chunks[0] == '4022') {
|
707 |
+
return array('CardNumber' => 'The card number is not valid for the card type selected.');
|
708 |
+
}
|
709 |
+
if ($chunks[0] == '4023') {
|
710 |
+
return array('CardNumber' => 'The issue number must be provided.');
|
711 |
+
}
|
712 |
+
return array($message);
|
713 |
+
}
|
714 |
+
|
715 |
+
private function requestPost($url, $data)
|
716 |
+
{
|
717 |
+
$fields_string = http_build_query($data);
|
718 |
+
$log['request'] = $data;
|
719 |
+
set_time_limit(60);
|
720 |
+
$output = array();
|
721 |
+
$curlSession = curl_init();
|
722 |
+
curl_setopt($curlSession, CURLOPT_URL, $url);
|
723 |
+
curl_setopt($curlSession, CURLOPT_HEADER, 0);
|
724 |
+
curl_setopt($curlSession, CURLOPT_POST, 1);
|
725 |
+
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $fields_string);
|
726 |
+
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
|
727 |
+
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
|
728 |
+
curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
|
729 |
+
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 2);
|
730 |
+
$response = explode(chr(10), curl_exec($curlSession));
|
731 |
+
$log['response'] = $response;
|
732 |
+
$this->getSagepayModel()->logTransaction($log);
|
733 |
+
unset($this->CardNumber);
|
734 |
+
unset($this->ExpiryDate);
|
735 |
+
unset($this->CV2);
|
736 |
+
|
737 |
+
if (curl_error($curlSession)) {
|
738 |
+
$output['Status'] = "FAIL";
|
739 |
+
$output['StatusDetail'] = curl_error($curlSession);
|
740 |
+
}
|
741 |
+
curl_close($curlSession);
|
742 |
+
for ($i = 0; $i < count($response); $i++) {
|
743 |
+
$splitAt = strpos($response[$i], "=");
|
744 |
+
$output[trim(substr($response[$i], 0, $splitAt))] = trim(substr($response[$i], ($splitAt + 1)));
|
745 |
+
}
|
746 |
+
return $output;
|
747 |
+
}
|
748 |
+
|
749 |
+
public static function country($code)
|
750 |
+
{
|
751 |
+
$countries = $this->getSagepayModel()->countries();
|
752 |
+
return $countries[$code];
|
753 |
+
}
|
754 |
+
|
755 |
+
public function registerTransaction($data)
|
756 |
+
{
|
757 |
+
if (Mage::getStoreConfig('payment/sagepay/payment_action') == 'authorize') {
|
758 |
+
$this->TxType = self::ACTION_AUTHENTICATE;
|
759 |
+
} elseif (Mage::getStoreConfig('payment/sagepay/payment_action') == 'authorize_capture') {
|
760 |
+
$this->TxType = self::ACTION_PAYMENT;
|
761 |
+
}
|
762 |
+
return $this->sagePayRegisterPayment($data);
|
763 |
+
}
|
764 |
+
|
765 |
+
public function sagePayRegisterPayment($data)
|
766 |
+
{
|
767 |
+
|
768 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
769 |
+
$amount = $quote->getData('grand_total');
|
770 |
+
|
771 |
+
if ($amount <= 0) {
|
772 |
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for transaction.'));
|
773 |
}
|
774 |
+
|
775 |
+
$this->Currency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
776 |
+
$this->Amount = $amount;
|
777 |
+
$this->CardHolder = $data['cc_owner'];
|
778 |
+
$this->CardNumber = $data['cc_number'];
|
779 |
+
$this->ExpiryDate = date("my", strtotime('01-' . $data['cc_exp_month'] . '-' . $data['cc_exp_year']));
|
780 |
+
$this->CV2 = $data['cc_cid'];
|
781 |
+
$this->CardType = $this->getConfigModel()->getCcCode($data['cc_type']);
|
782 |
+
|
783 |
+
$this->setGatewayOrderData($quote);
|
784 |
+
$result = $this->register();
|
785 |
+
if ($result == 'ERROR') {
|
786 |
+
$error = $this->result;
|
787 |
+
Mage::throwException($error['Errors'][0]);
|
788 |
+
} elseif (in_array($this->result['Status'], $this->getConfigModel()->getExpectedError())) {
|
789 |
+
if (!$this->result['Errors'][0])
|
790 |
+
Mage::throwException("Gateway error : {" . (string) $this->result['StatusDetail'] . "}");
|
791 |
+
else
|
792 |
+
Mage::throwException("Gateway error : {" . (string) $this->result['Errors'][0] . "}");
|
793 |
+
}
|
794 |
+
else {
|
795 |
+
$result['CustomerEmail'] = $this->CustomerEmail;
|
796 |
+
$result['CustomerName'] = $this->BillingFirstnames . ' ' . $this->BillingSurname;
|
797 |
+
$result['CardType'] = $this->CardType;
|
798 |
+
$result['CardHolderName'] = $this->CardHolder;
|
799 |
+
$result['CustomerContact'] = $this->BillingPhone;
|
800 |
+
$result['TxType'] = $this->TxType;
|
801 |
+
$result['VendorTxCode'] = $this->VendorTxCode;
|
802 |
+
}
|
803 |
+
return $result;
|
804 |
+
}
|
805 |
+
|
806 |
+
protected function _addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType, array $transactionDetails = array(), $message = false)
|
807 |
+
{
|
808 |
+
|
|
|
809 |
$payment->setTransactionId($transactionId);
|
810 |
$payment->resetTransactionAdditionalInfo();
|
811 |
foreach ($transactionDetails as $key => $value) {
|
812 |
$payment->setData($key, $value);
|
813 |
}
|
814 |
+
|
815 |
+
$transaction = $payment->addTransaction($transactionType, null, false, $message);
|
816 |
foreach ($transactionDetails as $key => $value) {
|
817 |
$payment->unsetData($key);
|
818 |
}
|
822 |
|
823 |
return $transaction;
|
824 |
}
|
825 |
+
|
826 |
+
public function getConfigModel()
|
827 |
+
{
|
828 |
+
return Mage::getSingleton('sagepay/config');
|
829 |
+
}
|
830 |
+
|
831 |
+
public function getSagepayModel()
|
832 |
+
{
|
833 |
+
return Mage::getSingleton('sagepay/sagepay');
|
834 |
+
}
|
835 |
+
|
836 |
+
public function getTransactionModel()
|
837 |
+
{
|
838 |
+
return Mage::getSingleton('sagepay/transaction');
|
839 |
+
}
|
840 |
|
841 |
}
|
842 |
+
|
843 |
?>
|
app/code/community/Raveinfosys/Sagepay/Model/Sagepay.php
CHANGED
@@ -1,126 +1,132 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Raveinfosys_Sagepay_Model_Sagepay extends Mage_Core_Model_Abstract
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
public function _construct(){
|
6 |
-
|
7 |
parent::_construct();
|
8 |
$this->_init('sagepay/sagepay');
|
9 |
}
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
}
|
126 |
-
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
+
class Raveinfosys_Sagepay_Model_Sagepay extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
|
|
|
|
|
9 |
parent::_construct();
|
10 |
$this->_init('sagepay/sagepay');
|
11 |
}
|
12 |
|
13 |
+
public function saveOrderDetail($result, $order_id)
|
14 |
+
{
|
15 |
+
$data['order_id'] = $order_id;
|
16 |
+
$data['vps_tx_id'] = $result['VPSTxId'];
|
17 |
+
$data['vendor_tx_code'] = $result['VendorTxCode'];
|
18 |
+
$data['security_key'] = $result['SecurityKey'];
|
19 |
+
$data['tx_auth_no'] = $result['TxAuthNo'];
|
20 |
+
$data['order_status'] = $result['StatusDetail'];
|
21 |
+
$data['threed_auth'] = $result['3DSecureStatus'];
|
22 |
+
$data['payment_type'] = 1;
|
23 |
+
$data['authorised'] = 1;
|
24 |
+
$data['customer_email'] = $result['CustomerEmail'];
|
25 |
+
$model = Mage::getModel('sagepay/sagepay');
|
26 |
+
$model->setData($data)
|
27 |
+
->save();
|
28 |
+
return $model->getId();
|
29 |
+
}
|
30 |
+
|
31 |
+
public function saveCardDetail($id, $data)
|
32 |
+
{
|
33 |
+
$model = Mage::getModel('sagepay/sagepay')->load($id);
|
34 |
+
$model->setCustomerName($data['CustomerName'])
|
35 |
+
->setCardType($data['CardType'])
|
36 |
+
->setCardHolderName($data['CardHolderName'])
|
37 |
+
->setCustomerContact($data['CustomerContact'])
|
38 |
+
->save();
|
39 |
+
}
|
40 |
+
|
41 |
+
public function saveAuthDetail($result, $order_id)
|
42 |
+
{
|
43 |
+
$data['order_id'] = $order_id;
|
44 |
+
$data['vps_tx_id'] = $result['VPSTxId'];
|
45 |
+
$data['vendor_tx_code'] = $result['VendorTxCode'];
|
46 |
+
$data['security_key'] = $result['SecurityKey'];
|
47 |
+
if ($result['TxAuthNo'])
|
48 |
+
$data['tx_auth_no'] = $result['TxAuthNo'];
|
49 |
+
else
|
50 |
+
$data['tx_auth_no'] = '0';
|
51 |
+
$data['order_status'] = $result['StatusDetail'];
|
52 |
+
$data['threed_auth'] = $result['3DSecureStatus'];
|
53 |
+
$data['payment_type'] = 2;
|
54 |
+
$data['customer_email'] = $result['CustomerEmail'];
|
55 |
+
$model = Mage::getModel('sagepay/sagepay');
|
56 |
+
$model->setData($data)
|
57 |
+
->save();
|
58 |
+
return $model->getId();
|
59 |
+
}
|
60 |
+
|
61 |
+
public function saveAuthorisedDetail($result, $vendor_tx_code, $parent_data, $order_id)
|
62 |
+
{
|
63 |
+
|
64 |
+
$parent_model = Mage::getModel('sagepay/sagepay')->load($parent_data->getSagepayId());
|
65 |
+
$parent_model->setAuthorised(1)
|
66 |
+
->save()->unsetData();
|
67 |
+
|
68 |
+
$data['order_id'] = $order_id;
|
69 |
+
$data['parent_id'] = $parent_data->getSagepayId();
|
70 |
+
$data['vps_tx_id'] = $result['VPSTxId'];
|
71 |
+
$data['vendor_tx_code'] = $vendor_tx_code;
|
72 |
+
$data['security_key'] = $result['SecurityKey'];
|
73 |
+
$data['tx_auth_no'] = $result['TxAuthNo'];
|
74 |
+
$data['order_status'] = $result['StatusDetail'];
|
75 |
+
$data['threed_auth'] = $result['3DSecureStatus'];
|
76 |
+
$data['authorised'] = 1;
|
77 |
+
$data['customer_email'] = $parent_data->getCustomerEmail();
|
78 |
+
$data['customer_name'] = $parent_data->getCustomerName();
|
79 |
+
$data['card_type'] = $parent_data->getCardType();
|
80 |
+
$data['card_holder_name'] = $parent_data->getCardHolderName();
|
81 |
+
$data['customer_contact'] = $parent_data->getCustomerContact();
|
82 |
+
|
83 |
+
$model = Mage::getModel('sagepay/sagepay');
|
84 |
+
$model->setData($data)
|
85 |
+
->save();
|
86 |
+
|
87 |
+
return $model->getId();
|
88 |
+
}
|
89 |
+
|
90 |
+
public function saveRefundDetail($result, $id)
|
91 |
+
{
|
92 |
+
$model = Mage::getModel('sagepay/sagepay')->load($id);
|
93 |
+
$model->setIsRefund(1)
|
94 |
+
->setRefundStatus($result['StatusDetail'])
|
95 |
+
->save();
|
96 |
+
}
|
97 |
+
|
98 |
+
public function saveVoidDetail($result, $id)
|
99 |
+
{
|
100 |
+
$model = Mage::getModel('sagepay/sagepay')->load($id);
|
101 |
+
$model->setIsVoid(1)
|
102 |
+
->setVoidStatus($result['StatusDetail'])
|
103 |
+
->save();
|
104 |
+
}
|
105 |
+
|
106 |
+
public function canVoid($order)
|
107 |
+
{
|
108 |
+
$data = $this->getCollection()->addFieldToFilter('order_id', $order->getIncrementId())->getFirstItem();
|
109 |
+
if ($data->getPaymentType() == 2 && $data->getIsVoid() != 1 && $data->getAuthorised() != 1)
|
110 |
+
return true;
|
111 |
+
else
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
public function logTransaction($data)
|
116 |
+
{
|
117 |
+
if (Mage::getStoreConfig('payment/sagepay/debug')) {
|
118 |
+
if ($data["request"]["CardNumber"] != '') {
|
119 |
+
$data["request"]["CardNumber"] = '****';
|
120 |
+
$data["request"]["IssueNumber"] = '****';
|
121 |
+
$data["request"]["CV2"] = '****';
|
122 |
+
$data["request"]["CardType"] = '****';
|
123 |
+
$data["request"]["CardHolder"] = '****';
|
124 |
+
}
|
125 |
+
$data["request"]["Vendor"] = '****';
|
126 |
+
Mage::log($data, null, 'raveinfosys_sagepay.log', 1);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
?>
|
app/code/community/Raveinfosys/Sagepay/Model/Status.php
CHANGED
@@ -2,14 +2,16 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Status extends Varien_Object
|
4 |
{
|
5 |
-
|
6 |
-
const
|
|
|
7 |
|
8 |
static public function getOptionArray()
|
9 |
{
|
10 |
return array(
|
11 |
-
self::STATUS_ENABLED
|
12 |
-
self::STATUS_DISABLED
|
13 |
);
|
14 |
}
|
15 |
-
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_Status extends Varien_Object
|
4 |
{
|
5 |
+
|
6 |
+
const STATUS_ENABLED = 1;
|
7 |
+
const STATUS_DISABLED = 2;
|
8 |
|
9 |
static public function getOptionArray()
|
10 |
{
|
11 |
return array(
|
12 |
+
self::STATUS_ENABLED => Mage::helper('sagepay')->__('Enabled'),
|
13 |
+
self::STATUS_DISABLED => Mage::helper('sagepay')->__('Disabled')
|
14 |
);
|
15 |
}
|
16 |
+
|
17 |
+
}
|
app/code/community/Raveinfosys/Sagepay/Model/System/Config/Source/Dropdown/Values.php
CHANGED
@@ -2,7 +2,8 @@
|
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_System_Config_Source_Dropdown_Values
|
4 |
{
|
5 |
-
|
|
|
6 |
{
|
7 |
return array(
|
8 |
array(
|
@@ -13,10 +14,11 @@ class Raveinfosys_Sagepay_Model_System_Config_Source_Dropdown_Values
|
|
13 |
'value' => 'test',
|
14 |
'label' => 'Test',
|
15 |
),
|
16 |
-
|
17 |
'value' => 'live',
|
18 |
'label' => 'Live',
|
19 |
),
|
20 |
);
|
21 |
}
|
|
|
22 |
}
|
2 |
|
3 |
class Raveinfosys_Sagepay_Model_System_Config_Source_Dropdown_Values
|
4 |
{
|
5 |
+
|
6 |
+
public function toOptionArray()
|
7 |
{
|
8 |
return array(
|
9 |
array(
|
14 |
'value' => 'test',
|
15 |
'label' => 'Test',
|
16 |
),
|
17 |
+
array(
|
18 |
'value' => 'live',
|
19 |
'label' => 'Live',
|
20 |
),
|
21 |
);
|
22 |
}
|
23 |
+
|
24 |
}
|
app/code/community/Raveinfosys/Sagepay/Model/Transaction.php
CHANGED
@@ -1,34 +1,35 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Raveinfosys_Sagepay_Model_Transaction extends Mage_Core_Model_Abstract
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
public function _construct(){
|
6 |
-
|
7 |
parent::_construct();
|
8 |
$this->_init('sagepay/transaction');
|
9 |
}
|
10 |
|
11 |
-
public function saveTransactionDetail($order_id
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
?>
|
1 |
<?php
|
2 |
|
3 |
+
class Raveinfosys_Sagepay_Model_Transaction extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
|
|
|
|
|
9 |
parent::_construct();
|
10 |
$this->_init('sagepay/transaction');
|
11 |
}
|
12 |
|
13 |
+
public function saveTransactionDetail($order_id, $result, $vendor_tx_code, $mode, $sagepay_id)
|
14 |
+
{
|
15 |
+
$transaction_detail = array();
|
16 |
+
$card_detail = Mage::getModel('sagepay/sagepay')->load($sagepay_id);
|
17 |
+
$transaction_detail['order_id'] = $order_id;
|
18 |
+
$transaction_detail['vendor_tx_code'] = $vendor_tx_code;
|
19 |
+
$transaction_detail['vps_tx_id'] = $result['VPSTxId'];
|
20 |
+
$transaction_detail['security_key'] = $result['SecurityKey'];
|
21 |
+
$transaction_detail['tx_auth_no'] = $result['TxAuthNo'];
|
22 |
+
$transaction_detail['order_status'] = $result['Status'];
|
23 |
+
$transaction_detail['customer_name'] = $card_detail['customer_name'];
|
24 |
+
$transaction_detail['customer_email'] = $card_detail['customer_email'];
|
25 |
+
$transaction_detail['customer_contact'] = $card_detail['customer_contact'];
|
26 |
+
$transaction_detail['card_holder_name'] = $card_detail['card_holder_name'];
|
27 |
+
$transaction_detail['card_type'] = $card_detail['card_type'];
|
28 |
+
$transaction_detail['mode'] = $mode;
|
29 |
+
$transaction_detail['threed_secure'] = $result['3DSecureStatus'];
|
30 |
+
$this->setData($transaction_detail)->save();
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
?>
|
|
app/code/community/Raveinfosys/Sagepay/controllers/Adminhtml/SagepayController.php
CHANGED
@@ -3,42 +3,45 @@
|
|
3 |
class Raveinfosys_Sagepay_Adminhtml_SagepayController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
33 |
-
}
|
34 |
-
}
|
35 |
-
$this->_redirect('*/*/');
|
36 |
-
}
|
37 |
-
|
38 |
-
public function massDeleteAction() {
|
39 |
$sagepayIds = $this->getRequest()->getParam('sagepay');
|
40 |
-
if(!is_array($sagepayIds)) {
|
41 |
-
|
42 |
} else {
|
43 |
try {
|
44 |
foreach ($sagepayIds as $sagepayId) {
|
@@ -46,9 +49,9 @@ class Raveinfosys_Sagepay_Adminhtml_SagepayController extends Mage_Adminhtml_Con
|
|
46 |
$sagepay->delete();
|
47 |
}
|
48 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
);
|
53 |
} catch (Exception $e) {
|
54 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
@@ -57,32 +60,31 @@ class Raveinfosys_Sagepay_Adminhtml_SagepayController extends Mage_Adminhtml_Con
|
|
57 |
$this->_redirect('*/*/index');
|
58 |
}
|
59 |
|
60 |
-
|
61 |
public function exportCsvAction()
|
62 |
{
|
63 |
-
$fileName
|
64 |
-
$content
|
65 |
-
|
66 |
|
67 |
$this->_sendUploadResponse($fileName, $content);
|
68 |
}
|
69 |
|
70 |
public function exportXmlAction()
|
71 |
{
|
72 |
-
$fileName
|
73 |
-
$content
|
74 |
-
|
75 |
|
76 |
$this->_sendUploadResponse($fileName, $content);
|
77 |
}
|
78 |
|
79 |
-
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
80 |
{
|
81 |
$response = $this->getResponse();
|
82 |
-
$response->setHeader('HTTP/1.1 200 OK','');
|
83 |
$response->setHeader('Pragma', 'public', true);
|
84 |
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
85 |
-
$response->setHeader('Content-Disposition', 'attachment; filename='
|
86 |
$response->setHeader('Last-Modified', date('r'));
|
87 |
$response->setHeader('Accept-Ranges', 'bytes');
|
88 |
$response->setHeader('Content-Length', strlen($content));
|
@@ -91,4 +93,5 @@ class Raveinfosys_Sagepay_Adminhtml_SagepayController extends Mage_Adminhtml_Con
|
|
91 |
$response->sendResponse();
|
92 |
die;
|
93 |
}
|
94 |
-
|
|
3 |
class Raveinfosys_Sagepay_Adminhtml_SagepayController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('sagepay/items')
|
10 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
11 |
+
|
12 |
+
return $this;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
$this->_initAction()
|
18 |
+
->renderLayout();
|
19 |
+
}
|
20 |
+
|
21 |
+
public function deleteAction()
|
22 |
+
{
|
23 |
+
if ($this->getRequest()->getParam('id') > 0) {
|
24 |
+
try {
|
25 |
+
$model = Mage::getModel('sagepay/sagepay');
|
26 |
|
27 |
+
$model->setId($this->getRequest()->getParam('id'))
|
28 |
+
->delete();
|
29 |
|
30 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
31 |
+
$this->_redirect('*/*/');
|
32 |
+
} catch (Exception $e) {
|
33 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
34 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
35 |
+
}
|
36 |
+
}
|
37 |
+
$this->_redirect('*/*/');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function massDeleteAction()
|
41 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
$sagepayIds = $this->getRequest()->getParam('sagepay');
|
43 |
+
if (!is_array($sagepayIds)) {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
45 |
} else {
|
46 |
try {
|
47 |
foreach ($sagepayIds as $sagepayId) {
|
49 |
$sagepay->delete();
|
50 |
}
|
51 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
52 |
+
Mage::helper('adminhtml')->__(
|
53 |
+
'Total of %d record(s) were successfully deleted', count($sagepayIds)
|
54 |
+
)
|
55 |
);
|
56 |
} catch (Exception $e) {
|
57 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
60 |
$this->_redirect('*/*/index');
|
61 |
}
|
62 |
|
|
|
63 |
public function exportCsvAction()
|
64 |
{
|
65 |
+
$fileName = 'sagepay.csv';
|
66 |
+
$content = $this->getLayout()->createBlock('sagepay/adminhtml_sagepay_grid')
|
67 |
+
->getCsv();
|
68 |
|
69 |
$this->_sendUploadResponse($fileName, $content);
|
70 |
}
|
71 |
|
72 |
public function exportXmlAction()
|
73 |
{
|
74 |
+
$fileName = 'sagepay.xml';
|
75 |
+
$content = $this->getLayout()->createBlock('sagepay/adminhtml_sagepay_grid')
|
76 |
+
->getXml();
|
77 |
|
78 |
$this->_sendUploadResponse($fileName, $content);
|
79 |
}
|
80 |
|
81 |
+
protected function _sendUploadResponse($fileName, $content, $contentType = 'application/octet-stream')
|
82 |
{
|
83 |
$response = $this->getResponse();
|
84 |
+
$response->setHeader('HTTP/1.1 200 OK', '');
|
85 |
$response->setHeader('Pragma', 'public', true);
|
86 |
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
87 |
+
$response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
|
88 |
$response->setHeader('Last-Modified', date('r'));
|
89 |
$response->setHeader('Accept-Ranges', 'bytes');
|
90 |
$response->setHeader('Content-Length', strlen($content));
|
93 |
$response->sendResponse();
|
94 |
die;
|
95 |
}
|
96 |
+
|
97 |
+
}
|
app/code/community/Raveinfosys/Sagepay/controllers/Checkout/OnepageController.php
CHANGED
@@ -1,10 +1,13 @@
|
|
1 |
<?php
|
|
|
2 |
require_once 'Mage/Checkout/controllers/OnepageController.php';
|
|
|
3 |
class Raveinfosys_Sagepay_Checkout_OnepageController extends Mage_Checkout_OnepageController
|
4 |
{
|
5 |
-
|
6 |
-
public function threedsecureAction()
|
7 |
-
|
|
|
8 |
return;
|
9 |
}
|
10 |
|
@@ -20,88 +23,83 @@ class Raveinfosys_Sagepay_Checkout_OnepageController extends Mage_Checkout_Onepa
|
|
20 |
return;
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
$this->getOnepage()->getQuote()->getPayment()->importData($data);
|
25 |
}
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$this->_forward('saveOrder');
|
47 |
-
}
|
48 |
-
|
49 |
} catch (Exception $e) {
|
50 |
Mage::logException($e);
|
51 |
-
|
52 |
$result['error'] = true;
|
53 |
$result['error_messages'] = $e->getMessage();
|
54 |
}
|
55 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
56 |
}
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
78 |
Mage::logException($e);
|
79 |
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
80 |
-
$result['success']
|
81 |
-
$result['error']
|
82 |
$result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
|
83 |
}
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
$this->getOnepage()->getQuote()->getPayment()->importData($data);
|
94 |
}
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
Mage::logException($e);
|
99 |
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
100 |
-
|
101 |
}
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
}
|
1 |
<?php
|
2 |
+
|
3 |
require_once 'Mage/Checkout/controllers/OnepageController.php';
|
4 |
+
|
5 |
class Raveinfosys_Sagepay_Checkout_OnepageController extends Mage_Checkout_OnepageController
|
6 |
{
|
7 |
+
|
8 |
+
public function threedsecureAction()
|
9 |
+
{
|
10 |
+
if ($this->_expireAjax()) {
|
11 |
return;
|
12 |
}
|
13 |
|
23 |
return;
|
24 |
}
|
25 |
}
|
26 |
+
if ($data = $this->getRequest()->getPost('payment', false)) {
|
27 |
$this->getOnepage()->getQuote()->getPayment()->importData($data);
|
28 |
}
|
29 |
+
$gateway_result = Mage::getModel('sagepay/payment')->registerTransaction($data);
|
30 |
+
$session = Mage::getSingleton('core/session');
|
31 |
+
$session->setGatewayResult($gateway_result)->setPaymentdata($data);
|
32 |
+
if ($gateway_result['Status'] == '3DAUTH' && $gateway_result["PAReq"] != '' && $gateway_result["MD"] != '') {
|
33 |
+
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
|
34 |
+
$url = Mage::getUrl('checkout/onepage/sagepay3dCheck');
|
35 |
+
Mage::register('url', $url);
|
36 |
+
|
37 |
+
if (!isset($result['error'])) {
|
38 |
+
$result['goto_section'] = 'threedsecure';
|
39 |
+
$html = Mage::app()->getLayout()->createBlock('checkout/onepage')->setTemplate('sagepay/checkout/3dredirect.phtml')->toHtml();
|
40 |
+
$result['update_section'] = array(
|
41 |
+
'name' => 'threedsecure',
|
42 |
+
'html' => $html
|
43 |
+
#'html' => "<script>alert('hello');window.open('".$url."','mypopup','status=1,width=500,height=500,scrollbars=1');</script>"
|
44 |
+
);
|
45 |
+
}
|
46 |
+
} elseif (in_array($gateway_result['Status'], Mage::getSingleton('sagepay/config')->getExpectedSuccess())) {
|
47 |
+
$this->_forward('saveOrder');
|
48 |
+
}
|
|
|
|
|
|
|
49 |
} catch (Exception $e) {
|
50 |
Mage::logException($e);
|
51 |
+
$result['success'] = false;
|
52 |
$result['error'] = true;
|
53 |
$result['error_messages'] = $e->getMessage();
|
54 |
}
|
55 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
56 |
}
|
57 |
+
|
58 |
+
public function sagepay3dcheckAction()
|
59 |
+
{
|
60 |
+
|
61 |
+
$this->loadLayout();
|
62 |
+
$block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'sagepay_3d_form', array('template' => 'sagepay/sagepay.phtml'));
|
63 |
+
$this->getLayout()->getBlock('content')->append($block);
|
64 |
+
$this->renderLayout();
|
65 |
+
}
|
66 |
+
|
67 |
+
public function threedsuccessAction()
|
68 |
+
{
|
69 |
+
$this->loadLayout();
|
70 |
+
try {
|
71 |
+
$result = Mage::getModel('sagepay/payment')->complete3d($_POST);
|
72 |
+
if (in_array($result['Status'], Mage::getSingleton('sagepay/config')->getExpectedSuccess())) {
|
73 |
+
$session = Mage::getSingleton('core/session');
|
74 |
+
$session->setGatewayResult($result);
|
75 |
+
Mage::register('status', 1);
|
76 |
+
Mage::register('url', Mage::getUrl('checkout/onepage/savesagepayorder'));
|
77 |
+
}
|
78 |
+
} catch (Exception $e) {
|
79 |
Mage::logException($e);
|
80 |
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
81 |
+
$result['success'] = false;
|
82 |
+
$result['error'] = true;
|
83 |
$result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
|
84 |
}
|
85 |
+
|
86 |
+
$this->renderLayout();
|
87 |
+
}
|
88 |
+
|
89 |
+
public function saveSagePayOrderAction()
|
90 |
+
{
|
91 |
+
try {
|
92 |
+
$session = Mage::getSingleton('core/session');
|
93 |
+
if ($data = $session->getPaymentdata()) {
|
94 |
$this->getOnepage()->getQuote()->getPayment()->importData($data);
|
95 |
}
|
96 |
+
$this->getOnepage()->saveOrder();
|
97 |
+
$this->getOnepage()->getQuote()->save();
|
98 |
+
} catch (Exception $e) {
|
99 |
Mage::logException($e);
|
100 |
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
|
|
|
101 |
}
|
102 |
+
$this->_redirect('checkout/onepage/success');
|
103 |
+
}
|
104 |
+
|
|
|
|
|
105 |
}
|
app/code/community/Raveinfosys/Sagepay/sql/sagepay_setup/mysql4-install-0.1.0.php
CHANGED
@@ -6,11 +6,11 @@ $installer->startSetup();
|
|
6 |
|
7 |
$installer->run("
|
8 |
|
9 |
-
-- DROP TABLE IF EXISTS {$this->getTable('sagepay')};
|
10 |
CREATE TABLE {$this->getTable('sagepay')} (
|
11 |
-
`sagepay_id` int(11) NOT NULL auto_increment,
|
12 |
-
`parent_id` int(11),
|
13 |
-
`order_id` int(11) NOT NULL default 0,
|
14 |
`vps_tx_id` varchar(200) NOT NULL default '',
|
15 |
`vendor_tx_code` varchar(200) NOT NULL default '',
|
16 |
`security_key` varchar(200) NOT NULL default '',
|
@@ -32,11 +32,11 @@ $installer->run("
|
|
32 |
PRIMARY KEY (`sagepay_id`)
|
33 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
34 |
|
35 |
-
-- DROP TABLE IF EXISTS {$this->getTable('sagepay_transaction_detail')};
|
36 |
CREATE TABLE {$this->getTable('sagepay_transaction_detail')} (
|
37 |
-
`transaction_id` int(11) NOT NULL auto_increment,
|
38 |
-
`sagepay_id` int(11) NOT NULL default 0,
|
39 |
-
`order_id` int(11) NOT NULL default 0,
|
40 |
`vps_tx_id` varchar(200) NOT NULL default '',
|
41 |
`vendor_tx_code` varchar(200) NOT NULL default '',
|
42 |
`security_key` varchar(200) NOT NULL default '',
|
@@ -51,4 +51,4 @@ CREATE TABLE {$this->getTable('sagepay_transaction_detail')} (
|
|
51 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
52 |
");
|
53 |
|
54 |
-
$installer->endSetup();
|
6 |
|
7 |
$installer->run("
|
8 |
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('sagepay')};
|
10 |
CREATE TABLE {$this->getTable('sagepay')} (
|
11 |
+
`sagepay_id` int(11) NOT NULL auto_increment,
|
12 |
+
`parent_id` int(11),
|
13 |
+
`order_id` int(11) NOT NULL default 0,
|
14 |
`vps_tx_id` varchar(200) NOT NULL default '',
|
15 |
`vendor_tx_code` varchar(200) NOT NULL default '',
|
16 |
`security_key` varchar(200) NOT NULL default '',
|
32 |
PRIMARY KEY (`sagepay_id`)
|
33 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
34 |
|
35 |
+
-- DROP TABLE IF EXISTS {$this->getTable('sagepay_transaction_detail')};
|
36 |
CREATE TABLE {$this->getTable('sagepay_transaction_detail')} (
|
37 |
+
`transaction_id` int(11) NOT NULL auto_increment,
|
38 |
+
`sagepay_id` int(11) NOT NULL default 0,
|
39 |
+
`order_id` int(11) NOT NULL default 0,
|
40 |
`vps_tx_id` varchar(200) NOT NULL default '',
|
41 |
`vendor_tx_code` varchar(200) NOT NULL default '',
|
42 |
`security_key` varchar(200) NOT NULL default '',
|
51 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
52 |
");
|
53 |
|
54 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/sagepay.xml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
</default>
|
5 |
<sagepay_index_index>
|
6 |
<reference name="content">
|
7 |
-
<block type="
|
8 |
</reference>
|
9 |
</sagepay_index_index>
|
10 |
|
@@ -13,7 +13,7 @@
|
|
13 |
<remove name="top.menu"/>
|
14 |
<remove name="top.search"/>
|
15 |
<reference name="content">
|
16 |
-
<block type="
|
17 |
</reference>
|
18 |
|
19 |
</checkout_onepage_sagepay3dcheck>
|
@@ -23,7 +23,7 @@
|
|
23 |
<remove name="top.menu"/>
|
24 |
<remove name="top.search"/>
|
25 |
<reference name="content">
|
26 |
-
<block type="
|
27 |
</reference>
|
28 |
|
29 |
</checkout_onepage_threedsuccess>
|
4 |
</default>
|
5 |
<sagepay_index_index>
|
6 |
<reference name="content">
|
7 |
+
<block type="core/template" name="sagepay" template="core/template.phtml" />
|
8 |
</reference>
|
9 |
</sagepay_index_index>
|
10 |
|
13 |
<remove name="top.menu"/>
|
14 |
<remove name="top.search"/>
|
15 |
<reference name="content">
|
16 |
+
<block type="core/template" name="sagepay_3d_form" template="core/template.phtml" />
|
17 |
</reference>
|
18 |
|
19 |
</checkout_onepage_sagepay3dcheck>
|
23 |
<remove name="top.menu"/>
|
24 |
<remove name="top.search"/>
|
25 |
<reference name="content">
|
26 |
+
<block type="core/template" name="sagepay_success" template="sagepay/threedsuccess.phtml" />
|
27 |
</reference>
|
28 |
|
29 |
</checkout_onepage_threedsuccess>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Raveinfosys_Sagepay</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Sagepay Payment Gateway Extension.</summary>
|
10 |
<description>Sagepay Payment Gateway Extension.</description>
|
11 |
-
<notes>
|
12 |
-
<authors><author><name>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Raveinfosys"><dir name="Sagepay"><dir name="Block"><dir name="Adminhtml"><dir name="Sagepay"><file name="Grid.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Raveinfosys_Sagepay</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Sagepay Payment Gateway Extension.</summary>
|
10 |
<description>Sagepay Payment Gateway Extension.</description>
|
11 |
+
<notes>This version is properly tested on the following Magento CE versions: 1.5, 1.6, 1.7,1.8,1.9.* . In this particular version we are supporting it to run on PHP V 5.5.X.</notes>
|
12 |
+
<authors><author><name>Rave Infosys</name><user>raveinfo</user><email>magento@raveinfosys.com</email></author></authors>
|
13 |
+
<date>2016-04-07</date>
|
14 |
+
<time>07:15:16</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Raveinfosys"><dir name="Sagepay"><dir name="Block"><dir name="Adminhtml"><dir name="Sagepay"><file name="Grid.php" hash="93cff5cf5c26db14bfc73f70b503d06d"/></dir><file name="Sagepay.php" hash="cd412c35093f881bb5b7cb84d5b697c5"/></dir></dir><dir name="Controller"><file name="Observer.php" hash="fb82d968fae6832d00b669d87d964e0a"/></dir><dir name="Helper"><file name="Data.php" hash="dcd5bdb84912401eef98006697b54a79"/></dir><dir name="Model"><file name="Config.php" hash="4b7b84de4c699a552131b2a8f145d897"/><dir name="Mysql4"><dir name="Sagepay"><file name="Collection.php" hash="861db6e6babf9b900f9c2be422c7e909"/></dir><file name="Sagepay.php" hash="b880c55bd894aeb26a9ad55842eb1e1e"/><dir name="Transaction"><file name="Collection.php" hash="dca1e40bbb6cee2f382f0fac398d32f6"/></dir><file name="Transaction.php" hash="e9b51b73460fca7ac31bfe78dc8defc1"/></dir><file name="Observer.php" hash="b0a26778751bbec6cd7608db6688ed49"/><file name="Payment.php" hash="4baf597cb1e0e751c0c61c73102a932e"/><file name="Sagepay.php" hash="5abb123e24acf07cdea8a8f7c2ee4375"/><file name="Status.php" hash="fd320d12ba0c856b7676df8f651dfb7a"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Values.php" hash="8183b136e4a2e5377f2b706ff5ed0d34"/></dir></dir></dir></dir><file name="Transaction.php" hash="f89c934b5d390aee8c30cc8d344e999b"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SagepayController.php" hash="ba648e6cda846489a6b04364a1f4fec5"/></dir><dir name="Checkout"><file name="OnepageController.php" hash="033fa47705a876fb86315e5aa96a5cb3"/></dir></dir><dir name="etc"><file name="config.xml" hash="a3c468c7232e42e7c41075ba98a887cb"/><file name="system.xml" hash="4f6cb32581acbf3d8741e2b15a6afe54"/></dir><dir name="sql"><dir name="sagepay_setup"><file name="mysql4-install-0.1.0.php" hash="d0453d69d13ea649d2d9946b32de1b6d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Raveinfosys_Sagepay.xml" hash="ef02fac665847458f4c4a3980dd1aed0"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sagepay.xml" hash="befac7554e8892b1e06d5b1d68fae32e"/></dir></dir><dir name="sagepay"><dir name="template"><dir name="sales"><dir name="order"><dir name="view"><dir name="items"><dir name="renderer"><file name="default.phtml" hash="4b6e5e56132537b4eb690ebd189d70ba"/></dir></dir><file name="items.phtml" hash="5e392e35a8c3c123be3a15c49f63c3b8"/><dir name="tab"><file name="info.phtml" hash="2a503acd3054293d7259440435d40eaf"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sagepay.xml" hash="4353400c1d20ebc2e89e0318582db039"/></dir><dir name="template"><dir name="sagepay"><dir name="checkout"><file name="3dredirect.phtml" hash="bc7dbec38d65fb797d41d09e814338ab"/><dir name="review"><file name="info.phtml" hash="daa7b988f6e41cc2ddf3d7343acd86f6"/></dir></dir><file name="sagepay.phtml" hash="a58ed0d6297e62b457035fb51c7a4955"/><file name="threedsuccess.phtml" hash="83347f1b11211582fe8daa5fcd3dd5df"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>5.6.20</max></php></required></dependencies>
|
18 |
</package>
|