Version Notes
First onecard extension release
Download this release
Release Info
Developer | Moe |
Extension | Onecard_Paymentmethod |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Onecard/Onecardpay/Adminhtml/Model/System/Config/Source/Currencyoptions.php +24 -0
- app/code/local/Onecard/Onecardpay/Adminhtml/Model/System/Config/Source/Languageoptions.php +19 -0
- app/code/local/Onecard/Onecardpay/Helper/Data.php +5 -0
- app/code/local/Onecard/Onecardpay/Model/Pay.php +12 -0
- app/code/local/Onecard/Onecardpay/controllers/PaymentController.php +128 -0
- app/code/local/Onecard/Onecardpay/etc/config.xml +78 -0
- app/code/local/Onecard/Onecardpay/etc/system.xml +110 -0
- app/design/frontend/default/default/template/onecard/redirect.phtml +54 -0
- app/design/frontend/default/default/template/onecard/success.phtml +39 -0
- app/etc/modules/Onecard_Onecardpay.xml +12 -0
- package.xml +18 -0
app/code/local/Onecard/Onecardpay/Adminhtml/Model/System/Config/Source/Currencyoptions.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Onecard_Onecardpay_Adminhtml_Model_System_Config_Source_Currencyoptions {
|
4 |
+
/***/
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Options getter
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function toOptionArray()
|
12 |
+
{
|
13 |
+
return array(
|
14 |
+
array('value' => 'usd', 'label'=>Mage::helper('adminhtml')->__('USD')),
|
15 |
+
array('value' => 'aed', 'label'=>Mage::helper('adminhtml')->__('AED')),
|
16 |
+
array('value' => 'eur', 'label'=>Mage::helper('adminhtml')->__('EUR')),
|
17 |
+
array('value' => 'egp', 'label'=>Mage::helper('adminhtml')->__('EGP')),
|
18 |
+
array('value' => 'sar', 'label'=>Mage::helper('adminhtml')->__('SAR')),
|
19 |
+
array('value' => 'kwd', 'label'=>Mage::helper('adminhtml')->__('KWD')),
|
20 |
+
array('value' => 'syp', 'label'=>Mage::helper('adminhtml')->__('SYP')),
|
21 |
+
);
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
app/code/local/Onecard/Onecardpay/Adminhtml/Model/System/Config/Source/Languageoptions.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Onecard_Onecardpay_Adminhtml_Model_System_Config_Source_Languageoptions {
|
4 |
+
/***/
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Options getter
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function toOptionArray()
|
12 |
+
{
|
13 |
+
return array(
|
14 |
+
array('value' => 'en', 'label'=>Mage::helper('adminhtml')->__('en')),
|
15 |
+
array('value' => 'ar', 'label'=>Mage::helper('adminhtml')->__('ar')),
|
16 |
+
);
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
app/code/local/Onecard/Onecardpay/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Onecard_Onecardpay_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
}
|
app/code/local/Onecard/Onecardpay/Model/Pay.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Onecard_Onecardpay_Model_Pay extends Mage_Payment_Model_Method_Abstract {
|
3 |
+
protected $_code = 'onecardpay';
|
4 |
+
|
5 |
+
protected $_isInitializeNeeded = true;
|
6 |
+
protected $_canUseInternal = true;
|
7 |
+
protected $_canUseForMultishipping = false;
|
8 |
+
|
9 |
+
public function getOrderPlaceRedirectUrl() {
|
10 |
+
return Mage::getUrl('onecardpay/payment/redirect', array('_secure' => true));
|
11 |
+
}
|
12 |
+
}
|
app/code/local/Onecard/Onecardpay/controllers/PaymentController.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Onecard_Onecardpay_PaymentController extends Mage_Core_Controller_Front_Action {
|
4 |
+
// The redirect action is triggered when someone places an order
|
5 |
+
public function redirectAction() {
|
6 |
+
$this->loadLayout();
|
7 |
+
$block = $this->getLayout()->createBlock('Mage_Core_Block_Template','onecardpay',array('template' => 'onecard/redirect.phtml'));
|
8 |
+
$this->getLayout()->getBlock('content')->append($block);
|
9 |
+
$this->renderLayout();
|
10 |
+
}
|
11 |
+
|
12 |
+
// The response action is triggered when your gateway sends back a response after processing the customer's payment
|
13 |
+
public function responseAction() {
|
14 |
+
if($this->getRequest()->isPost()) {
|
15 |
+
|
16 |
+
$validated = false;
|
17 |
+
|
18 |
+
$onecard_code = $_POST['OneCard_Code'];
|
19 |
+
$onecard_transid = $_POST['OneCard_TransID'];
|
20 |
+
$onecard_amount = $_POST['OneCard_Amount'];
|
21 |
+
$onecard_currency = $_POST['OneCard_Currency'];
|
22 |
+
$onecard_r_hashkey = $_POST['OneCard_RHashKey'];
|
23 |
+
$onecard_r_time = $_POST['OneCard_RTime'];
|
24 |
+
|
25 |
+
$orderId = $_POST['OneCard_Field1'];
|
26 |
+
|
27 |
+
|
28 |
+
$merchant_id = Mage::getStoreConfig('payment/onecardpay/merchant_id',Mage::app()->getStore());
|
29 |
+
$onecard_keyword = Mage::getStoreConfig('payment/onecardpay/onecard_keyword',Mage::app()->getStore());
|
30 |
+
|
31 |
+
$onecard_hashkey = md5($merchant_id.$onecard_transid.$onecard_amount.$onecard_currency.$onecard_r_time.$onecard_keyword.$onecard_code);
|
32 |
+
|
33 |
+
if($onecard_r_hashkey == $onecard_hashkey)
|
34 |
+
$validated = true;
|
35 |
+
|
36 |
+
|
37 |
+
/*
|
38 |
+
/* Your gateway's code to make sure the reponse you
|
39 |
+
/* just got is from the gatway and not from some weirdo.
|
40 |
+
/* This generally has some checksum or other checks,
|
41 |
+
/* and is provided by the gateway.
|
42 |
+
/* For now, we assume that the gateway's response is valid
|
43 |
+
*/
|
44 |
+
|
45 |
+
//extract($_POST);
|
46 |
+
|
47 |
+
//die($_POST['OneCard_Code']);
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
//var_dump($orderId);
|
53 |
+
|
54 |
+
if($validated) {
|
55 |
+
|
56 |
+
|
57 |
+
$confirmation_response = md5($merchant_id.$onecard_code.$onecard_transid.$onecard_amount.$onecard_currency.$onecard_r_time.$onecard_transkey);
|
58 |
+
//echo $confirmation_response;
|
59 |
+
|
60 |
+
|
61 |
+
// Payment was successful, so update the order's state, send order email and move to the success page
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
$order = Mage::getModel('sales/order');
|
66 |
+
$order->loadByIncrementId($orderId);
|
67 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
|
68 |
+
|
69 |
+
$order->sendNewOrderEmail();
|
70 |
+
$order->setEmailSent(true);
|
71 |
+
|
72 |
+
$order->save();
|
73 |
+
|
74 |
+
//Mage::getSingleton('checkout/session')->unsQuoteId();
|
75 |
+
|
76 |
+
//header('location: http://test.shopgo.me/cashument/payment/success');
|
77 |
+
//Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
|
78 |
+
//echo $orderId;
|
79 |
+
//$this->getLayout()->helper('page/layout')->applyTemplate('two_columns_left');
|
80 |
+
|
81 |
+
$block = $this->getLayout()->createBlock('Mage_Core_Block_Template','onecardpay_block',array('template' => 'onecard/success.phtml'))->setData('order', $orderId);
|
82 |
+
|
83 |
+
|
84 |
+
$this->loadLayout()->getLayout()->getBlock('root')->setTemplate('page/2columns-left.phtml');
|
85 |
+
|
86 |
+
|
87 |
+
$this->loadLayout()->getLayout()->getBlock('content')->append($block);
|
88 |
+
|
89 |
+
|
90 |
+
$this->renderLayout();
|
91 |
+
|
92 |
+
|
93 |
+
}
|
94 |
+
else {
|
95 |
+
// There is a problem in the response we got
|
96 |
+
$this->cancelAction();
|
97 |
+
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
|
98 |
+
}
|
99 |
+
}
|
100 |
+
else
|
101 |
+
Mage_Core_Controller_Varien_Action::_redirect('');
|
102 |
+
}
|
103 |
+
|
104 |
+
// The cancel action is triggered when an order is to be cancelled
|
105 |
+
public function cancelAction() {
|
106 |
+
if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
|
107 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
|
108 |
+
if($order->getId()) {
|
109 |
+
// Flag the order as 'cancelled' and save it
|
110 |
+
$order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
public function successAction(){
|
116 |
+
/**/
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
public function testAction(){
|
121 |
+
/**/
|
122 |
+
//echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
123 |
+
//echo time();
|
124 |
+
//$millitime = round(microtime(true) * 1000);
|
125 |
+
//echo $millitime;
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
app/code/local/Onecard/Onecardpay/etc/config.xml
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Onecard_Onecardpay>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Onecard_Onecardpay>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<onecardpay>
|
11 |
+
<class>Onecard_Onecardpay_Block</class>
|
12 |
+
</onecardpay>
|
13 |
+
</blocks>
|
14 |
+
<helpers>
|
15 |
+
<onecardpay>
|
16 |
+
<class>Onecard_Onecardpay_Helper</class>
|
17 |
+
</onecardpay>
|
18 |
+
</helpers>
|
19 |
+
<models>
|
20 |
+
<onecardpay>
|
21 |
+
<class>Onecard_Onecardpay_Model</class>
|
22 |
+
</onecardpay>
|
23 |
+
<onecardpay_adminhtml>
|
24 |
+
<class>Onecard_Onecardpay_Adminhtml_Model</class>
|
25 |
+
</onecardpay_adminhtml>
|
26 |
+
</models>
|
27 |
+
<resources>
|
28 |
+
<onecardpay_setup>
|
29 |
+
<setup>
|
30 |
+
<module>Onecard_Onecardpay</module>
|
31 |
+
</setup>
|
32 |
+
<connection>
|
33 |
+
<use>core_setup</use>
|
34 |
+
</connection>
|
35 |
+
</onecardpay_setup>
|
36 |
+
<onecardpay_write>
|
37 |
+
<connection>
|
38 |
+
<use>core_write</use>
|
39 |
+
</connection>
|
40 |
+
</onecardpay_write>
|
41 |
+
<onecardpay_read>
|
42 |
+
<connection>
|
43 |
+
<use>core_read</use>
|
44 |
+
</connection>
|
45 |
+
</onecardpay_read>
|
46 |
+
</resources>
|
47 |
+
</global>
|
48 |
+
<default>
|
49 |
+
<payment>
|
50 |
+
<onecardpay>
|
51 |
+
<active>1</active>
|
52 |
+
|
53 |
+
<order_status>pending</order_status>
|
54 |
+
|
55 |
+
<model>onecardpay/pay</model>
|
56 |
+
|
57 |
+
<title>Onecard Payment Method</title>
|
58 |
+
|
59 |
+
<payment_action>sale</payment_action>
|
60 |
+
|
61 |
+
<allowspecific>0</allowspecific>
|
62 |
+
|
63 |
+
<sort_order>1</sort_order>
|
64 |
+
</onecardpay>
|
65 |
+
</payment>
|
66 |
+
</default>
|
67 |
+
<frontend>
|
68 |
+
<routers>
|
69 |
+
<onecardpay>
|
70 |
+
<use>standard</use>
|
71 |
+
<args>
|
72 |
+
<module>Onecard_Onecardpay</module>
|
73 |
+
<frontName>onecardpay</frontName>
|
74 |
+
</args>
|
75 |
+
</onecardpay>
|
76 |
+
</routers>
|
77 |
+
</frontend>
|
78 |
+
</config>
|
app/code/local/Onecard/Onecardpay/etc/system.xml
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<onecardpay translate="label" module="paygate">
|
7 |
+
<label>Onecard 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 |
+
<order_status translate="label">
|
23 |
+
<label>New order status</label>
|
24 |
+
<frontend_type>select</frontend_type>
|
25 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
26 |
+
<sort_order>4</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>0</show_in_store>
|
30 |
+
</order_status>
|
31 |
+
<title translate="label">
|
32 |
+
<label>Title</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>2</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 |
+
</title>
|
39 |
+
<merchant_id translate="label">
|
40 |
+
<label>Merchant Id</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
<sort_order>3</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>0</show_in_store>
|
46 |
+
</merchant_id>
|
47 |
+
<currency translate="label">
|
48 |
+
<label>Currency</label>
|
49 |
+
<frontend_type>select</frontend_type>
|
50 |
+
<source_model>onecardpay_adminhtml/system_config_source_currencyoptions</source_model>
|
51 |
+
<sort_order>4</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 |
+
</currency>
|
56 |
+
<language translate="label">
|
57 |
+
<label>Language</label>
|
58 |
+
<frontend_type>select</frontend_type>
|
59 |
+
<source_model>onecardpay_adminhtml/system_config_source_languageoptions</source_model>
|
60 |
+
<sort_order>5</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>1</show_in_website>
|
63 |
+
<show_in_store>0</show_in_store>
|
64 |
+
</language>
|
65 |
+
<!--<display_text translate="label">
|
66 |
+
<label>Transaction Description</label>
|
67 |
+
<frontend_type>textarea</frontend_type>
|
68 |
+
<sort_order>6</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>1</show_in_website>
|
71 |
+
<show_in_store>0</show_in_store>
|
72 |
+
</display_text>-->
|
73 |
+
<payment_gateway_url translate="label">
|
74 |
+
<label>Payment gateway url (staging or production)</label>
|
75 |
+
<frontend_type>text</frontend_type>
|
76 |
+
<sort_order>7</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 |
+
</payment_gateway_url>
|
81 |
+
<onecard_keyword translate="label">
|
82 |
+
<label>Keyword</label>
|
83 |
+
<frontend_type>text</frontend_type>
|
84 |
+
<sort_order>8</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 |
+
</onecard_keyword>
|
89 |
+
<onecard_transkey translate="label">
|
90 |
+
<label>Transkey</label>
|
91 |
+
<frontend_type>text</frontend_type>
|
92 |
+
<sort_order>8</sort_order>
|
93 |
+
<show_in_default>1</show_in_default>
|
94 |
+
<show_in_website>1</show_in_website>
|
95 |
+
<show_in_store>0</show_in_store>
|
96 |
+
</onecard_transkey>
|
97 |
+
<!--<return_url>
|
98 |
+
<label>Note : you need to specify your Return URL http://example.com/onecardpay/payment/response</label>
|
99 |
+
<frontend_type>label</frontend_type>
|
100 |
+
<sort_order>9</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>0</show_in_store>
|
104 |
+
</return_url>-->
|
105 |
+
</fields>
|
106 |
+
</onecardpay>
|
107 |
+
</groups>
|
108 |
+
</payment>
|
109 |
+
</sections>
|
110 |
+
</config>
|
app/design/frontend/default/default/template/onecard/redirect.phtml
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Retrieve order
|
3 |
+
$_order = new Mage_Sales_Model_Order();
|
4 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
5 |
+
$_order->loadByIncrementId($orderId);
|
6 |
+
|
7 |
+
//var_dump($_order->getAllItems());
|
8 |
+
$items_description = '';
|
9 |
+
|
10 |
+
$items = $_order->getAllItems();
|
11 |
+
|
12 |
+
foreach($items as $item){
|
13 |
+
|
14 |
+
$items_description .= $item->getName();
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
//var_dump($items_description);
|
19 |
+
/* we use current order_id as a transaction_id */
|
20 |
+
$onecard_transid = $orderId;
|
21 |
+
|
22 |
+
|
23 |
+
$onecard_timein = round(microtime(true) * 1000);
|
24 |
+
|
25 |
+
$site_domain_name = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
26 |
+
$onecard_return_url = $site_domain_name.'onecardpay/payment/response';
|
27 |
+
|
28 |
+
/********************************/
|
29 |
+
$onecard_keyword = Mage::getStoreConfig('payment/onecardpay/onecard_keyword',Mage::app()->getStore());
|
30 |
+
$onecard_transkey = Mage::getStoreConfig('payment/onecardpay/onecard_transkey',Mage::app()->getStore());
|
31 |
+
$payment_gateway_url = Mage::getStoreConfig('payment/onecardpay/payment_gateway_url',Mage::app()->getStore());
|
32 |
+
$language = Mage::getStoreConfig('payment/onecardpay/language',Mage::app()->getStore());
|
33 |
+
$currency = Mage::getStoreConfig('payment/onecardpay/currency',Mage::app()->getStore());
|
34 |
+
$merchant_id = Mage::getStoreConfig('payment/onecardpay/merchant_id',Mage::app()->getStore());
|
35 |
+
|
36 |
+
//exit();
|
37 |
+
?>
|
38 |
+
|
39 |
+
<form name="onecardpaymentform" action="<?php echo $payment_gateway_url;?>" method="post" />
|
40 |
+
<input type="hidden" id="OneCard_MerchID" name="OneCard_MerchID" value="<?php echo $merchant_id;?>" />
|
41 |
+
<input type="hidden" id="OneCard_TransID" name="OneCard_TransID" value="<?php echo $onecard_transid;?>" />
|
42 |
+
<input type="hidden" id="OneCard_Amount" name="OneCard_Amount" value="<?php echo round($_order->getBaseGrandTotal(),2);?>" />
|
43 |
+
<input type="hidden" id="OneCard_Currency" name="OneCard_Currency" value="<?php echo $currency;?>" />
|
44 |
+
<input type="hidden" id="OneCard_Timein" name="OneCard_Timein" value="<?php echo $onecard_timein;?>" />
|
45 |
+
<input type="hidden" id="OneCard_MProd" name="OneCard_MProd" value="<?php echo $items_description;?>" />
|
46 |
+
<input type="hidden" id="OneCard_ReturnURL" name="OneCard_ReturnURL" value = "<?php echo $onecard_return_url;?>" />
|
47 |
+
<input type="hidden" id="OneCard_Field1" name="OneCard_Field1" value="<?php echo $orderId;?>" />
|
48 |
+
<input type="hidden" id="OneCard_Field2" name="OneCard_Field2" value="Value2" />
|
49 |
+
<input type="hidden" id="OneCard_HashKey" name="OneCard_HashKey" value="<?php echo md5($merchant_id.$onecard_transid.round($_order->getBaseGrandTotal(),2).$currency.$onecard_timein.$onecard_transkey);?>" />
|
50 |
+
</form>
|
51 |
+
<script type="text/javascript">
|
52 |
+
document.onecardpaymentform.submit();
|
53 |
+
</script>
|
54 |
+
|
app/design/frontend/default/default/template/onecard/success.phtml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
$_order = new Mage_Sales_Model_Order();
|
4 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
5 |
+
$_order->loadByIncrementId($orderId);
|
6 |
+
*/
|
7 |
+
$orderId = $this->getOrder();
|
8 |
+
$home_url = Mage::helper('core/url')->getHomeUrl();
|
9 |
+
|
10 |
+
//$checkout_order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
11 |
+
$current_order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
12 |
+
|
13 |
+
?>
|
14 |
+
<?php if($this->helper('customer')->isLoggedIn()): ?>
|
15 |
+
<div class="col-main">
|
16 |
+
<div class="page-title">
|
17 |
+
<h1>Your order has been received.</h1>
|
18 |
+
</div>
|
19 |
+
<h2 class="sub-title">Thank you for your purchase!</h2>
|
20 |
+
<p>Your order # is: <a href="<?php echo $home_url;?>sales/order/view/order_id/<?php echo $current_order->getId();?>"><?php echo $orderId;?></a>.</p>
|
21 |
+
<p>You will receive an order confirmation email with details of your order and a link to track its progress.</p>
|
22 |
+
<p>Click <a href="<?php echo $home_url;?>sales/order/print/order_id/<?php echo $current_order->getId();?>" onclick="this.target='_blank'">here to print</a> a copy of your order confirmation. </p>
|
23 |
+
<div class="buttons-set">
|
24 |
+
<button type="button" class="button" title="Continue Shopping" onclick="window.location='<?php echo $home_url;?>'"><span><span>Continue Shopping</span></span></button>
|
25 |
+
</div>
|
26 |
+
</div>
|
27 |
+
<?php else: ?>
|
28 |
+
<div class="col-main">
|
29 |
+
<div class="page-title">
|
30 |
+
<h1>Your order has been received.</h1>
|
31 |
+
</div>
|
32 |
+
<h2 class="sub-title">Thank you for your purchase!</h2>
|
33 |
+
<p>Your order # is: <?php echo $orderId;?>.</p>
|
34 |
+
<p>You will receive an order confirmation email with details of your order and a link to track its progress.</p>
|
35 |
+
<div class="buttons-set">
|
36 |
+
<button type="button" class="button" title="Continue Shopping" onclick="window.location='<?php echo $home_url;?>'"><span><span>Continue Shopping</span></span></button>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
<?php endif; ?>
|
app/etc/modules/Onecard_Onecardpay.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Onecard_Onecardpay>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Payment />
|
9 |
+
</depends>
|
10 |
+
</Onecard_Onecardpay>
|
11 |
+
</modules>
|
12 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Onecard_Paymentmethod</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Onecard integration for magento</summary>
|
10 |
+
<description>it allow users to use Onecard payment gateway in magento</description>
|
11 |
+
<notes>First onecard extension release</notes>
|
12 |
+
<authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
|
13 |
+
<date>2012-08-02</date>
|
14 |
+
<time>11:30:28</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Onecard"><dir name="Onecardpay"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="fc83780f82046c35823e74b1cd05b3f0"/><file name="Languageoptions.php" hash="c133d13eb64e99d7677bc817182c6c6c"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="50e632324654e42c438a831d96863bce"/></dir><dir name="Model"><file name="Pay.php" hash="fa02a9eaf39a0dab41874e1f919b788c"/></dir><dir name="controllers"><file name="PaymentController.php" hash="45217d3fc2d2a1bb9b63b85442fb3491"/></dir><dir name="etc"><file name="config.xml" hash="016825c62621241a5a1a7fd7998e0242"/><file name="system.xml" hash="bb99cdc5e10da236c6183996a2863f36"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="onecard"><file name="redirect.phtml" hash="b07cc83face7508d89c52daf11502067"/><file name="success.phtml" hash="857f02535c3b6908da9de15013cf4df5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Onecard_Onecardpay.xml" hash="9104f0d72530a39a89284678fa446130"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|