payfort_payment - Version 0.0.1

Version Notes

Payfort Payment Gateway first release 0.0.1

Download this release

Release Info

Developer Moe
Extension payfort_payment
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

app/code/community/Payfort/Pay/Adminhtml/Model/System/Config/Source/Currencyoptions.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payfort_Pay_Adminhtml_Model_System_Config_Source_Currencyoptions {
4
+ /* * */
5
+
6
+ /**
7
+ * Options getter
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray() {
12
+ return array(
13
+ array('value' => 'USD', 'label' => Mage::helper('adminhtml')->__('USD')),
14
+ array('value' => 'AED', 'label' => Mage::helper('adminhtml')->__('AED')),
15
+ array('value' => 'EUR', 'label' => Mage::helper('adminhtml')->__('EUR')),
16
+ array('value' => 'EGP', 'label' => Mage::helper('adminhtml')->__('EGP')),
17
+ array('value' => 'SAR', 'label' => Mage::helper('adminhtml')->__('SAR')),
18
+ array('value' => 'KWD', 'label' => Mage::helper('adminhtml')->__('KWD')),
19
+ array('value' => 'SYP', 'label' => Mage::helper('adminhtml')->__('SYP')),
20
+ array('value' => 'no_currency', 'label' => Mage::helper('adminhtml')->__('Use Default')),
21
+ );
22
+ }
23
+
24
+ }
app/code/community/Payfort/Pay/Adminhtml/Model/System/Config/Source/Languageoptions.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payfort_Pay_Adminhtml_Model_System_Config_Source_Languageoptions {
4
+ /* * */
5
+
6
+ /**
7
+ * Options getter
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray() {
12
+ return array(
13
+ array('value' => 'en_US', 'label' => Mage::helper('adminhtml')->__('en_US')),
14
+ array('value' => 'ar_SA', 'label' => Mage::helper('adminhtml')->__('ar_SA')),
15
+ );
16
+ }
17
+
18
+ }
app/code/community/Payfort/Pay/Helper/Data.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payfort_Pay_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ public function deleteallCartItems() {
6
+ $cartHelper = Mage::helper('checkout/cart');
7
+ $items = $cartHelper->getCart()->getItems();
8
+ foreach ($items as $item) {
9
+ $itemId = $item->getItemId();
10
+ $cartHelper->getCart()->removeItem($itemId)->save();
11
+ }
12
+ }
13
+
14
+ /**
15
+ * Translates the response code into a more meaningful description.
16
+ * Response code descriptions are taken directly from the Payfort documentation.
17
+ */
18
+ function getResponseCodeDescription($responseCode) {
19
+ switch ($responseCode) {
20
+ case "0" : $result = "Invalid or incomplete";
21
+ break;
22
+ case "1" : $result = "Cancelled by customer";
23
+ break;
24
+ case "2" : $result = "Authorisation declined";
25
+ break;
26
+ case "5" : $result = "Authorised";
27
+ break;
28
+ case "9" : $result = "Payment requested";
29
+ break;
30
+ default : $result = "Response Unknown";
31
+ }
32
+
33
+ return $result;
34
+ }
35
+
36
+ }
app/code/community/Payfort/Pay/Model/Pay.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payfort_Pay_Model_Pay extends Mage_Payment_Model_Method_Abstract {
4
+
5
+ protected $_code = 'payfort';
6
+ protected $_isInitializeNeeded = true;
7
+ protected $_canUseInternal = true;
8
+ protected $_canUseForMultishipping = false;
9
+
10
+ public function getOrderPlaceRedirectUrl() {
11
+ return Mage::getUrl('payfort/payment/redirect', array('_secure' => true));
12
+ }
13
+
14
+ }
app/code/community/Payfort/Pay/Model/Service/Quote.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payfort_Pay_Model_Service_Quote extends Mage_Sales_Model_Service_Quote {
4
+
5
+ public function submitOrder() {
6
+ $order = parent::submitOrder();
7
+
8
+ // Prevent the cart to be emptied before payment response
9
+ //$this->_quote->setIsActive(true);
10
+
11
+ return $order;
12
+ }
13
+
14
+ }
app/code/community/Payfort/Pay/controllers/PaymentController.php ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+
7
+ }
8
+
9
+ // The redirect action is triggered when someone places an order
10
+ public function redirectAction() {
11
+
12
+ $is_active = Mage::getStoreConfig('payment/payfort/active');
13
+ $test_mode = Mage::getStoreConfig('payment/payfort/sandbox_mode');
14
+
15
+ $merchant_affiliation_name = Mage::getStoreConfig('payment/payfort/merchant_affiliation_name');
16
+ $sha_in_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_in_pass_phrase');
17
+ $sha_out_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_out_pass_phrase');
18
+
19
+
20
+ $action_gateway = '';
21
+
22
+ if (!$test_mode) {
23
+ $action_gateway = 'https://secure.payfort.com/ncol/';
24
+ } else {
25
+ $action_gateway = 'https://secure.payfort.com/ncol/test/';
26
+ }
27
+
28
+ //Loading current layout
29
+ $this->loadLayout();
30
+ //Creating a new block
31
+ $block = $this->getLayout()->createBlock(
32
+ 'Mage_Core_Block_Template', 'payfort_block_redirect', array('template' => 'payfort/pay/redirect.phtml')
33
+ )
34
+ ->setData('merchant_affiliation_name', $merchant_affiliation_name)
35
+ ->setData('sha_in_pass_phrase', $sha_in_pass_phrase)
36
+ ->setData('sha_out_pass_phrase', $sha_out_pass_phrase);
37
+
38
+ $this->getLayout()->getBlock('content')->append($block);
39
+
40
+ //Now showing it with rendering of layout
41
+ $this->renderLayout();
42
+ }
43
+
44
+ public function responseAction() {
45
+
46
+
47
+
48
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
49
+ $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
50
+
51
+ /*
52
+ * $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
53
+ * $order->getGrandTotal();
54
+ *
55
+ * */
56
+
57
+
58
+ /*
59
+ * Most frequent transaction statuses:
60
+ *
61
+ 0 - Invalid or incomplete
62
+ 1 - Cancelled by customer
63
+ 2 - Authorisation declined
64
+ 5 - Authorised
65
+ 9 - Payment requested
66
+ */
67
+
68
+ $sha_in_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_in_pass_phrase');
69
+
70
+ $sha_out_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_out_pass_phrase');
71
+
72
+ $params_not_included = array('response_type', 'SHASIGN');
73
+
74
+ $response_type = $this->getRequest()->getParam('response_type');
75
+
76
+ $SHASIGN = $this->getRequest()->getParam('SHASIGN');
77
+
78
+ $response_order_id = $this->getRequest()->getParam('orderID');
79
+
80
+ $response_status = $this->getRequest()->getParam('STATUS');
81
+
82
+
83
+
84
+ $response_params = $this->getRequest()->getParams();
85
+
86
+ uksort($response_params, 'strnatcasecmp');
87
+
88
+ $sha_string = '';
89
+
90
+ $error = false;
91
+ $status = "";
92
+
93
+ foreach($response_params as $key => $param) {
94
+
95
+ // ignore not included params
96
+ if(in_array($key, $params_not_included))
97
+ continue;
98
+
99
+ // ignore empty params
100
+ if($param == '')
101
+ continue;
102
+
103
+ $sha_string .= strtoupper($key) . '=' . $param . $sha_out_pass_phrase;
104
+
105
+ }
106
+
107
+ $sha_string_encrypted = sha1($sha_string);
108
+
109
+ //var_dump(strtolower($sha_string_encrypted));
110
+ //var_dump(strtolower($SHASIGN));
111
+
112
+ // check the SHASIGN
113
+ if(strtolower($sha_string_encrypted) !== strtolower($SHASIGN)) {
114
+
115
+ $response_message = $this->__('Invalid response encrypted key.');
116
+
117
+ $this->loadLayout();
118
+ //Creating a new block
119
+ $block = $this->getLayout()->createBlock(
120
+ 'Mage_Core_Block_Template', 'payfort_block_response', array('template' => 'payfort/pay/response.phtml')
121
+ )
122
+ ->setData('response_message', $response_message);
123
+
124
+ $this->getLayout()->getBlock('content')->append($block);
125
+
126
+ //Now showing it with rendering of layout
127
+ $this->renderLayout();
128
+
129
+ return false;
130
+
131
+ }
132
+
133
+
134
+ /*$error = false;
135
+ $status = "pending";
136
+ //die('Transaction Pending');
137
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING, true, 'Transaction is pending on Payfort Team for approval/acceptance');
138
+ $order->save();*/
139
+
140
+
141
+ $response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
142
+
143
+ if($response_status != 9 && $response_status != 5) {
144
+
145
+ $response_message = $this->__($response_status_message);
146
+
147
+ $this->renderResponse($response_message);
148
+
149
+ return false;
150
+
151
+ }
152
+
153
+ switch($response_type):
154
+ case 'accept':
155
+
156
+ /** trying to create invoice * */
157
+ try {
158
+ if (!$order->canInvoice()):
159
+ //Mage::throwException(Mage::helper('core')->__('cannot create invoice !'));
160
+ //Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
161
+
162
+ $response_message = $this->__('Error: cannot create an invoice !');
163
+
164
+ $this->renderResponse($response_message);
165
+
166
+ return false;
167
+
168
+ else:
169
+ /** create invoice **/
170
+ //$invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncremenetId(), array());
171
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
172
+
173
+ if (!$invoice->getTotalQty()):
174
+ //Mage::throwException(Mage::helper('core')->__('cannot create an invoice without products !'));
175
+
176
+ $response_message = $this->__('Error: cannot create an invoice without products !');
177
+
178
+ $this->renderResponse($response_message);
179
+
180
+ return false;
181
+
182
+
183
+ endif;
184
+
185
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
186
+ $invoice->register();
187
+ $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
188
+ $transactionSave->save();
189
+
190
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Payfort has accepted the payment.');
191
+ /** load invoice * */
192
+ //$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
193
+ /** pay invoice * */
194
+ //$invoice->capture()->save();
195
+ endif;
196
+ } catch (Mage_Core_Exception $e) {
197
+ //Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
198
+ }
199
+
200
+ $order->sendNewOrderEmail();
201
+ $order->setEmailSent(true);
202
+ $order->save();
203
+
204
+ if($response_status == 9) {
205
+
206
+ $response_message = $this->__('Your payment is accepted.');
207
+
208
+ } elseif($response_status == 5) {
209
+
210
+ $response_message = $this->__('Your payment is authorized.');
211
+
212
+ } else {
213
+
214
+ $response_message = $this->__('Unknown response status.');
215
+
216
+ }
217
+
218
+
219
+
220
+ $this->renderResponse($response_message);
221
+
222
+ return;
223
+
224
+
225
+ break;
226
+ case 'decline':
227
+
228
+ // There is a problem in the response we got
229
+ $this->cancelAction();
230
+ //Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
231
+
232
+
233
+ $response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
234
+
235
+ $this->renderResponse($response_message);
236
+
237
+ return false;
238
+
239
+
240
+ break;
241
+ case 'exception':
242
+
243
+ // There is a problem in the response we got
244
+ $this->cancelAction();
245
+ //Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
246
+
247
+ $response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
248
+
249
+ $this->renderResponse($response_message);
250
+
251
+ return false;
252
+
253
+
254
+ break;
255
+
256
+ case 'cancel':
257
+
258
+ // There is a problem in the response we got
259
+ $this->cancelAction();
260
+ //Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
261
+
262
+ $response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
263
+
264
+ $this->renderResponse($response_message);
265
+
266
+ return false;
267
+
268
+ break;
269
+
270
+ default:
271
+
272
+ $response_message = $this->__('Response Unknown');
273
+
274
+ $this->renderResponse($response_message);
275
+
276
+ return false;
277
+
278
+ break;
279
+ endswitch;
280
+
281
+
282
+
283
+ }
284
+
285
+ // The cancel action is triggered when an order is to be cancelled
286
+ public function cancelAction() {
287
+ if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
288
+ $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
289
+ if ($order->getId()) {
290
+ // Flag the order as 'cancelled' and save it
291
+ $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
292
+ }
293
+ }
294
+ }
295
+
296
+ public function successAction() {
297
+ /**/
298
+ }
299
+
300
+ public function renderResponse($response_message) {
301
+
302
+ $this->loadLayout();
303
+ //Creating a new block
304
+ $block = $this->getLayout()->createBlock(
305
+ 'Mage_Core_Block_Template', 'payfort_block_response', array('template' => 'payfort/pay/response.phtml')
306
+ )
307
+ ->setData('response_message', $response_message);
308
+
309
+ $this->getLayout()->getBlock('content')->append($block);
310
+
311
+ //Now showing it with rendering of layout
312
+ $this->renderLayout();
313
+
314
+ }
315
+
316
+ public function testAction() {
317
+
318
+ }
319
+
320
+ }
app/code/community/Payfort/Pay/etc/config.xml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Payfort_Pay>
5
+ <version>0.0.1</version>
6
+ </Payfort_Pay>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <payfort>
11
+ <class>Payfort_Pay_Block</class>
12
+ </payfort>
13
+ </blocks>
14
+ <helpers>
15
+ <payfort>
16
+ <class>Payfort_Pay_Helper</class>
17
+ </payfort>
18
+ </helpers>
19
+ <models>
20
+ <payfort>
21
+ <class>Payfort_Pay_Model</class>
22
+ </payfort>
23
+ <payfort_adminhtml>
24
+ <class>Payfort_Pay_Adminhtml_Model</class>
25
+ </payfort_adminhtml>
26
+ <!-- <sales>
27
+ <rewrite>
28
+ <service_quote>Payfort_Pay_Model_Service_Quote</service_quote>
29
+ </rewrite>
30
+ </sales>-->
31
+ </models>
32
+ <resources>
33
+ <payfort_setup>
34
+ <setup>
35
+ <module>Payfort_Pay</module>
36
+ </setup>
37
+ <connection>
38
+ <use>core_setup</use>
39
+ </connection>
40
+ </payfort_setup>
41
+ <payfort_write>
42
+ <connection>
43
+ <use>core_write</use>
44
+ </connection>
45
+ </payfort_write>
46
+ <payfort_read>
47
+ <connection>
48
+ <use>core_read</use>
49
+ </connection>
50
+ </payfort_read>
51
+ </resources>
52
+ </global>
53
+ <default>
54
+ <payment>
55
+ <payfort>
56
+ <active>1</active>
57
+ <order_status>pending</order_status>
58
+ <model>payfort/pay</model>
59
+ <title>PayPayfort Payment Method</title>
60
+ <payment_action>sale</payment_action>
61
+ <allowspecific>0</allowspecific>
62
+ <sort_order>1</sort_order>
63
+ </payfort>
64
+ </payment>
65
+ </default>
66
+ <frontend>
67
+ <secure_url>
68
+ <pay>/payfort</pay>
69
+ </secure_url>
70
+ <routers>
71
+ <payfort>
72
+ <use>standard</use>
73
+ <args>
74
+ <module>Payfort_Pay</module>
75
+ <frontName>payfort</frontName>
76
+ </args>
77
+ </payfort>
78
+ </routers>
79
+ <layout>
80
+ <updates>
81
+ <payfort>
82
+ <file>payfort/payfort.xml</file>
83
+ </payfort>
84
+ </updates>
85
+ </layout>
86
+ </frontend>
87
+ </config>
app/code/community/Payfort/Pay/etc/system.xml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <payfort translate="label">
7
+ <label>Payfort Payment Method</label>
8
+ <sort_order>670</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <fields>
13
+ <active translate="label">
14
+ <label>Enabled</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>1</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ </active>
22
+ <title translate="label">
23
+ <label>Title</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>2</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>0</show_in_store>
29
+ </title>
30
+ <currency translate="label">
31
+ <label>Currency</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>payfort_adminhtml/system_config_source_currencyoptions</source_model>
34
+ <sort_order>3</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </currency>
39
+ <language translate="label">
40
+ <label>Language</label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>payfort_adminhtml/system_config_source_languageoptions</source_model>
43
+ <sort_order>4</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ </language>
48
+ <merchant_affiliation_name translate="label">
49
+ <label>Merchant affiliation name</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>5</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </merchant_affiliation_name>
56
+ <sha_in_pass_phrase translate="label">
57
+ <label>SHA-IN pass phrase</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>6</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>0</show_in_store>
63
+ </sha_in_pass_phrase>
64
+ <sha_out_pass_phrase translate="label">
65
+ <label>SHA-OUT pass phrase</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>7</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>0</show_in_store>
71
+ </sha_out_pass_phrase>
72
+ <sandbox_mode translate="label">
73
+ <label>Sandbox mode</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <sort_order>8</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>0</show_in_store>
80
+ </sandbox_mode>
81
+ <!--<return_url>
82
+ <label>Note : you need to specify your Return URL http://example.com/payfort/payment/response</label>
83
+ <frontend_type>label</frontend_type>
84
+ <sort_order>9</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ </return_url>-->
89
+ </fields>
90
+ </payfort>
91
+ </groups>
92
+ </payment>
93
+ </sections>
94
+ </config>
app/design/frontend/base/default/layout/payfort/payfort.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ </default>
5
+ <payfort_payment_redirect>
6
+ <remove name="header"/>
7
+ <remove name="footer"/>
8
+ <!-- <remove name="content"/> -->
9
+ <reference name="root">
10
+ <action method="setTemplate"><template>payfort/layout.phtml</template></action>
11
+ </reference>
12
+ <reference name="head"></reference>
13
+ <reference name="content"></reference>
14
+ </payfort_payment_redirect>
15
+
16
+ <payfort_payment_response>
17
+ <remove name="header"/>
18
+ <remove name="footer"/>
19
+ <!-- <remove name="content"/> -->
20
+ <reference name="head"></reference>
21
+ <reference name="root">
22
+ <action method="setTemplate"><template>payfort/layout.phtml</template></action>
23
+ </reference>
24
+ <reference name="content"></reference>
25
+ </payfort_payment_response>
26
+
27
+ </layout>
app/design/frontend/base/default/template/payfort/layout.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php echo $this->getChildHtml('content') ?>
app/design/frontend/base/default/template/payfort/pay/redirect.phtml ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $merchant_affiliation_name = $this->getData('merchant_affiliation_name');
3
+ $sha_in_pass_phrase = $this->getData('sha_in_pass_phrase');
4
+
5
+ $action_gateway = $this->getData('action_gateway');
6
+
7
+ // Retrieve order
8
+ $_order = Mage::getModel('sales/order');
9
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
10
+ $_order->loadByIncrementId($orderId);
11
+
12
+
13
+
14
+ $total = round($_order->getBaseGrandTotal(), 2);
15
+ //$shipping_amount = $_order->getShippingAmount();
16
+
17
+ //$shipping_amount = str_replace('.', '', $shipping_amount);
18
+
19
+ $language = Mage::getStoreConfig('payment/payfort/language');
20
+ $currency = Mage::getStoreConfig('payment/payfort/currency');
21
+
22
+
23
+
24
+ /*
25
+ *
26
+ String to hash
27
+ AMOUNT=1500Mysecretsig1875!?CURRENCY=EURMysecretsig1875!?
28
+ LANGUAGE=en_USMysecretsig1875!?ORDERID=1234Mysecretsig1875!?
29
+ PSPID=MyPSPIDMysecretsig1875!?
30
+ *
31
+ */
32
+
33
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
34
+ $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
35
+
36
+ // Convert currency
37
+
38
+ if($currency == 'no_currency') {
39
+
40
+ $currency = $currentCurrencyCode;
41
+ $total = round(Mage::helper('directory')->currencyConvert($total, $baseCurrencyCode, $currentCurrencyCode), 2);
42
+
43
+ } else {
44
+
45
+ $total = round(Mage::helper('directory')->currencyConvert($total, $baseCurrencyCode, $currency), 2);
46
+ }
47
+
48
+ //$total = str_replace('.', '', $total) * 100;
49
+ $total = $total * 100;
50
+
51
+ //$shipping_amount = round(Mage::helper('directory')->currencyConvert($_order->getShippingAmount(), 'USD', 'SAR'), 2);
52
+
53
+
54
+
55
+ $sha_sign = sha1('AMOUNT=' . $total . $sha_in_pass_phrase . 'CURRENCY=' . $currency . $sha_in_pass_phrase .
56
+ 'LANGUAGE=' . $language . $sha_in_pass_phrase . 'ORDERID=' . $orderId . $sha_in_pass_phrase . 'PSPID=' . $merchant_affiliation_name . $sha_in_pass_phrase);
57
+
58
+
59
+
60
+
61
+ $items_name = array();
62
+ $items_description = array();
63
+ $items_qty = array();
64
+ $items_price = array();
65
+ $items_id = array();
66
+
67
+ $items = $_order->getAllItems();
68
+
69
+ foreach ($items as $item) {
70
+
71
+
72
+ $items_name[] = $item->getName();
73
+ $items_description[] = $item->getDescription();
74
+ $items_qty[] = $item->getQtyOrdered();
75
+ //$items_price[] = round(Mage::helper('directory')->currencyConvert(round($item->getPrice(), 2), 'USD', 'SAR'), 2);
76
+ $items_price[] = round($item->getPrice());
77
+ $items_id[] = $item->getProductId();
78
+ }
79
+ ?>
80
+
81
+ <div class="center wrapper">
82
+
83
+ <div id="logo" class="center"></div>
84
+ <p class="center title"><?php echo $this->__('Redirecting to Payfort ...') ?></p>
85
+
86
+ <form name="payfortpaymentform" id="payfortpaymentform" method="post" action="https://secure.payfort.com/ncol/test/orderstandard.asp" id="form1" name="form1">
87
+ <!-- general parameters -->
88
+ <input type="hidden" name="PSPID" value="<?php echo $merchant_affiliation_name ?>">
89
+ <input type="hidden" name="ORDERID" value="<?php echo $orderId ?>">
90
+ <input type="hidden" name="AMOUNT" value="<?php echo $total ?>">
91
+ <input type="hidden" name="CURRENCY" value="<?php echo $currency ?>">
92
+ <input type="hidden" name="LANGUAGE" value="<?php echo $language ?>">
93
+ <!--<input type="hidden" name="CN" value="">
94
+ <input type="hidden" name="EMAIL" value="">
95
+ <input type="hidden" name="OWNERZIP" value="">
96
+ <input type="hidden" name="OWNERADDRESS" value="">
97
+ <input type="hidden" name="OWNERCTY" value="">
98
+ <input type="hidden" name="OWNERTOWN" value="">
99
+ <input type="hidden" name="OWNERTELNO" value="">-->
100
+ <!-- check before the payment: see Security: Check before the payment -->
101
+ <input type="hidden" name="SHASIGN" value="<?php echo $sha_sign ?>">
102
+ <!-- layout information: see Look and feel of the payment page -->
103
+ <!--<input type="hidden" name="TITLE" value="">
104
+ <input type="hidden" name="BGCOLOR" value="">
105
+ <input type="hidden" name="TXTCOLOR" value="">
106
+ <input type="hidden" name="TBLBGCOLOR" value="">
107
+ <input type="hidden" name="TBLTXTCOLOR" value="">
108
+ <input type="hidden" name="BUTTONBGCOLOR" value="">
109
+ <input type="hidden" name="BUTTONTXTCOLOR" value="">
110
+ <input type="hidden" name="LOGO" value="">
111
+ <input type="hidden" name="FONTTYPE" value="">-->
112
+ <!-- post payment redirection: see Transaction feedback to the customer -->
113
+ <!--<input type="hidden" name="ACCEPTURL" value="">
114
+ <input type="hidden" name="DECLINEURL" value="">
115
+ <input type="hidden" name="EXCEPTIONURL" value="">
116
+ <input type="hidden" name="CANCELURL" value="">-->
117
+ <input type="submit" value="" id="submit2" name="submit2">
118
+ </form>
119
+
120
+ </div>
121
+
122
+ <script type="text/javascript">
123
+ (function(){
124
+ setTimeout(function(){
125
+ document.payfortpaymentform.submit();
126
+ }, 5000);
127
+ })();
128
+ </script>
129
+
130
+ <style type="text/css">
131
+
132
+ #payfortpaymentform {
133
+ display:none;
134
+ }
135
+
136
+ .center {
137
+ width: 50%;
138
+ margin: 0 auto;
139
+ }
140
+
141
+ #logo {
142
+ background:url(<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/base/default/payfort/img/payfort_logo.png' ?>);
143
+ width: 123px;
144
+ height: 44px;
145
+ margin-top:50px;
146
+
147
+ }
148
+
149
+ .title {
150
+ text-align: center;
151
+ margin-top:50px;
152
+ }
153
+
154
+ </style>
app/design/frontend/base/default/template/payfort/pay/response.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $response_message = $this->getData('response_message'); ?>
2
+
3
+ <div class="center wrapper">
4
+ <div id="logo" class="center"></div>
5
+ <p class="center title"><?php echo $this->__($response_message) ?></p>
6
+ </div>
7
+
8
+ <script type="text/javascript">
9
+ (function(){
10
+ setTimeout(function(){
11
+ document.location.href = '<?php echo Mage::getBaseUrl() ?>';
12
+ }, 5000);
13
+ })();
14
+ </script>
15
+
16
+ <style type="text/css">
17
+
18
+ #payfortpaymentform {
19
+ display:none;
20
+ }
21
+
22
+ .center {
23
+ width: 50%;
24
+ margin: 0 auto;
25
+ }
26
+
27
+ #logo {
28
+ background:url(<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/base/default/payfort/img/payfort_logo.png' ?>);
29
+ width: 123px;
30
+ height: 44px;
31
+ margin-top:50px;
32
+
33
+ }
34
+
35
+ .title {
36
+ text-align: center;
37
+ margin-top:50px;
38
+ }
39
+
40
+ </style>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>payfort_payment</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension will allow your customers to use Payfort payment gateway.</summary>
10
+ <description>This extension adds (Payfort Payment Gateway) option to your store payment methods. Upon adding this extension to your store, your customers will be able to complete payment through Payfort Gateway. This extension is customizable as you can configure it to meet your needs. Additionally, it allows you to add the requirements settings for your Payfort merchant account.</description>
11
+ <notes>Payfort Payment Gateway first release 0.0.1 </notes>
12
+ <authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
13
+ <date>2013-08-18</date>
14
+ <time>15:30:06</time>
15
+ <contents><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payfort"><file name="layout.phtml" hash="7949696b79643341359508a6d6d64921"/><dir name="pay"><file name="redirect.phtml" hash="d331ba9d7fcc8e747eff3e37a8550a38"/><file name="response.phtml" hash="11d9417ffb22e1cafcb266b4585a5c6e"/></dir></dir></dir><dir name="layout"><dir name="payfort"><file name="payfort.xml" hash="e76ce8855e50afeb1188d0db5a240f2d"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="payfort"><dir name="img"><file name="payfort_logo.png" hash="0667a5f51fe189ede6184fc1aff10466"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Payfort"><dir name="Pay"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="9db473b306b6184457643b8d215d5deb"/><file name="Languageoptions.php" hash="69c088784228db9d1e160dc939846012"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="77e47b554e7119e2b5901b528df25604"/></dir><dir name="Model"><file name="Pay.php" hash="a04390520c7b3d087caafd05830bd231"/><dir name="Service"><file name="Quote.php" hash="7fea0b61ba93444686a3591af6325a35"/></dir></dir><dir name="controllers"><file name="PaymentController.php" hash="f84cc037a5ceec0315674e418d1d9ce9"/></dir><dir name="etc"><file name="config.xml" hash="f5f70a879646e8d9a9771c320600d650"/><file name="system.xml" hash="453d8465747ed08f76ab83bb0bd8178f"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/payfort/img/payfort_logo.png ADDED
Binary file