MTS_FoxTransfers - Version 1.0.0.1

Version Notes

First version stable.

Download this release

Release Info

Developer MTS
Extension MTS_FoxTransfers
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/local/MTS/Foxtransfers/Block/Pay/Form.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MTS_Foxtransfers_Block_Pay_Form extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->setTemplate('foxtransfers/form.phtml');
8
+
9
+ parent::_construct();
10
+ }
11
+ }
12
+
13
+ ?>
app/code/local/MTS/Foxtransfers/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mts_Foxtransfers_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ }
6
+
7
+ ?>
app/code/local/MTS/Foxtransfers/Model/Actions.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MTS_Foxtransfers_Model_Actions
4
+ {
5
+
6
+ /**
7
+ * Options getter
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ return array(
14
+ array('value'=>'https://www.foxtransfers.lt/transaction/choosebank', 'label'=>Mage::helper('foxtransfers')->__('Real mode')),
15
+ array('value'=>'https://www.foxtransfers.lt/transaction/test/report-payment-success', 'label'=>Mage::helper('foxtransfers')->__('Test mode: report status payment successful')),
16
+ array('value'=>'https://www.foxtransfers.lt/transaction/test/report-payment-canceled', 'label'=>Mage::helper('foxtransfers')->__('Test mode: report status payment canceled')),
17
+ array('value'=>'https://www.foxtransfers.lt/transaction/test/customer-return-payment-success', 'label'=>Mage::helper('foxtransfers')->__('Test mode: customer return payment successful')),
18
+ array('value'=>'https://www.foxtransfers.lt/transaction/test/customer-return-payment-canceled', 'label'=>Mage::helper('foxtransfers')->__('Test mode: customer return payment canceled')),
19
+ array('value'=>'https://www.foxtransfers.lt/transaction/test/sandbox', 'label'=>Mage::helper('foxtransfers')->__('Test mode: sandbox without registration and with common keys')),
20
+ );
21
+ }
22
+
23
+ }
24
+
25
+ ?>
app/code/local/MTS/Foxtransfers/Model/Foxtransferskey.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MTS_Foxtransfers_Model_Foxtransferskey extends Mage_Core_Model_Config_Data
4
+ {
5
+
6
+ public function save()
7
+ {
8
+
9
+ if ( isset($_FILES['groups']['tmp_name']['foxtransfers']['fields']['foxtransferskey']) and (file_exists($_FILES['groups']['tmp_name']['foxtransfers']['fields']['foxtransferskey']['value'])) ) {
10
+
11
+ $key_content = file_get_contents($_FILES['groups']['tmp_name']['foxtransfers']['fields']['foxtransferskey']['value']);
12
+
13
+ $cfg = new Mage_Core_Model_Config();
14
+
15
+ $cfg->saveConfig('payment/foxtransfers/foxtransferskeycontent', $key_content);
16
+
17
+ return parent::save();
18
+
19
+ }
20
+
21
+ else
22
+
23
+ {
24
+
25
+ if (isset($_POST['groups']['foxtransfers']['fields']['foxtransferskey']['value']['delete']) AND $_POST['groups']['foxtransfers']['fields']['foxtransferskey']['value']['delete'] == 1)
26
+ {
27
+
28
+ $cfg = new Mage_Core_Model_Config();
29
+
30
+ $cfg->saveConfig('payment/foxtransfers/foxtransferskeycontent', null);
31
+ $cfg->saveConfig('payment/foxtransfers/foxtransferskey', null);
32
+
33
+ return;
34
+
35
+ }
36
+
37
+ }
38
+
39
+ }
40
+
41
+ }
42
+
43
+ ?>
app/code/local/MTS/Foxtransfers/Model/Foxtransferslogo.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MTS_Foxtransfers_Model_Foxtransferslogo extends Mage_Core_Model_Config_Data
4
+ {
5
+
6
+ public function save()
7
+ {
8
+
9
+ if ( isset($_FILES['groups']['tmp_name']['foxtransfers']['fields']['logo']) and (file_exists($_FILES['groups']['tmp_name']['foxtransfers']['fields']['logo']['value'])) ) {
10
+
11
+ $path = Mage::getBaseDir('media') . DS . 'foxtransfers/';
12
+
13
+ if(!is_dir($path)){
14
+ mkdir($path, 0777, true);
15
+ }
16
+
17
+ $file_path = $path . $_FILES['groups']['name']['foxtransfers']['fields']['logo']['value'];
18
+
19
+ move_uploaded_file($_FILES['groups']['tmp_name']['foxtransfers']['fields']['logo']['value'], $file_path);
20
+
21
+ $cfg = new Mage_Core_Model_Config();
22
+ $cfg->saveConfig('payment/foxtransfers/logo', 'foxtransfers/' . $_FILES['groups']['name']['foxtransfers']['fields']['logo']['value']);
23
+
24
+ return;
25
+
26
+ }
27
+
28
+ else
29
+
30
+ {
31
+
32
+ if (isset($_POST['groups']['foxtransfers']['fields']['logo']['value']['delete']) AND $_POST['groups']['foxtransfers']['fields']['logo']['value']['delete'] == 1)
33
+ {
34
+
35
+ $path = Mage::getBaseDir('media') . DS;
36
+
37
+ $cfg = new Mage_Core_Model_Config();
38
+ $filename = Mage::getStoreConfig('payment/foxtransfers/logo');
39
+
40
+ unlink($path . $filename);
41
+
42
+ $cfg->saveConfig('payment/foxtransfers/logo', null);
43
+
44
+ return;
45
+
46
+ }
47
+
48
+ }
49
+
50
+ }
51
+
52
+ }
53
+
54
+ ?>
app/code/local/MTS/Foxtransfers/Model/PaymentMethod.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MTS_Foxtransfers_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
3
+ {
4
+
5
+ protected $_code = 'foxtransfers';
6
+
7
+ protected $_formBlockType = 'foxtransfers/pay_form';
8
+
9
+ //protected $_canAuthorize=true;
10
+
11
+ public function assignData($data)
12
+ {
13
+ $details = array();
14
+ if ($this->getPayableTo()) {
15
+ $details['payable_to'] = $this->getPayableTo();
16
+ }
17
+
18
+ if ($this->getMailingAddress()) {
19
+ $details['mailing_address'] = $this->getMailingAddress();
20
+ }
21
+
22
+ if (!empty($details)) {
23
+ $this->getInfoInstance()->setAdditionalData(serialize($details));
24
+ }
25
+
26
+ return $this;
27
+
28
+ }
29
+
30
+ public function getPayableTo(){
31
+ return $this->getConfigData('payable_to');
32
+ }
33
+
34
+ public function getMailingAddress(){
35
+ return $this->getConfigData('mailing_address');
36
+ }
37
+
38
+ public function getOrderPlaceRedirectUrl()
39
+ {
40
+ return Mage::getUrl('foxtransfers/pay/redirect');
41
+ }
42
+
43
+ }
app/code/local/MTS/Foxtransfers/Model/Privatekey.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MTS_Foxtransfers_Model_Privatekey extends Mage_Core_Model_Config_Data
4
+ {
5
+
6
+ public function save()
7
+ {
8
+
9
+ if ( isset($_FILES['groups']['tmp_name']['foxtransfers']['fields']['privatekey']) and (file_exists($_FILES['groups']['tmp_name']['foxtransfers']['fields']['privatekey']['value'])) ) {
10
+
11
+ $key_content = file_get_contents($_FILES['groups']['tmp_name']['foxtransfers']['fields']['privatekey']['value']);
12
+
13
+ $cfg = new Mage_Core_Model_Config();
14
+
15
+ $cfg->saveConfig('payment/foxtransfers/privatekeycontent', $key_content);
16
+
17
+ return parent::save();
18
+
19
+ }
20
+
21
+ else
22
+
23
+ {
24
+
25
+ if (isset($_POST['groups']['foxtransfers']['fields']['privatekey']['value']['delete']) AND $_POST['groups']['foxtransfers']['fields']['privatekey']['value']['delete'] == 1)
26
+ {
27
+
28
+ $cfg = new Mage_Core_Model_Config();
29
+
30
+ $cfg->saveConfig('payment/foxtransfers/privatekeycontent', null);
31
+ $cfg->saveConfig('payment/foxtransfers/privatekey', null);
32
+
33
+ return;
34
+
35
+ }
36
+
37
+ }
38
+
39
+ }
40
+
41
+ }
42
+
43
+ ?>
app/code/local/MTS/Foxtransfers/Model/foxtransfers.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php
app/code/local/MTS/Foxtransfers/controllers/PayController.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MTS_Foxtransfers_PayController extends Mage_Core_Controller_Front_Action{
3
+
4
+ public function getCheckout()
5
+ {
6
+ return Mage::getSingleton('checkout/session');
7
+ }
8
+
9
+ public function getQuote()
10
+ {
11
+ return $this->getCheckout()->getQuote();
12
+ }
13
+
14
+
15
+ public function redirectAction()
16
+ {
17
+
18
+ $FoxUser = Mage::getStoreConfig('payment/foxtransfers/username');
19
+ $action = Mage::getStoreConfig('payment/foxtransfers/action');
20
+ $private_key = Mage::getStoreConfig('payment/foxtransfers/privatekeycontent');
21
+ $send_email = Mage::getStoreConfig('payment/foxtransfers/sendemail');
22
+
23
+ include_once(Mage::getBaseDir() . '/app/code/local/MTS/Foxtransfers/lib/FoxTransfersShop.class.php');
24
+
25
+ $a = $this->getQuote()->getShippingAddress();
26
+ $b = $this->getQuote()->getBillingAddress();
27
+
28
+ $cc = $this->getQuote()->getBaseCurrencyCode();
29
+ $cost = $a->getBaseSubtotal() - $a->getBaseDiscountAmount();
30
+ $shipping = $a->getBaseShippingAmount();
31
+
32
+ $_shippingTax = $this->getQuote()->getShippingAddress()->getBaseTaxAmount();
33
+ $_billingTax = $this->getQuote()->getBillingAddress()->getBaseTaxAmount();
34
+
35
+ $tax = sprintf('%.2f', $_shippingTax + $_billingTax);
36
+ $cost = sprintf('%.2f', $cost + $tax);
37
+ if (!isset($_SESSION['checkout']['last_real_order_id'])) $_SESSION['checkout']['last_real_order_id'] = 0;
38
+
39
+ $session = Mage::getSingleton('checkout/session');
40
+ $session->setPayQuoteId($session->getQuoteId());
41
+ $session->unsQuoteId();
42
+
43
+ $order = Mage::getModel('sales/order');
44
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
45
+
46
+
47
+ if($order->getId())
48
+ {
49
+
50
+ $total = $order->getBaseTotalDue();
51
+ $order_id = $order->getRealOrderId();
52
+
53
+ $FoxShop = new FoxTransfersShop($private_key);
54
+
55
+ $FoxShopReq = array(
56
+ 'partner' => $FoxUser,
57
+ 'amount' => $total,
58
+ 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(),
59
+ 'transaction' => $order_id,
60
+ 'lang' => Mage::app()->getLocale()->getLocaleCode(),
61
+ );
62
+ if ($send_email) {
63
+ $FoxShopReq['snd_email'] = $order->getCustomerEmail();
64
+ }
65
+
66
+
67
+ //Mage::log('FoxTransfers: '.$arr['partner'].'|'.$arr['amount'].'|'.$arr['currency'].'|'.$arr['transaction']);
68
+
69
+ $FoxShopReqWithSign = $FoxShop->generateForm($FoxShopReq);
70
+
71
+ $form = '<form id="foxtransfers-form" action="' . $action . '" method="post">';
72
+ $form .= $FoxShopReqWithSign;
73
+ //$form .= '</form>';
74
+ $form .= '</form><script> onload = function () { document.getElementById("foxtransfers-form").submit(); } </script>';
75
+
76
+ echo $form;
77
+
78
+ }
79
+
80
+ else
81
+ {
82
+ $this->_redirect('checkout/onepage/failure');
83
+ }
84
+
85
+ return;
86
+
87
+ }
88
+
89
+ public function successAction(){
90
+
91
+ $foxtransfers_key = Mage::getStoreConfig('payment/foxtransfers/foxtransferskeycontent');
92
+ include_once(Mage::getBaseDir() . '/app/code/local/MTS/Foxtransfers/lib/FoxTransfersShop.class.php');
93
+
94
+ $post = $this->getRequest()->getPost();
95
+
96
+ // Because at the moment, when customer returns from bank, there is no garantee, that payment was successful
97
+ // - we do not change order status
98
+ // - we do this when real report comes in report action
99
+
100
+ // Just send customer email
101
+
102
+ $order_id = $post['transaction'];
103
+ $order = Mage::getModel('sales/order');
104
+ $order -> loadByIncrementId($order_id);
105
+ $order -> sendNewOrderEmail();
106
+
107
+ $session = $this->getCheckout();
108
+ $session -> setQuoteId($session -> getPayQuoteId(true));
109
+ $session -> getQuote() -> setIsActive(false) -> save();
110
+ $this -> _redirect('checkout/onepage/success', array('_secure' => true));
111
+
112
+ return;
113
+
114
+ // To change the order status
115
+
116
+ /*
117
+ $FoxShop = new FoxTransfersShop($foxtransfers_key);
118
+ if ($FoxShop->validateDataSuccess($post)){
119
+ $order_id=$post['transaction'];
120
+ $order = Mage::getModel('sales/order');
121
+ $order->loadByIncrementId($order_id)->setStatus('processing')->save();
122
+ $order->sendNewOrderEmail();
123
+ Mage::getSingleton('checkout/session')->unsQuoteId();
124
+ $this->_redirect('checkout/onepage/success');
125
+ }
126
+ else {
127
+ Mage::getSingleton('checkout/session')->unsQuoteId();
128
+ $this->_redirect('checkout/onepage/failure');
129
+ }
130
+ */
131
+
132
+ }
133
+
134
+ public function cancelAction(){
135
+
136
+ $foxtransfers_key = Mage::getStoreConfig('payment/foxtransfers/foxtransferskeycontent');
137
+ include_once(Mage::getBaseDir() . '/app/code/local/MTS/Foxtransfers/lib/FoxTransfersShop.class.php');
138
+
139
+ $post = $this->getRequest()->getPost();
140
+
141
+ $FoxShop = new FoxTransfersShop($foxtransfers_key);
142
+
143
+ if ($FoxShop->validateDataSuccess($post)==0){
144
+ $order_id = $post['transaction'];
145
+ $order = Mage::getModel('sales/order');
146
+ $order->loadByIncrementId($order_id)->cancel()->save();
147
+ Mage::getSingleton('checkout/session')->unsQuoteId();
148
+
149
+ }
150
+
151
+ $session = Mage::getSingleton('checkout/session');
152
+ $session->setQuoteId($session->getPayQuoteId(true));
153
+
154
+ $this->_redirect('checkout/cart');
155
+ //$this->_redirect('checkout/onepage/failure');
156
+
157
+ }
158
+
159
+ public function reportAction()
160
+ {
161
+
162
+ $foxtransfers_key = Mage::getStoreConfig('payment/foxtransfers/foxtransferskeycontent');
163
+ include_once(Mage::getBaseDir() . '/app/code/local/MTS/Foxtransfers/lib/FoxTransfersShop.class.php');
164
+
165
+ $post = $this->getRequest()->getPost();
166
+
167
+ $FoxShop = new FoxTransfersShop($foxtransfers_key);
168
+
169
+ if ($FoxShop->validateData($post)) {
170
+
171
+ $order_id = $post['transaction'];
172
+ $order = Mage::getModel('sales/order');
173
+ if ($post['status']){
174
+ $order->loadByIncrementId($order_id)->setStatus('processing')->save();
175
+ $order->sendNewOrderEmail();
176
+ echo 'OK';
177
+ exit;
178
+ }
179
+ else {
180
+ $order->loadByIncrementId($order_id)->cancel()->save();
181
+ echo 'OK';
182
+ exit;
183
+ }
184
+
185
+ }else {
186
+
187
+ echo 'NOT OK';
188
+ exit;
189
+
190
+ }
191
+
192
+ }
193
+
194
+ }
app/code/local/MTS/Foxtransfers/etc/config.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+
4
+ <modules>
5
+ <MTS_Foxtransfers>
6
+ <version>1.0.0</version>
7
+ </MTS_Foxtransfers>
8
+ </modules>
9
+
10
+ <global>
11
+
12
+ <blocks>
13
+ <foxtransfers>
14
+ <class>MTS_Foxtransfers_Block</class>
15
+ </foxtransfers>
16
+ </blocks>
17
+
18
+ <models>
19
+ <foxtransfers>
20
+ <class>MTS_Foxtransfers_Model</class>
21
+ </foxtransfers>
22
+ </models>
23
+
24
+ <helpers>
25
+ <foxtransfers>
26
+ <class>MTS_Foxtransfers_Helper</class>
27
+ </foxtransfers>
28
+ </helpers>
29
+
30
+ <resources>
31
+
32
+ <foxtransfers_setup>
33
+ <setup>
34
+ <module>MTS_Foxtransfers</module>
35
+ </setup>
36
+ <connection>
37
+ <use>core_setup</use>
38
+ </connection>
39
+ </foxtransfers_setup>
40
+
41
+ <foxtransfers_write>
42
+ <connection>
43
+ <use>core_write</use>
44
+ </connection>
45
+ </foxtransfers_write>
46
+
47
+ <foxtransfers_read>
48
+ <connection>
49
+ <use>core_read</use>
50
+ </connection>
51
+ </foxtransfers_read>
52
+
53
+ </resources>
54
+
55
+ </global>
56
+
57
+ <frontend>
58
+ <routers>
59
+ <foxtransfers>
60
+ <use>standard</use>
61
+ <args>
62
+ <module>MTS_Foxtransfers</module>
63
+ <frontName>foxtransfers</frontName>
64
+ </args>
65
+ </foxtransfers>
66
+ </routers>
67
+ </frontend>
68
+
69
+ <default>
70
+ <payment>
71
+ <foxtransfers>
72
+ <active>1</active>
73
+ <title>FoxTransfers.lt</title>
74
+ <username>sandbox</username>
75
+ <sendemail>1</sendemail>
76
+ <model>foxtransfers/paymentMethod</model>
77
+ <!--<order_status>processing</order_status>-->
78
+ </foxtransfers>
79
+ </payment>
80
+ </default>
81
+
82
+
83
+ </config>
app/code/local/MTS/Foxtransfers/etc/system.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+ <sections>
5
+ <payment>
6
+ <groups>
7
+ <foxtransfers translate="label" module="paygate">
8
+
9
+ <label>FoxTransfers.lt</label>
10
+
11
+ <sort_order>200</sort_order>
12
+
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>0</show_in_store>
16
+
17
+ <fields>
18
+
19
+ <title translate="label">
20
+ <label>Title</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ </title>
27
+
28
+ <active translate="label">
29
+ <label>Enabled</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>2</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </active>
37
+
38
+ <username translate="label">
39
+ <label>Merchant ID</label>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>3</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <tooltip>Merchant ID is used for merchant identification by FoxTransfers system.</tooltip>
46
+ </username>
47
+
48
+ <action translate="label">
49
+ <label>Payment action</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>foxtransfers/actions</source_model>
52
+ <sort_order>4</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ <tooltip>Choose different modes for testing or real payments.</tooltip>
57
+ </action>
58
+
59
+ <privatekey translate="label">
60
+ <label>Merchant private key file</label>
61
+ <frontend_type>file</frontend_type>
62
+ <backend_model>foxtransfers/privatekey</backend_model>
63
+ <sort_order>5</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ <tooltip>Merchant private key file - special file, used for signing data sent from eCommerce system to FoxTransfers system.</tooltip>
68
+ </privatekey>
69
+
70
+ <foxtransferskey translate="label">
71
+ <label>FoxTransfers public key</label>
72
+ <frontend_type>file</frontend_type>
73
+ <backend_model>foxtransfers/foxtransferskey</backend_model>
74
+ <sort_order>6</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ <tooltip>FoxTransfers system public key - special file, should be provided to Merchant by FoxTransfers system administrator.</tooltip>
79
+ </foxtransferskey>
80
+
81
+ <sendemail translate="label">
82
+ <label>Send customer email</label>
83
+ <frontend_type>select</frontend_type>
84
+ <source_model>adminhtml/system_config_source_yesno</source_model>
85
+ <sort_order>7</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <tooltip>If set to Yes, customer e-mail is sent to FoxTransfers system and if payment was successful, e-mail confirmation message is sent to customer from FoxTransfers system.</tooltip>
90
+ </sendemail>
91
+
92
+
93
+ </fields>
94
+
95
+ </foxtransfers>
96
+ </groups>
97
+ </payment>
98
+ </sections>
99
+
100
+ </config>
app/code/local/MTS/Foxtransfers/lib/FoxTransfersShop.class.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FoxTransfersShop{
3
+
4
+ private $formHtml;
5
+ private $encoding;
6
+ private $key;
7
+ private $signString;
8
+
9
+ public function __construct($key, $enc=null){
10
+ $this->formHtml="";
11
+ $this->encoding=$enc;
12
+ $this->key=$key;
13
+ $this->signString=null;
14
+ }
15
+
16
+ public function convertArray(&$formArray){
17
+ if (!$this->encoding) return NULL;
18
+ foreach($formArray as $key=>$val){
19
+ $formArray[$key]=iconv($this->encoding,"UTF-8",$val);
20
+ }
21
+ return $formArray;
22
+ }
23
+
24
+ public function makeSignString($formArray,$convert=TRUE,$sort=TRUE){
25
+ if ($sort) ksort($formArray);
26
+ if ($convert) $this->convertArray($formArray);
27
+ $this->signString="";
28
+ $keys=array("amount","currency","encoding","partner","stamp","status","transaction");
29
+ foreach ($keys as $key){
30
+ if (isset($formArray[$key])){
31
+ $length=mb_strlen($formArray[$key],"UTF-8");
32
+ if ($length>0){
33
+ $this->signString.=sprintf ("%03d",$length);
34
+ $this->signString.=$formArray[$key];
35
+ }
36
+ }
37
+ }
38
+ return $this->signString;
39
+ }
40
+
41
+ public function validateFormArray($formArray){
42
+ if (!is_array($formArray)) return FALSE;
43
+ if (!array_key_exists("partner",$formArray)
44
+ or !array_key_exists("amount",$formArray)
45
+ or !array_key_exists("transaction",$formArray)
46
+ or strlen($formArray['partner'])<1
47
+ or strlen($formArray['amount'])<1
48
+ or strlen($formArray['transaction'])<1 )
49
+ return FALSE;
50
+ return true;
51
+ }
52
+
53
+ public function generateFormData($formArray){
54
+ if (!$this->validateFormArray($formArray)) return;
55
+ ksort($formArray);
56
+ if (!is_null($this->encoding)) $this->convertArray($formArray);
57
+ $signStr=$this->makeSignString($formArray,FALSE,FALSE);
58
+ $privKey=openssl_get_privatekey($this->key);
59
+ openssl_sign($this->signString,$signature,$privKey);
60
+ openssl_free_key($privKey);
61
+ $signature=base64_encode($signature);
62
+ $signature = preg_replace("/[\r|\n]/", "", $signature);
63
+ $formArray['signature']=$signature;
64
+ return $formArray;
65
+ }
66
+
67
+ public function generateForm($formArray){
68
+ $str="";
69
+ $formArray=$this->generateFormData($formArray);
70
+ foreach ($formArray as $key=>$val){
71
+ $str.="<input type=\"hidden\" name=\"".$key."\" value=\"".htmlentities($val)."\"/>\n";
72
+ }
73
+ $this->formHtml=$str;
74
+ return $this->formHtml;
75
+
76
+ }
77
+
78
+ public function validateData(&$formArray){
79
+ if (!isset($formArray['signature']) or !isset($formArray['transaction']) ) return false;
80
+ $signature=$formArray['signature'];
81
+ unset($formArray['sign']);
82
+ ksort($formArray);
83
+ $signStr=$this->makeSignString($formArray,false,false);
84
+ $pubKey=openssl_get_publickey($this->key);
85
+ return openssl_verify($signStr,base64_decode($signature),$pubKey);
86
+ }
87
+
88
+ public function validateDataSuccess(&$formArray){
89
+ if (!$this->validateData($formArray)){
90
+ return false;
91
+ }
92
+ else {
93
+ return $formArray['status'];
94
+ }
95
+ }
96
+
97
+
98
+ }
99
+ ?>
app/code/local/MTS/Foxtransfers/sql/foxtransfers_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php
app/design/frontend/default/default/template/foxtransfers/form.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset class="form-list">
2
+
3
+ <?php $_code = $this->getMethodCode(); ?>
4
+ <?php $logo = Mage::getStoreConfig('payment/foxtransfers/logo'); ?>
5
+
6
+ <ul id="payment_form_<?php echo $_code; ?>" style="display:none;">
7
+
8
+ <table>
9
+ <tr>
10
+
11
+ <td>
12
+ <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . '/foxtransfers/FoxLogo.png'; ?>" onclick="payment.switchMethod('foxtransfers');document.getElementById('p_method_<?php echo $_code ?>').checked=true;" />
13
+ </td>
14
+
15
+ <td style="padding: 0px 0px 0px 10px;">
16
+
17
+ <?php echo $this->__('FoxTransfers.lt - electronic payment system.'); ?>
18
+ <br />
19
+ <?php echo $this->__('(SEB, SwedBank, DNB, Nordea, DanskeBank, Šiaulių bankas, Citadele, Medicinos bankas)'); ?>
20
+ <br />
21
+ <a href="http://www.foxtransfers.lt" title="<?php echo $this->__('FoxTransfers.lt - electronic payment system'); ?>" target="_blank" >
22
+ <?php echo $this->__('More about FoxTransfers.lt.'); ?>
23
+ </a>
24
+
25
+ </td>
26
+
27
+ </tr>
28
+ </table>
29
+
30
+ </ul>
31
+
32
+ </fieldset>
app/etc/modules/MTS_Foxtransfers.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <MTS_Foxtransfers>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Payment />
9
+ </depends>
10
+ <version>0.1.0</version>
11
+ </MTS_Foxtransfers>
12
+ </modules>
13
+ </config>
media/foxtransfers/FoxLogo.png ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>MTS_FoxTransfers</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl.html">GNU General Public License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>FoxTransfers payment module</summary>
10
+ <description>FoxTransfers - electronic payment system</description>
11
+ <notes>First version stable.</notes>
12
+ <authors><author><name>MTS</name><user>TomasMisiunas</user><email>tmisiunas@gmail.com</email></author></authors>
13
+ <date>2013-06-01</date>
14
+ <time>13:35:34</time>
15
+ <contents><target name="magelocal"><dir name="MTS"><dir name="Foxtransfers"><dir name="Block"><dir name="Pay"><file name="Form.php" hash="2bf98ba68aca4984a46a3844f202637c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6a9d24fe6f3ad248cc74f71c5b03f199"/></dir><dir name="Model"><file name="Actions.php" hash="2a8e1519b68d6fadb06313db0641adf1"/><file name="Foxtransferskey.php" hash="bb5c1f2a3d50ce4ab4d699ff24b2c1fc"/><file name="Foxtransferslogo.php" hash="7c6371d30654f0bb56a7cfca8acdc4e7"/><file name="PaymentMethod.php" hash="8abcb6ff128531c7aef63ad9c1aa83b4"/><file name="Privatekey.php" hash="3d22e89862e0dd3ca395ef86306e872a"/><file name="foxtransfers.php" hash="f84214fc43f665c79b92dc7a092b364f"/></dir><dir name="controllers"><file name="PayController.php" hash="6c52304e74df3f5493791b16d7a3f3b6"/></dir><dir name="etc"><file name="config.xml" hash="394a457808998a6d95bc904b4497ae16"/><file name="system.xml" hash="6f9b20150e1aaae7cbd798fae100ce11"/></dir><dir name="lib"><file name="FoxTransfersShop.class.php" hash="e1a8e754b5c13b2cbfe53033838c3385"/></dir><dir name="sql"><dir name="foxtransfers_setup"><file name="mysql4-install-1.0.0.php" hash="f84214fc43f665c79b92dc7a092b364f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="foxtransfers"><file name="form.phtml" hash="3ab0f9f2b14f120f29fa77d5e3ee37ea"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MTS_Foxtransfers.xml" hash="70878b23e596e46e0fd1473af5672b29"/></dir></target><target name="magemedia"><dir name="foxtransfers"><file name="FoxLogo.png" hash="0c5d0c9383002dccf764c028817e0a0d"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>