Version Notes
Payfort Payment Gateway first release 0.0.2
Download this release
Release Info
Developer | Moe |
Extension | payfort_payment |
Version | 0.0.2 |
Comparing to | |
See all releases |
Code changes from version 0.0.1 to 0.0.2
- app/code/community/Payfort/Pay/Adminhtml/Model/System/Config/Source/Languageoptions.php +1 -0
- app/code/community/Payfort/Pay/Adminhtml/Model/System/Config/Source/Shaoptions.php +19 -0
- app/code/community/Payfort/Pay/Block/Adminhtml/System/Config/Fieldset/Group.php +46 -0
- app/code/community/Payfort/Pay/Block/Adminhtml/System/Config/Fieldset/Payment.php +70 -0
- app/code/community/Payfort/Pay/Block/Note.php +27 -0
- app/code/community/Payfort/Pay/controllers/PaymentController.php +60 -138
- app/code/community/Payfort/Pay/etc/config.xml +1 -0
- app/code/community/Payfort/Pay/etc/system.xml +56 -5
- app/design/frontend/base/default/layout/payfort/payfort.xml +56 -4
- app/design/frontend/base/default/template/payfort/pay/redirect.phtml +43 -62
- app/etc/modules/Payfort_Pay.xml +12 -0
- package.xml +5 -5
app/code/community/Payfort/Pay/Adminhtml/Model/System/Config/Source/Languageoptions.php
CHANGED
@@ -12,6 +12,7 @@ class Payfort_Pay_Adminhtml_Model_System_Config_Source_Languageoptions {
|
|
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 |
|
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 |
+
array('value' => 'no_language', 'label' => Mage::helper('adminhtml')->__('Use store locale')),
|
16 |
);
|
17 |
}
|
18 |
|
app/code/community/Payfort/Pay/Adminhtml/Model/System/Config/Source/Shaoptions.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payfort_Pay_Adminhtml_Model_System_Config_Source_Shaoptions {
|
4 |
+
/* * */
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Options getter
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function toOptionArray() {
|
12 |
+
return array(
|
13 |
+
array('value' => 'SHA-1', 'label' => Mage::helper('adminhtml')->__('SHA-1')),
|
14 |
+
array('value' => 'SHA-256', 'label' => Mage::helper('adminhtml')->__('SHA-256')),
|
15 |
+
array('value' => 'SHA-512', 'label' => Mage::helper('adminhtml')->__('SHA-512')),
|
16 |
+
);
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
app/code/community/Payfort/Pay/Block/Adminhtml/System/Config/Fieldset/Group.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payfort_Pay_Block_Adminhtml_System_Config_Fieldset_Group
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* Return header comment part of html for fieldset
|
8 |
+
*
|
9 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
10 |
+
* @return string
|
11 |
+
*/
|
12 |
+
protected function _getHeaderCommentHtml($element)
|
13 |
+
{
|
14 |
+
$groupConfig = $this->getGroup($element)->asArray();
|
15 |
+
|
16 |
+
if (empty($groupConfig['help_url']) || !$element->getComment()) {
|
17 |
+
return parent::_getHeaderCommentHtml($element);
|
18 |
+
}
|
19 |
+
|
20 |
+
$html = '<div class="comment">' . $element->getComment()
|
21 |
+
. ' <a target="_blank" href="' . $groupConfig['help_url'] . '">'
|
22 |
+
. Mage::helper('payfort')->__('Help') . '</a></div>';
|
23 |
+
|
24 |
+
return $html;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Return collapse state
|
29 |
+
*
|
30 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
31 |
+
* @return bool
|
32 |
+
*/
|
33 |
+
protected function _getCollapseState($element)
|
34 |
+
{
|
35 |
+
$extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
|
36 |
+
if (isset($extra['configState'][$element->getId()])) {
|
37 |
+
return $extra['configState'][$element->getId()];
|
38 |
+
}
|
39 |
+
|
40 |
+
if ($element->getExpanded() !== null) {
|
41 |
+
return 1;
|
42 |
+
}
|
43 |
+
|
44 |
+
return false;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Payfort/Pay/Block/Adminhtml/System/Config/Fieldset/Payment.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payfort_Pay_Block_Adminhtml_System_Config_Fieldset_Payment
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* Add custom css class
|
8 |
+
*
|
9 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
10 |
+
* @return string
|
11 |
+
*/
|
12 |
+
protected function _getFrontendClass($element)
|
13 |
+
{
|
14 |
+
return parent::_getFrontendClass($element) . ' with-button '
|
15 |
+
. ($this->_isPaymentEnabled($element) ? ' enabled' : '');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Check whether current payment method is enabled
|
20 |
+
*
|
21 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
22 |
+
* @return bool
|
23 |
+
*/
|
24 |
+
protected function _isPaymentEnabled($element)
|
25 |
+
{
|
26 |
+
$groupConfig = $this->getGroup($element)->asArray();
|
27 |
+
$activityPath = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : '';
|
28 |
+
|
29 |
+
if (empty($activityPath)) {
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
|
33 |
+
$isPaymentEnabled = (string)Mage::getSingleton('adminhtml/config_data')->getConfigDataValue($activityPath);
|
34 |
+
|
35 |
+
return (bool)$isPaymentEnabled;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Return header title part of html for payment solution
|
40 |
+
*
|
41 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
protected function _getHeaderTitleHtml($element)
|
45 |
+
{
|
46 |
+
return '';
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Return header comment part of html for payment solution
|
51 |
+
*
|
52 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
protected function _getHeaderCommentHtml($element)
|
56 |
+
{
|
57 |
+
return '';
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get collapsed state on-load
|
62 |
+
*
|
63 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
64 |
+
* @return bool
|
65 |
+
*/
|
66 |
+
protected function _getCollapseState($element)
|
67 |
+
{
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Payfort/Pay/Block/Note.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payfort_Pay_Block_Note extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
4 |
+
|
5 |
+
function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
6 |
+
$element_id = str_replace('payment_payfort_', '', $element->getId());
|
7 |
+
switch($element_id):
|
8 |
+
case 'more_info':
|
9 |
+
return '<a href="http://support.shopgo.me/en/2013/08/29/how-to-enable-payfort-on-your-store/" target="_blank">How to enable PayFort on your store</a>';
|
10 |
+
break;
|
11 |
+
case 'how_to_test':
|
12 |
+
return '<a href="https://secure.payfort.com/Ncol/PayFort_Testacc_EN.pdf?CSRFSP=%2fncol%2ftest%2fbackoffice%2fsupportgetdownloaddocument.asp&CSRFKEY=83E267BD93379EC7A63B9D5BDBE67B83E81240E9&CSRFTS=20130906221442&branding=PAYFORT" target="_blank">How to create a test account</a>';
|
13 |
+
break;
|
14 |
+
case 'feedback_urls':
|
15 |
+
return '
|
16 |
+
|
17 |
+
Accepturl: http://[example.com]/[store lanuage code]/payfort/payment/response?response_type=accept <br />
|
18 |
+
Declineurl: http://[example.com]/[store lanuage code]/payfort/payment/response?response_type=decline <br />
|
19 |
+
Exceptionurl: http://[example.com]/[store lanuage code]/payfort/payment/response?response_type=exception <br />
|
20 |
+
Cancelurl: http://[example.com]/[store lanuage code]/payfort/payment/response?response_type=cancel <br />
|
21 |
+
|
22 |
+
|
23 |
+
';
|
24 |
+
break;
|
25 |
+
endswitch;
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Payfort/Pay/controllers/PaymentController.php
CHANGED
@@ -3,20 +3,17 @@
|
|
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 |
-
|
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) {
|
@@ -43,8 +40,6 @@ class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
|
|
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 |
|
@@ -53,11 +48,9 @@ class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
|
|
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
|
@@ -66,48 +59,34 @@ class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
|
|
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 |
-
|
73 |
-
|
74 |
-
|
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 |
-
$
|
108 |
|
109 |
-
|
110 |
-
|
111 |
|
112 |
// check the SHASIGN
|
113 |
if(strtolower($sha_string_encrypted) !== strtolower($SHASIGN)) {
|
@@ -130,156 +109,101 @@ class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
|
|
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 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
$this->renderResponse($response_message);
|
165 |
-
|
166 |
-
return false;
|
167 |
-
|
168 |
else:
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
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 |
-
|
202 |
-
|
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 |
-
|
229 |
-
|
230 |
-
|
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 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
$this->renderResponse($response_message);
|
250 |
-
|
251 |
-
return false;
|
252 |
-
|
253 |
-
|
254 |
break;
|
255 |
-
|
256 |
case 'cancel':
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
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
|
@@ -298,7 +222,6 @@ class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
|
|
298 |
}
|
299 |
|
300 |
public function renderResponse($response_message) {
|
301 |
-
|
302 |
$this->loadLayout();
|
303 |
//Creating a new block
|
304 |
$block = $this->getLayout()->createBlock(
|
@@ -310,7 +233,6 @@ class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
|
|
310 |
|
311 |
//Now showing it with rendering of layout
|
312 |
$this->renderLayout();
|
313 |
-
|
314 |
}
|
315 |
|
316 |
public function testAction() {
|
3 |
class Payfort_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
|
4 |
|
5 |
public function indexAction() {
|
6 |
+
return;
|
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 |
$merchant_affiliation_name = Mage::getStoreConfig('payment/payfort/merchant_affiliation_name');
|
15 |
$sha_in_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_in_pass_phrase');
|
16 |
$sha_out_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_out_pass_phrase');
|
|
|
|
|
17 |
$action_gateway = '';
|
18 |
|
19 |
if (!$test_mode) {
|
40 |
|
41 |
public function responseAction() {
|
42 |
|
|
|
|
|
43 |
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
44 |
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
|
45 |
|
48 |
* $order->getGrandTotal();
|
49 |
*
|
50 |
* */
|
51 |
+
/*
|
52 |
+
* * Most frequent transaction statuses:
|
53 |
+
* *
|
|
|
|
|
54 |
0 - Invalid or incomplete
|
55 |
1 - Cancelled by customer
|
56 |
2 - Authorisation declined
|
59 |
*/
|
60 |
|
61 |
$sha_in_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_in_pass_phrase');
|
|
|
62 |
$sha_out_pass_phrase = Mage::getStoreConfig('payment/payfort/sha_out_pass_phrase');
|
63 |
+
$params_not_included = array('response_type', 'SHASIGN');
|
64 |
+
$response_type = $this->getRequest()->getParam('response_type');
|
65 |
+
$SHASIGN = $this->getRequest()->getParam('SHASIGN');
|
66 |
+
$response_order_id = $this->getRequest()->getParam('orderID');
|
67 |
+
$response_status = $this->getRequest()->getParam('STATUS');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
$response_params = $this->getRequest()->getParams();
|
69 |
|
70 |
uksort($response_params, 'strnatcasecmp');
|
|
|
71 |
$sha_string = '';
|
72 |
|
73 |
$error = false;
|
74 |
$status = "";
|
75 |
|
76 |
foreach($response_params as $key => $param) {
|
|
|
77 |
// ignore not included params
|
78 |
if(in_array($key, $params_not_included))
|
79 |
continue;
|
|
|
80 |
// ignore empty params
|
81 |
if($param == '')
|
82 |
continue;
|
|
|
83 |
$sha_string .= strtoupper($key) . '=' . $param . $sha_out_pass_phrase;
|
|
|
84 |
}
|
85 |
|
86 |
+
$sha_type = Mage::getStoreConfig('payment/payfort/sha_type');
|
87 |
|
88 |
+
//$sha_string_encrypted = sha1($sha_string);
|
89 |
+
$sha_string_encrypted = hash(str_replace('-', '', $sha_type), $sha_string);
|
90 |
|
91 |
// check the SHASIGN
|
92 |
if(strtolower($sha_string_encrypted) !== strtolower($SHASIGN)) {
|
109 |
|
110 |
}
|
111 |
|
|
|
112 |
/*$error = false;
|
113 |
$status = "pending";
|
114 |
//die('Transaction Pending');
|
115 |
$order->setState(Mage_Sales_Model_Order::STATE_PENDING, true, 'Transaction is pending on Payfort Team for approval/acceptance');
|
116 |
$order->save();*/
|
117 |
|
118 |
+
$response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
|
|
|
119 |
|
120 |
if($response_status != 9 && $response_status != 5) {
|
|
|
121 |
$response_message = $this->__($response_status_message);
|
|
|
122 |
$this->renderResponse($response_message);
|
|
|
123 |
return false;
|
|
|
124 |
}
|
125 |
|
126 |
switch($response_type):
|
127 |
case 'accept':
|
|
|
128 |
/** trying to create invoice * */
|
129 |
try {
|
130 |
if (!$order->canInvoice()):
|
131 |
+
//Mage::throwException(Mage::helper('core')->__('cannot create invoice !'));
|
132 |
+
//Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
|
133 |
+
$response_message = $this->__('Error: cannot create an invoice !');
|
134 |
+
$this->renderResponse($response_message);
|
135 |
+
return false;
|
|
|
|
|
|
|
|
|
136 |
else:
|
137 |
+
/** create invoice **/
|
138 |
+
//$invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncremenetId(), array());
|
139 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
140 |
+
if (!$invoice->getTotalQty()):
|
141 |
+
//Mage::throwException(Mage::helper('core')->__('cannot create an invoice without products !'));
|
142 |
+
$response_message = $this->__('Error: cannot create an invoice without products !');
|
143 |
+
$this->renderResponse($response_message);
|
144 |
+
return false;
|
145 |
+
endif;
|
146 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
147 |
+
$invoice->register();
|
148 |
+
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
|
149 |
+
$transactionSave->save();
|
150 |
+
|
151 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Payfort has accepted the payment.');
|
152 |
+
/** load invoice * */
|
153 |
+
//$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
|
154 |
+
/** pay invoice * */
|
155 |
+
//$invoice->capture()->save();
|
156 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
} catch (Mage_Core_Exception $e) {
|
158 |
//Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
|
159 |
}
|
160 |
|
161 |
$order->sendNewOrderEmail();
|
162 |
+
$order->setEmailSent(true);
|
163 |
+
$order->save();
|
|
|
|
|
164 |
|
165 |
+
if($response_status == 9) {
|
166 |
$response_message = $this->__('Your payment is accepted.');
|
|
|
167 |
} elseif($response_status == 5) {
|
|
|
168 |
$response_message = $this->__('Your payment is authorized.');
|
|
|
169 |
} else {
|
|
|
170 |
$response_message = $this->__('Unknown response status.');
|
|
|
171 |
}
|
172 |
|
|
|
|
|
173 |
$this->renderResponse($response_message);
|
|
|
174 |
return;
|
|
|
|
|
175 |
break;
|
176 |
case 'decline':
|
177 |
+
// There is a problem in the response we got
|
178 |
+
$this->cancelAction();
|
179 |
+
//Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
|
180 |
+
$response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
|
181 |
+
$this->renderResponse($response_message);
|
182 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
break;
|
184 |
case 'exception':
|
185 |
+
// There is a problem in the response we got
|
186 |
+
$this->cancelAction();
|
187 |
+
//Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
|
188 |
+
$response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
|
189 |
+
$this->renderResponse($response_message);
|
190 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
break;
|
|
|
192 |
case 'cancel':
|
193 |
+
// There is a problem in the response we got
|
194 |
+
$this->cancelAction();
|
195 |
+
//Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
|
196 |
+
$response_status_message = Mage::helper('payfort/data')->getResponseCodeDescription($response_status);
|
197 |
+
$this->renderResponse($response_message);
|
198 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
199 |
break;
|
|
|
200 |
default:
|
|
|
201 |
$response_message = $this->__('Response Unknown');
|
|
|
202 |
$this->renderResponse($response_message);
|
|
|
203 |
return false;
|
|
|
204 |
break;
|
205 |
endswitch;
|
206 |
|
|
|
|
|
207 |
}
|
208 |
|
209 |
// The cancel action is triggered when an order is to be cancelled
|
222 |
}
|
223 |
|
224 |
public function renderResponse($response_message) {
|
|
|
225 |
$this->loadLayout();
|
226 |
//Creating a new block
|
227 |
$block = $this->getLayout()->createBlock(
|
233 |
|
234 |
//Now showing it with rendering of layout
|
235 |
$this->renderLayout();
|
|
|
236 |
}
|
237 |
|
238 |
public function testAction() {
|
app/code/community/Payfort/Pay/etc/config.xml
CHANGED
@@ -57,6 +57,7 @@
|
|
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>
|
57 |
<order_status>pending</order_status>
|
58 |
<model>payfort/pay</model>
|
59 |
<title>PayPayfort Payment Method</title>
|
60 |
+
<sha_type>SHA-512</sha_type>
|
61 |
<payment_action>sale</payment_action>
|
62 |
<allowspecific>0</allowspecific>
|
63 |
<sort_order>1</sort_order>
|
app/code/community/Payfort/Pay/etc/system.xml
CHANGED
@@ -3,12 +3,22 @@
|
|
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>
|
@@ -46,17 +56,28 @@
|
|
46 |
<show_in_store>0</show_in_store>
|
47 |
</language>
|
48 |
<merchant_affiliation_name translate="label">
|
49 |
-
<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>
|
60 |
<show_in_default>1</show_in_default>
|
61 |
<show_in_website>1</show_in_website>
|
62 |
<show_in_store>0</show_in_store>
|
@@ -64,7 +85,7 @@
|
|
64 |
<sha_out_pass_phrase translate="label">
|
65 |
<label>SHA-OUT pass phrase</label>
|
66 |
<frontend_type>text</frontend_type>
|
67 |
-
<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>
|
@@ -72,12 +93,42 @@
|
|
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>
|
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>
|
3 |
<sections>
|
4 |
<payment>
|
5 |
<groups>
|
6 |
+
<payfort translate="label" module="payfort">
|
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 |
+
<expanded>1</expanded>
|
13 |
+
<frontend_class>complex</frontend_class>
|
14 |
+
<!--
|
15 |
+
<frontend_model>payfort/adminhtml_system_config_fieldset_payment</frontend_model>
|
16 |
+
-->
|
17 |
+
<!--
|
18 |
+
<comment>Payfort payment method configurations.</comment>
|
19 |
+
-->
|
20 |
+
<payfort_title></payfort_title>
|
21 |
+
<help_url></help_url>
|
22 |
<fields>
|
23 |
<active translate="label">
|
24 |
<label>Enabled</label>
|
56 |
<show_in_store>0</show_in_store>
|
57 |
</language>
|
58 |
<merchant_affiliation_name translate="label">
|
59 |
+
<label>PSPID</label>
|
60 |
<frontend_type>text</frontend_type>
|
61 |
+
<comment>Merchant affiliation name</comment>
|
62 |
<sort_order>5</sort_order>
|
63 |
<show_in_default>1</show_in_default>
|
64 |
<show_in_website>1</show_in_website>
|
65 |
<show_in_store>0</show_in_store>
|
66 |
</merchant_affiliation_name>
|
67 |
+
<sha_type translate="label">
|
68 |
+
<label>Hash algorithm</label>
|
69 |
+
<frontend_type>select</frontend_type>
|
70 |
+
<comment>The Hash algorithm will be used.</comment>
|
71 |
+
<source_model>payfort_adminhtml/system_config_source_shaoptions</source_model>
|
72 |
+
<sort_order>6</sort_order>
|
73 |
+
<show_in_default>1</show_in_default>
|
74 |
+
<show_in_website>1</show_in_website>
|
75 |
+
<show_in_store>0</show_in_store>
|
76 |
+
</sha_type>
|
77 |
<sha_in_pass_phrase translate="label">
|
78 |
<label>SHA-IN pass phrase</label>
|
79 |
<frontend_type>text</frontend_type>
|
80 |
+
<sort_order>7</sort_order>
|
81 |
<show_in_default>1</show_in_default>
|
82 |
<show_in_website>1</show_in_website>
|
83 |
<show_in_store>0</show_in_store>
|
85 |
<sha_out_pass_phrase translate="label">
|
86 |
<label>SHA-OUT pass phrase</label>
|
87 |
<frontend_type>text</frontend_type>
|
88 |
+
<sort_order>8</sort_order>
|
89 |
<show_in_default>1</show_in_default>
|
90 |
<show_in_website>1</show_in_website>
|
91 |
<show_in_store>0</show_in_store>
|
93 |
<sandbox_mode translate="label">
|
94 |
<label>Sandbox mode</label>
|
95 |
<frontend_type>select</frontend_type>
|
96 |
+
<comment>Testing or live mode.</comment>
|
97 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
98 |
+
<sort_order>9</sort_order>
|
99 |
<show_in_default>1</show_in_default>
|
100 |
<show_in_website>1</show_in_website>
|
101 |
<show_in_store>0</show_in_store>
|
102 |
</sandbox_mode>
|
103 |
+
<more_info translate="label">
|
104 |
+
<label>More info</label>
|
105 |
+
<frontend_type>note</frontend_type>
|
106 |
+
<frontend_model>payfort/note</frontend_model>
|
107 |
+
<sort_order>10</sort_order>
|
108 |
+
<show_in_default>1</show_in_default>
|
109 |
+
<show_in_website>1</show_in_website>
|
110 |
+
<show_in_store>0</show_in_store>
|
111 |
+
</more_info>
|
112 |
+
<how_to_test translate="label">
|
113 |
+
<label></label>
|
114 |
+
<frontend_type>note</frontend_type>
|
115 |
+
<frontend_model>payfort/note</frontend_model>
|
116 |
+
<sort_order>11</sort_order>
|
117 |
+
<show_in_default>1</show_in_default>
|
118 |
+
<show_in_website>1</show_in_website>
|
119 |
+
<show_in_store>0</show_in_store>
|
120 |
+
</how_to_test>
|
121 |
+
<!--
|
122 |
+
<feedback_urls translate="label">
|
123 |
+
<label>Feedbacks urls</label>
|
124 |
+
<frontend_type>note</frontend_type>
|
125 |
+
<frontend_model>payfort/note</frontend_model>
|
126 |
+
<sort_order>12</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>0</show_in_store>
|
130 |
+
</feedback_urls>
|
131 |
+
-->
|
132 |
<!--<return_url>
|
133 |
<label>Note : you need to specify your Return URL http://example.com/payfort/payment/response</label>
|
134 |
<frontend_type>label</frontend_type>
|
app/design/frontend/base/default/layout/payfort/payfort.xml
CHANGED
@@ -6,22 +6,74 @@
|
|
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 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
<reference name="root">
|
22 |
<action method="setTemplate"><template>payfort/layout.phtml</template></action>
|
23 |
</reference>
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
</payfort_payment_response>
|
26 |
|
27 |
</layout>
|
6 |
<remove name="header"/>
|
7 |
<remove name="footer"/>
|
8 |
<!-- <remove name="content"/> -->
|
9 |
+
<reference name="head">
|
10 |
+
<!--
|
11 |
+
<action method="addJs"><script>Hyper/jquery-1.10.1.min.js</script></action>
|
12 |
+
<action method="addJs"><script>Hyper/jquery-no-conflict.js</script></action>
|
13 |
+
<action method="addJs"><script>Hyper/scripts.js</script></action>
|
14 |
+
|
15 |
+
<action method="addCss"><stylesheet>payfort/css/bootstrap.css</stylesheet></action>
|
16 |
+
<action method="addCss"><stylesheet>payfort/css/payfort.css</stylesheet></action>
|
17 |
+
-->
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
</reference>
|
22 |
<reference name="root">
|
23 |
<action method="setTemplate"><template>payfort/layout.phtml</template></action>
|
24 |
</reference>
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
<reference name="head">
|
30 |
+
|
31 |
+
|
32 |
+
</reference>
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
<reference name="content">
|
37 |
+
|
38 |
+
|
39 |
+
</reference>
|
40 |
</payfort_payment_redirect>
|
41 |
|
42 |
<payfort_payment_response>
|
43 |
<remove name="header"/>
|
44 |
<remove name="footer"/>
|
45 |
<!-- <remove name="content"/> -->
|
46 |
+
<reference name="head">
|
47 |
+
<!--
|
48 |
+
<action method="addJs"><script>Hyper/jquery-1.10.1.min.js</script></action>
|
49 |
+
<action method="addJs"><script>Hyper/jquery-no-conflict.js</script></action>
|
50 |
+
<action method="addJs"><script>Hyper/scripts.js</script></action>
|
51 |
+
|
52 |
+
<action method="addCss"><stylesheet>payfort/css/bootstrap.css</stylesheet></action>
|
53 |
+
<action method="addCss"><stylesheet>payfort/css/payfort.css</stylesheet></action>
|
54 |
+
-->
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
</reference>
|
59 |
<reference name="root">
|
60 |
<action method="setTemplate"><template>payfort/layout.phtml</template></action>
|
61 |
</reference>
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
<reference name="head">
|
67 |
+
|
68 |
+
|
69 |
+
</reference>
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
<reference name="content">
|
74 |
+
|
75 |
+
|
76 |
+
</reference>
|
77 |
</payfort_payment_response>
|
78 |
|
79 |
</layout>
|
app/design/frontend/base/default/template/payfort/pay/redirect.phtml
CHANGED
@@ -1,25 +1,24 @@
|
|
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 |
*
|
@@ -34,14 +33,10 @@ $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 |
|
@@ -49,26 +44,23 @@ if($currency == 'no_currency') {
|
|
49 |
$total = $total * 100;
|
50 |
|
51 |
//$shipping_amount = round(Mage::helper('directory')->currencyConvert($_order->getShippingAmount(), 'USD', 'SAR'), 2);
|
|
|
52 |
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
$sha_sign =
|
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();
|
@@ -77,48 +69,43 @@ foreach ($items as $item) {
|
|
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 |
-
|
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 |
-
</form>
|
119 |
-
|
120 |
</div>
|
121 |
-
|
122 |
<script type="text/javascript">
|
123 |
(function(){
|
124 |
setTimeout(function(){
|
@@ -126,18 +113,14 @@ foreach ($items as $item) {
|
|
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;
|
@@ -145,10 +128,8 @@ foreach ($items as $item) {
|
|
145 |
margin-top:50px;
|
146 |
|
147 |
}
|
148 |
-
|
149 |
.title {
|
150 |
text-align: center;
|
151 |
margin-top:50px;
|
152 |
}
|
153 |
-
|
154 |
</style>
|
1 |
<?php
|
2 |
+
|
3 |
$merchant_affiliation_name = $this->getData('merchant_affiliation_name');
|
4 |
$sha_in_pass_phrase = $this->getData('sha_in_pass_phrase');
|
|
|
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 |
$total = round($_order->getBaseGrandTotal(), 2);
|
|
|
12 |
|
13 |
+
//$shipping_amount = $_order->getShippingAmount();
|
14 |
//$shipping_amount = str_replace('.', '', $shipping_amount);
|
15 |
|
16 |
$language = Mage::getStoreConfig('payment/payfort/language');
|
17 |
$currency = Mage::getStoreConfig('payment/payfort/currency');
|
18 |
|
19 |
+
if($language == 'no_language') {
|
20 |
+
$language = Mage::app()->getLocale()->getLocaleCode();
|
21 |
+
}
|
22 |
|
23 |
/*
|
24 |
*
|
33 |
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
34 |
|
35 |
// Convert currency
|
|
|
36 |
if($currency == 'no_currency') {
|
|
|
37 |
$currency = $currentCurrencyCode;
|
38 |
$total = round(Mage::helper('directory')->currencyConvert($total, $baseCurrencyCode, $currentCurrencyCode), 2);
|
|
|
39 |
} else {
|
|
|
40 |
$total = round(Mage::helper('directory')->currencyConvert($total, $baseCurrencyCode, $currency), 2);
|
41 |
}
|
42 |
|
44 |
$total = $total * 100;
|
45 |
|
46 |
//$shipping_amount = round(Mage::helper('directory')->currencyConvert($_order->getShippingAmount(), 'USD', 'SAR'), 2);
|
47 |
+
$sha_type = Mage::getStoreConfig('payment/payfort/sha_type');
|
48 |
|
49 |
+
/*$sha_sign = sha1('AMOUNT=' . $total . $sha_in_pass_phrase . 'CURRENCY=' . $currency . $sha_in_pass_phrase .
|
50 |
+
'LANGUAGE=' . $language . $sha_in_pass_phrase . 'ORDERID=' . $orderId . $sha_in_pass_phrase . 'PSPID=' . $merchant_affiliation_name . $sha_in_pass_phrase);*/
|
51 |
|
52 |
+
// Replace (-) with (empty) string in hash alg.
|
53 |
+
$sha_sign = hash(str_replace('-', '', $sha_type), 'AMOUNT=' . $total . $sha_in_pass_phrase . 'CURRENCY=' . $currency . $sha_in_pass_phrase .
|
54 |
'LANGUAGE=' . $language . $sha_in_pass_phrase . 'ORDERID=' . $orderId . $sha_in_pass_phrase . 'PSPID=' . $merchant_affiliation_name . $sha_in_pass_phrase);
|
55 |
|
|
|
|
|
|
|
56 |
$items_name = array();
|
57 |
$items_description = array();
|
58 |
$items_qty = array();
|
59 |
$items_price = array();
|
60 |
$items_id = array();
|
|
|
61 |
$items = $_order->getAllItems();
|
62 |
|
63 |
foreach ($items as $item) {
|
|
|
|
|
64 |
$items_name[] = $item->getName();
|
65 |
$items_description[] = $item->getDescription();
|
66 |
$items_qty[] = $item->getQtyOrdered();
|
69 |
$items_id[] = $item->getProductId();
|
70 |
}
|
71 |
?>
|
|
|
72 |
<div class="center wrapper">
|
|
|
73 |
<div id="logo" class="center"></div>
|
74 |
<p class="center title"><?php echo $this->__('Redirecting to Payfort ...') ?></p>
|
75 |
+
<form name="payfortpaymentform" id="payfortpaymentform" method="post" action="https://secure.payfort.com/ncol/test/orderstandard.asp" id="form1" name="form1">
|
76 |
+
<!-- general parameters -->
|
77 |
+
<input type="hidden" name="PSPID" value="<?php echo $merchant_affiliation_name ?>">
|
78 |
+
<input type="hidden" name="ORDERID" value="<?php echo $orderId ?>">
|
79 |
+
<input type="hidden" name="AMOUNT" value="<?php echo $total ?>">
|
80 |
+
<input type="hidden" name="CURRENCY" value="<?php echo $currency ?>">
|
81 |
+
<input type="hidden" name="LANGUAGE" value="<?php echo $language ?>">
|
82 |
+
<!--<input type="hidden" name="CN" value="">
|
83 |
+
<input type="hidden" name="EMAIL" value="">
|
84 |
+
<input type="hidden" name="OWNERZIP" value="">
|
85 |
+
<input type="hidden" name="OWNERADDRESS" value="">
|
86 |
+
<input type="hidden" name="OWNERCTY" value="">
|
87 |
+
<input type="hidden" name="OWNERTOWN" value="">
|
88 |
+
<input type="hidden" name="OWNERTELNO" value="">-->
|
89 |
+
<!-- check before the payment: see Security: Check before the payment -->
|
90 |
+
<input type="hidden" name="SHASIGN" value="<?php echo $sha_sign ?>">
|
91 |
+
<!-- layout information: see Look and feel of the payment page -->
|
92 |
+
<!--<input type="hidden" name="TITLE" value="">
|
93 |
+
<input type="hidden" name="BGCOLOR" value="">
|
94 |
+
<input type="hidden" name="TXTCOLOR" value="">
|
95 |
+
<input type="hidden" name="TBLBGCOLOR" value="">
|
96 |
+
<input type="hidden" name="TBLTXTCOLOR" value="">
|
97 |
+
<input type="hidden" name="BUTTONBGCOLOR" value="">
|
98 |
+
<input type="hidden" name="BUTTONTXTCOLOR" value="">
|
99 |
+
<input type="hidden" name="LOGO" value="">
|
100 |
+
<input type="hidden" name="FONTTYPE" value="">-->
|
101 |
+
<!-- post payment redirection: see Transaction feedback to the customer -->
|
102 |
+
<!--<input type="hidden" name="ACCEPTURL" value="">
|
103 |
+
<input type="hidden" name="DECLINEURL" value="">
|
104 |
+
<input type="hidden" name="EXCEPTIONURL" value="">
|
105 |
+
<input type="hidden" name="CANCELURL" value="">-->
|
106 |
+
<input type="submit" value="" id="submit2" name="submit2">
|
107 |
+
</form>
|
|
|
|
|
108 |
</div>
|
|
|
109 |
<script type="text/javascript">
|
110 |
(function(){
|
111 |
setTimeout(function(){
|
113 |
}, 5000);
|
114 |
})();
|
115 |
</script>
|
|
|
116 |
<style type="text/css">
|
|
|
117 |
#payfortpaymentform {
|
118 |
display:none;
|
119 |
}
|
|
|
120 |
.center {
|
121 |
width: 50%;
|
122 |
margin: 0 auto;
|
123 |
}
|
|
|
124 |
#logo {
|
125 |
background:url(<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/base/default/payfort/img/payfort_logo.png' ?>);
|
126 |
width: 123px;
|
128 |
margin-top:50px;
|
129 |
|
130 |
}
|
|
|
131 |
.title {
|
132 |
text-align: center;
|
133 |
margin-top:50px;
|
134 |
}
|
|
|
135 |
</style>
|
app/etc/modules/Payfort_Pay.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Payfort_Pay>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Payment />
|
9 |
+
</depends>
|
10 |
+
</Payfort_Pay>
|
11 |
+
</modules>
|
12 |
+
</config>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>payfort_payment</name>
|
4 |
-
<version>0.0.
|
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.
|
12 |
<authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
|
13 |
-
<date>2013-
|
14 |
-
<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="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>payfort_payment</name>
|
4 |
+
<version>0.0.2</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.2</notes>
|
12 |
<authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
|
13 |
+
<date>2013-09-06</date>
|
14 |
+
<time>21:02:11</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="d83e6c96e318cfa82720fb9290f3efe4"/><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="8eaebfd095436b0077200107b11d558d"/><file name="Shaoptions.php" hash="f7bb4923b485253d4236ef28f7bfad98"/></dir></dir></dir></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Group.php" hash="b4f2ae57336f0a415a517d8cd5d5cb32"/><file name="Payment.php" hash="821e14eda2c84847b4486814c1311ebe"/></dir></dir></dir></dir><file name="Note.php" hash="6b7c2a2cd0cdc32abb74ba1304338ebc"/></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="b281c357f541ab9f1bb0b18db269c9cc"/></dir><dir name="etc"><file name="config.xml" hash="52c886413f5a7bbf32d6607437dc805e"/><file name="system.xml" hash="c8d9b028bbd7a7f90ab3aaa56d3f8407"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Payfort_Pay.xml" hash="de239e211cd7a03877a2482c22975280"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|