Thinkhigh_VPCpaymentgateway - Version 0.1.0

Version Notes

3-party payment

Download this release

Release Info

Developer Mitali
Extension Thinkhigh_VPCpaymentgateway
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Thinkhigh/VPCpaymentgateway/Block/Form/vpcpaymentgateway.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Payment
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Thinkhigh_VPCpaymentgateway_Block_Form_vpcpaymentgateway extends Mage_Payment_Block_Form
29
+ {
30
+
31
+ protected function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->setTemplate('vpcpaymentgateway/vpcpaymentgateway.phtml');
35
+ }
36
+
37
+ protected function _getConfig()
38
+ {
39
+ return Mage::getSingleton('payment/config');
40
+ }
41
+
42
+ public function getVpcAvailableTypes()
43
+ {
44
+ $obj=new Thinkhigh_VPCpaymentgateway_Model_Source_Payment_Vpc();
45
+ $types =$obj->toOptionArray();
46
+ if ($method = $this->getMethod()) {
47
+ $availableTypes = $method->getConfigData('vpc_card');
48
+ if ($availableTypes) {
49
+ $availableTypes = explode(',', $availableTypes);
50
+ foreach ($types as $k=>$val) {
51
+ if (!in_array($val['value'], $availableTypes)) {
52
+ unset($types[$k]);
53
+ }
54
+ }
55
+ }
56
+ }
57
+ return $types;
58
+ }
59
+ }
app/code/local/Thinkhigh/VPCpaymentgateway/Block/Info/Vpcsave.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Thinkhigh_VPCpaymentgateway_Block_Info_Vpcsave extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _prepareSpecificInformation($transport = null)
6
+ {
7
+ if (null !== $this->_paymentSpecificInformation) {
8
+ return $this->_paymentSpecificInformation;
9
+ }
10
+ $info = $this->getInfo();
11
+ if($info->getVpcCard()){
12
+ $transport = new Varien_Object(array(Mage::helper('payment')->__('Credit Card Type') => $info->getVpcCard()));
13
+ }
14
+ $transport = parent::_prepareSpecificInformation($transport);
15
+ /*if (!$this->getIsSecureMode()) {
16
+ $transport->addData(array(
17
+ Mage::helper('payment')->__('Expiration Date') => $this->_formatCardDate(
18
+ $info->getCcExpYear(), $this->getCcExpMonth()
19
+ ),
20
+ Mage::helper('payment')->__('Credit Card Number') => $info->getCcNumber(),
21
+ ));
22
+ } */
23
+ return $transport;
24
+ }
25
+
26
+ }
app/code/local/Thinkhigh/VPCpaymentgateway/Helper/Data.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Thinkhigh_VPCpaymentgateway_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ function getResultDescription($responseCode) {
5
+
6
+ switch ($responseCode) {
7
+ case "0" : $result = "Transaction Successful"; break;
8
+ case "?" : $result = "Transaction status is unknown"; break;
9
+ case "E" : $result = "Referred"; break;
10
+ case "1" : $result = "Transaction Declined"; break;
11
+ case "2" : $result = "Bank Declined Transaction"; break;
12
+ case "3" : $result = "No Reply from Bank"; break;
13
+ case "4" : $result = "Expired Card"; break;
14
+ case "5" : $result = "Insufficient funds"; break;
15
+ case "6" : $result = "Error Communicating with Bank"; break;
16
+ case "7" : $result = "Payment Server detected an error"; break;
17
+ case "8" : $result = "Transaction Type Not Supported"; break;
18
+ case "9" : $result = "Bank declined transaction (Do not contact Bank)"; break;
19
+ case "A" : $result = "Transaction Aborted"; break;
20
+ case "C" : $result = "Transaction Cancelled"; break;
21
+ case "D" : $result = "Deferred transaction has been received and is awaiting processing"; break;
22
+ case "F" : $result = "3D Secure Authentication failed"; break;
23
+ case "I" : $result = "Card Security Code verification failed"; break;
24
+ case "L" : $result = "Shopping Transaction Locked (Please try the transaction again later)"; break;
25
+ case "N" : $result = "Cardholder is not enrolled in Authentication scheme"; break;
26
+ case "P" : $result = "Transaction has been received by the Payment Adaptor and is being processed"; break;
27
+ case "R" : $result = "Transaction was not processed - Reached limit of retry attempts allowed"; break;
28
+ case "S" : $result = "Duplicate SessionID (Amex Only)"; break;
29
+ case "T" : $result = "Address Verification Failed"; break;
30
+ case "U" : $result = "Card Security Code Failed"; break;
31
+ case "V" : $result = "Address Verification and Card Security Code Failed"; break;
32
+ default : $result = "Unable to be determined";
33
+ }
34
+ return $result;
35
+ }
36
+
37
+ public function getRedirectUrl(){
38
+ return Mage::getStoreConfig('payment/vpcpaymentgateway/virtualPaymentClientURL');
39
+ }
40
+
41
+ public function getSecureHash(){
42
+ /*
43
+ * This is secret for encoding the MD5 hash
44
+ * This secret will vary from merchant to merchant
45
+ * To not create a secure hash, let SECURE_SECRET be an empty string - ""
46
+ */
47
+ return Mage::getStoreConfig('payment/vpcpaymentgateway/vpc_SecureHash');
48
+ }
49
+
50
+ }
app/code/local/Thinkhigh/VPCpaymentgateway/Model/Paymentconnection.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Thinkhigh_VPCpaymentgateway_Model_Paymentconnection {
3
+
4
+ public function getPostData(){
5
+ $_order = new Mage_Sales_Model_Order();
6
+ $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
7
+ $_order->loadByIncrementId($orderId);
8
+
9
+ $payment_data=$_order->getPayment();
10
+
11
+ /*
12
+ * Indicates the transaction type. This must be equal to 'pay' for a 2-Party or 3-Party payment
13
+ * Required Alphanumeric 1,8 1
14
+ */
15
+ $post_data['vpc_Version']=Mage::getStoreConfig('payment/vpcpaymentgateway/vpc_Version');
16
+
17
+ /*
18
+ * Authenticates the merchant on the Payment Server. This means that a merchant cannot access another merchant's Merchant Id.
19
+ * The access code is provided when the merchant profile is registered with a Payment Provider
20
+ * Required Alphanumeric 1,16 pay
21
+ */
22
+ $post_data['vpc_Command']=Mage::getStoreConfig('payment/vpcpaymentgateway/vpc_Command');
23
+
24
+ /*
25
+ * The unique Merchant Id assigned to a merchant by the Payment Provider.
26
+ * The Merchant ID identifies the merchant account against which settlements will be made
27
+ * Required Alphanumeric 1,16 TESTMERCHANT01
28
+ */
29
+ $post_data['vpc_Merchant']=Mage::getStoreConfig('payment/vpcpaymentgateway/vpc_Merchant');
30
+
31
+ /*
32
+ * Authenticates the merchant on the Payment Server. This means that a merchant cannot access another merchant's Merchant Id.
33
+ * The access code is provided when the merchant profile is registered with a Payment Provider.
34
+ * Required Alphanumeric 8 6AQ89F3
35
+ */
36
+ $post_data['vpc_AccessCode']=Mage::getStoreConfig('payment/vpcpaymentgateway/vpc_AccessCode');
37
+
38
+ /*
39
+ * A unique value created by the merchant.
40
+ * Required Alphanumeric 1,40 ORDER958743-1
41
+ */
42
+ $post_data['vpc_MerchTxnRef']='MerchTxnRef_'.$orderId;
43
+
44
+ /*
45
+ * The merchant's identifier used to identify the order on the Payment Server.
46
+ * For example, a shopping cart number, an order number, or an invoice number.
47
+ * This identifier will be displayed in the Transaction Search results in the Merchant Administration portal on the Payment Server.
48
+ * Optional Alphanumeric 0,34 ORDER958743
49
+ */
50
+ $post_data['vpc_OrderInfo']=$orderId;
51
+
52
+ /*
53
+ * The amount of the transaction, expressed in the smallest currency unit.
54
+ * The amount must not contain any decimal points, thousands separators or currency symbols.
55
+ * For example, $12.50 is expressed as 1250.
56
+ * This value cannot be negative or zero. The maximum amount is 2147483647.
57
+ * Required Numeric 1,10 1250
58
+ */
59
+
60
+ $post_data['vpc_Amount']=number_format($_order->getGrandTotal(), 2,'','');
61
+ $post_data['vpc_Gateway']=Mage::getStoreConfig('payment/vpcpaymentgateway/vpc_Gateway');
62
+
63
+ /*
64
+ * It is recommended that the browser is returned to an SSL secured page.
65
+ * This will prevent the browser pop-up indicating that the cardholder is being returned to an unsecure site.
66
+ * If the cardholder clicks 'No' to continue, then neither the merchant nor the cardholder will obtain any receipt details.
67
+ * Required Alphanumeric 1,255 https://merchants_site/receipt.asp
68
+ */
69
+ $post_data['vpc_ReturnURL']=Mage::getUrl('vpcpaymentgateway/payment/response');
70
+ if(isset($post_data['vpc_card']))//for 2-party transaction
71
+ $post_data['vpc_card']=$payment_data->getVpcCard();
72
+
73
+ /*
74
+ * The number of the card used for the transaction.
75
+ * The format of the Card Number is based on the Electronic Commerce Modeling Language (ECML) and,
76
+ * in particular, must not contain white space or formatting characters.
77
+ * Required Numeric 15,19 5123456789012346
78
+ */
79
+ if(isset($post_data['vpc_CardNum']))//for 2-party transaction
80
+ $post_data['vpc_CardNum']=Mage::helper('core')->decrypt($payment_data->getVpcCardNum());
81
+
82
+ /*
83
+ * The expiry date of the card in the format YYMM.
84
+ * The value must be expressed as a 4-digit number (integer) with no white space or formatting characters.
85
+ * For example, an expiry date of May 2013 is represented as 1305.
86
+ * Required Numeric 4 1305
87
+ */
88
+ if(isset($post_data['vpc_CardExp']))//for 2-party transaction
89
+ $post_data['vpc_CardExp']=$payment_data->getVpcCardExp();
90
+
91
+ /*
92
+ * The currency of the order expressed as an ISO 4217 alphanumeric code. This field is case-sensitive and must include uppercase
93
+ * characters only.
94
+ * The merchant must be configured to accept the currency used in this field.
95
+ * To obtain a list of supported currencies and codes, please contact your Payment Provider.
96
+ * Note: This field is required only if more than one currency is configured for the merchant.
97
+ * Optional Alpha 3 USD
98
+ */
99
+ $post_data['vpc_Currency']=Mage::app()->getStore()->getCurrentCurrencyCode();
100
+
101
+ /*
102
+ * vpc_Locale
103
+ * Specifies the language used on the Payment Server pages that are displayed to the cardholder,
104
+ * in 3-Party transactions. Please check with your Payment Provider for the correct value to use.
105
+ * In a 2-Party transaction the default value of 'en' is used.
106
+ * Required Alphanumeric 2,5 en
107
+ */
108
+ $post_data['vpc_Locale']=Mage::app()->getLocale()->getLocaleCode();
109
+
110
+ if(isset($post_data['vpc_CardSecurityCode']))//for 2-party transaction
111
+ $post_data['vpc_CardSecurityCode']=Mage::helper('core')->decrypt($payment_data->getVpcCardSecurityCode());
112
+
113
+ $post_data['vpc_ReturnAuthResponseData']='Y';
114
+
115
+ /*
116
+ * The field names are sorted in ascending of parameter name. Specifically, the sort order is:
117
+ * � Ascending order of parameter name using the ASCII collating sequence, for example, "Card" comes before "card"
118
+ * � Where one string is an exact substring of another, the smaller string should be ordered before the longer, for example, "Card"
119
+ * " should come before "CardNum".
120
+ */
121
+ ksort($post_data);
122
+
123
+ return $post_data;
124
+ }
125
+
126
+ }
127
+
128
+ ?>
app/code/local/Thinkhigh/VPCpaymentgateway/Model/Source.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Thinkhigh_VPCpaymentgateway_Model_Source{
3
+ public function toOptionArray(){
4
+ return array(
5
+ array('value' => 'ssl', 'label' => Mage::helper('vpcpaymentgateway')->__('Auth-Purchase with 3DS Authentication')),
6
+ array('value' => 'threeDSecure', 'label' => Mage::helper('vpcpaymentgateway')->__('3DS Authentication Only')),
7
+ );
8
+ }
9
+ }
10
+ ?>
app/code/local/Thinkhigh/VPCpaymentgateway/Model/Source/Payment/Vpc.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Thinkhigh_VPCpaymentgateway_Model_Source_Payment_Vpc{
3
+ public function toOptionArray(){
4
+ return array(
5
+ array('value' => 'Mastercard', 'label' => Mage::helper('vpcpaymentgateway')->__('Mastercard')),
6
+ array('value' => 'Visa', 'label' => Mage::helper('vpcpaymentgateway')->__('Visa')),
7
+ array('value' => 'Amex', 'label' => Mage::helper('vpcpaymentgateway')->__('American Express')),
8
+ array('value' => 'AmexPurchaseCard', 'label' => Mage::helper('vpcpaymentgateway')->__('Amex Corporate Purchase Card')),
9
+ );
10
+ }
11
+ }
12
+ ?>
app/code/local/Thinkhigh/VPCpaymentgateway/Model/Standard.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Thinkhigh_VPCpaymentgateway_Model_Standard extends Mage_Payment_Model_Method_Abstract {
3
+ protected $_code = 'vpcpaymentgateway';
4
+
5
+ protected $_isInitializeNeeded = true;
6
+ protected $_canUseInternal = true;
7
+ protected $_canUseForMultishipping = false;
8
+ // protected $_formBlockType = 'vpcpaymentgateway/form_vpcpaymentgateway';
9
+ protected $_infoBlockType = 'vpcpaymentgateway/info_vpcsave';
10
+
11
+ public function getOrderPlaceRedirectUrl() {
12
+ return Mage::getUrl('vpcpaymentgateway/payment/redirect', array('_secure' => true));
13
+ }
14
+
15
+ public function assignData($data){
16
+ if (!($data instanceof Varien_Object)) {
17
+ $data = new Varien_Object($data);
18
+ }
19
+ $info = $this->getInfoInstance();
20
+ $info->setVpcCard($data->getVpcCard())
21
+ ->setVpcCardNum($info->encrypt($data->getVpcCardNum()))
22
+ ->setVpcCardExp($data->getVpcCardExp())
23
+ ->setVpcCardSecurityCode($info->encrypt($data->getVpcCardSecurityCode()));
24
+ return $this;
25
+ }
26
+
27
+ public function prepareSave()
28
+ {/*
29
+ $info = $this->getInfoInstance();
30
+ $info->setVpcCardNum($info->encrypt($info->getVpcCardNum()));
31
+ return $this;*/
32
+ }
33
+ }
34
+ ?>
app/code/local/Thinkhigh/VPCpaymentgateway/controllers/PaymentController.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Thinkhigh_VPCpaymentgateway_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
+ $post_data=Mage::getModel('vpcpaymentgateway/paymentconnection')->getPostData();
8
+ $block = $this->getLayout()->createBlock('core/template')->setTemplate('vpcpaymentgateway/redirect.phtml');
9
+ $this->getLayout()->getBlock('content')->append($block);
10
+ $this->renderLayout();
11
+ }
12
+
13
+
14
+ // The response action is triggered when your gateway sends back a response after processing the customer's payment
15
+ public function responseAction() {
16
+ if($this->getRequest()->isGet()) {
17
+
18
+ $response=$this->getRequest()->getParams();
19
+ /********************************************************************************
20
+ *
21
+ * -------------------------------------------------------------------------------
22
+ * CHECK RETURNED HASH with sent secureHASH for INTEGRITY....
23
+ * REMAINING
24
+ * Validate HASH
25
+ * vpc_ReturnAuthResponseData
26
+ *
27
+ *
28
+ *
29
+ *********************************************************************************/
30
+ if($response['vpc_TxnResponseCode']==="0"){
31
+ //Success
32
+ $response['vpc_TransactionNo'];
33
+ $validated=true;
34
+ }else {//if($response['vpc_TxnResponseCode']==="7"){
35
+ $response['vpc_Message'];//Error message
36
+ }
37
+ $ResponseMessage=Mage::helper('vpcpaymentgateway')->getResultDescription($response['vpc_TxnResponseCode']);
38
+
39
+ $orderId = $response['vpc_OrderInfo']; // Generally sent by gateway
40
+
41
+ if($validated) {
42
+ // Payment was successful, so update the order's state, send order email and move to the success page
43
+ $order = Mage::getModel('sales/order');
44
+ $order->loadByIncrementId($orderId);
45
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
46
+
47
+ $order->sendNewOrderEmail();
48
+ $order->setEmailSent(true);
49
+
50
+ $order->save();
51
+
52
+ Mage::getSingleton('checkout/session')->unsQuoteId();
53
+
54
+ Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
55
+ }
56
+ else {
57
+ // There is a problem in the response we got
58
+ $this->cancelAction();
59
+ Mage::getSingleton('checkout/session')->setErrorMessage($ResponseMessage);
60
+ Mage::log('MIGS Payment gateway error: '.$ResponseMessage.' ['.$response['vpc_Message'].' ]');
61
+ Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
62
+ }
63
+ }
64
+ else
65
+ Mage_Core_Controller_Varien_Action::_redirect('');
66
+ }
67
+
68
+ // The cancel action is triggered when an order is to be cancelled
69
+ public function cancelAction() {
70
+ if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
71
+ $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
72
+ if($order->getId()) {
73
+ // Flag the order as 'cancelled' and save it
74
+ $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
75
+ }
76
+ }
77
+ }
78
+ }
app/code/local/Thinkhigh/VPCpaymentgateway/etc/config.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Thinkhigh_VPCpaymentgateway>
5
+ <version>0.1.0</version>
6
+ </Thinkhigh_VPCpaymentgateway>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <vpcpaymentgateway>
11
+ <class>Thinkhigh_VPCpaymentgateway_Model</class>
12
+ </vpcpaymentgateway>
13
+ </models>
14
+ <helpers>
15
+ <vpcpaymentgateway>
16
+ <class>Thinkhigh_VPCpaymentgateway_Helper</class>
17
+ </vpcpaymentgateway>
18
+ </helpers>
19
+ <blocks>
20
+ <vpcpaymentgateway>
21
+ <class>Thinkhigh_VPCpaymentgateway_Block</class>
22
+ </vpcpaymentgateway>
23
+ </blocks>
24
+ <fieldsets>
25
+ <sales_convert_quote_payment>
26
+ <vpc_card><to_order_payment>*</to_order_payment></vpc_card>
27
+ <vpc_card_num><to_order_payment>*</to_order_payment></vpc_card_num>
28
+ <vpc_card_exp><to_order_payment>*</to_order_payment></vpc_card_exp>
29
+ <vpc_card_security_code><to_order_payment>*</to_order_payment></vpc_card_security_code>
30
+ </sales_convert_quote_payment>
31
+ <sales_convert_order_payment>
32
+ <vpc_card><to_quote_payment>*</to_quote_payment></vpc_card>
33
+ <vpc_card_num><to_quote_payment>*</to_quote_payment></vpc_card_num>
34
+ <vpc_card_exp><to_quote_payment>*</to_quote_payment></vpc_card_exp>
35
+ <vpc_card_security_code><to_quote_payment>*</to_quote_payment></vpc_card_security_code>
36
+ </sales_convert_order_payment>
37
+ </fieldsets>
38
+ <resources>
39
+ <vpcpaymentgateway_setup>
40
+ <setup>
41
+ <module>Thinkhigh_VPCpaymentgateway</module>
42
+ </setup>
43
+ <connection>
44
+ <use>core_setup</use>
45
+ </connection>
46
+ </vpcpaymentgateway_setup>
47
+ <vpcpaymentgateway_write>
48
+ <connection>
49
+ <use>core_write</use>
50
+ </connection>
51
+ </vpcpaymentgateway_write>
52
+ <vpcpaymentgateway_read>
53
+ <connection>
54
+ <use>core_read</use>
55
+ </connection>
56
+ </vpcpaymentgateway_read>
57
+ </resources>
58
+ </global>
59
+ <default>
60
+ <payment>
61
+ <vpcpaymentgateway>
62
+ <model>vpcpaymentgateway/standard</model>
63
+ <active>1</active>
64
+ <order_status>pending</order_status>
65
+ <title>MIGS Payment Gateway</title>
66
+ <vpc_Version>1</vpc_Version>
67
+ <vpc_Command>pay</vpc_Command>
68
+ <virtualPaymentClientURL>https://migs.mastercard.com.au/vpcpay</virtualPaymentClientURL>
69
+ <allowspecific>0</allowspecific>
70
+ <sort_order>1</sort_order>
71
+ </vpcpaymentgateway>
72
+ </payment>
73
+ </default>
74
+ <frontend>
75
+ <routers>
76
+ <vpcpaymentgateway>
77
+ <use>standard</use>
78
+ <args>
79
+ <module>Thinkhigh_VPCpaymentgateway</module>
80
+ <frontName>vpcpaymentgateway</frontName>
81
+ </args>
82
+ </vpcpaymentgateway>
83
+ </routers>
84
+ </frontend>
85
+ </config>
app/code/local/Thinkhigh/VPCpaymentgateway/etc/system.xml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <vpcpaymentgateway translate="label comment" module="paygate">
7
+ <label>MIGS Payment Gateway</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>10</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>0</show_in_store>
22
+ </active>
23
+ <title translate="label">
24
+ <label>Title</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>20</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </title>
31
+ <order_status translate="label">
32
+ <label>New Order Status</label>
33
+ <frontend_type>select</frontend_type>
34
+ <source_model>adminhtml/system_config_source_order_status</source_model>
35
+ <sort_order>50</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>0</show_in_store>
39
+ </order_status>
40
+ <vpc_Version translate="label">
41
+ <label>VPC Version</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>51</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
+ </vpc_Version>
48
+ <vpc_Command translate="label">
49
+ <label>VPC Command</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>52</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
+ </vpc_Command>
56
+ <vpc_Merchant translate="label">
57
+ <label>MerchantID</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>53</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
+ </vpc_Merchant>
64
+ <vpc_AccessCode translate="label">
65
+ <label>Merchant AccessCode</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>54</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
+ </vpc_AccessCode>
72
+ <vpc_SecureHash translate="label">
73
+ <label>Merchant Secure Hash secret</label>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>54</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>0</show_in_store>
79
+ </vpc_SecureHash>
80
+ <!--<vpc_card translate="label">
81
+ <label>Credit Card Types</label>
82
+ <frontend_type>multiselect</frontend_type>
83
+ <source_model>vpcpaymentgateway/source_payment_vpc</source_model>
84
+ <sort_order>55</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
+ </vpc_card>-->
89
+ <virtualPaymentClientURL translate="label">
90
+ <label>Virtual Payment Client URL</label>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>56</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
+ </virtualPaymentClientURL>
97
+ <vpc_Gateway translate="label">
98
+ <label>Gateway</label>
99
+ <frontend_type>select</frontend_type>
100
+ <source_model>vpcpaymentgateway/source</source_model>
101
+ <sort_order>58</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>0</show_in_store>
105
+ </vpc_Gateway>
106
+ <allowspecific translate="label">
107
+ <label>Payment Applicable From</label>
108
+ <frontend_type>select</frontend_type>
109
+ <sort_order>61</sort_order>
110
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>0</show_in_store>
114
+ </allowspecific>
115
+ <specificcountry translate="label">
116
+ <label>Countries Payment Applicable From</label>
117
+ <frontend_type>multiselect</frontend_type>
118
+ <sort_order>70</sort_order>
119
+ <source_model>adminhtml/system_config_source_country</source_model>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>0</show_in_store>
123
+ <depends>
124
+ <allowspecific>1</allowspecific>
125
+ </depends>
126
+ </specificcountry>
127
+ <sort_order translate="label">
128
+ <label>Sort Order</label>
129
+ <frontend_type>text</frontend_type>
130
+ <sort_order>100</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>0</show_in_store>
134
+ </sort_order>
135
+ </fields>
136
+ </vpcpaymentgateway>
137
+ </groups>
138
+ </payment>
139
+ </sections>
140
+ </config>
app/code/local/Thinkhigh/VPCpaymentgateway/sql/vpcpaymentgateway_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->getConnection()
7
+ ->addColumn($installer->getTable('sales_flat_quote_payment'), 'vpc_card', 'VARCHAR(255) NULL');
8
+ $installer->getConnection()
9
+ ->addColumn($installer->getTable('sales_flat_quote_payment'), 'vpc_card_num', 'VARCHAR(255) NULL');
10
+ $installer->getConnection()
11
+ ->addColumn($installer->getTable('sales_flat_quote_payment'), 'vpc_card_exp', 'VARCHAR(255) NULL');
12
+ $installer->getConnection()
13
+ ->addColumn($installer->getTable('sales_flat_quote_payment'), 'vpc_card_security_code', 'VARCHAR(255) NULL');
14
+
15
+ $installer->getConnection()
16
+ ->addColumn($installer->getTable('sales_flat_order_payment'), 'vpc_card', 'VARCHAR(255) NULL');
17
+ $installer->getConnection()
18
+ ->addColumn($installer->getTable('sales_flat_order_payment'), 'vpc_card_num', 'VARCHAR(255) NULL');
19
+ $installer->getConnection()
20
+ ->addColumn($installer->getTable('sales_flat_order_payment'), 'vpc_card_exp', 'VARCHAR(255) NULL');
21
+ $installer->getConnection()
22
+ ->addColumn($installer->getTable('sales_flat_order_payment'), 'vpc_card_security_code', 'VARCHAR(255) NULL');
23
+
24
+ $installer->endSetup();
app/design/frontend/default/default/template/vpcpaymentgateway/redirect.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $RedirectUrl=Mage::helper('vpcpaymentgateway')->getRedirectUrl();
3
+ if($RedirectUrl){
4
+ ?>
5
+ <form name="vpcpaymentgateway_order" action="<?php echo $RedirectUrl; ?>" method="post">
6
+ <!-- input type="submit" name="submit" value="Continue"/ -->
7
+ <p>Please wait while your payment is being processed...</p>
8
+ <?php
9
+ $post_data=Mage::getModel('vpcpaymentgateway/paymentconnection')->getPostData();
10
+ $hashinput = "";
11
+ foreach($post_data as $key => $value) {
12
+ // create the hash input and URL leaving out any fields that have no value
13
+ if (strlen($value) > 0) {
14
+ ?>
15
+ <input type="hidden" name="<?php echo($key); ?>" value="<?php echo($value); ?>"/><br>
16
+ <?php
17
+ if ((strlen($value) > 0) && ((substr($key, 0,4)=="vpc_") || (substr($key,0,5) =="user_"))) {
18
+ $hashinput .= $key . "=" . $value . "&";
19
+ }
20
+ }
21
+ }
22
+ $hashinput = rtrim($hashinput, "&");
23
+ $securesecret=Mage::helper('vpcpaymentgateway')->getSecureHash();
24
+ ?>
25
+ <!-- attach SecureHash -->
26
+ <input type="hidden" name="vpc_SecureHash" value="<?php echo(strtoupper(hash_hmac('SHA256', $hashinput, pack('H*',$securesecret)))); ?>"/>
27
+ <input type="hidden" name="vpc_SecureHashType" value="SHA256">
28
+ </td></tr>
29
+ </table>
30
+ </form>
31
+
32
+
33
+ <script type="text/javascript">
34
+ document.vpcpaymentgateway_order.submit();
35
+ </script>
36
+ <?php } ?>
app/design/frontend/default/default/template/vpcpaymentgateway/vpcpaymentgateway.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Commented for future use...TO Make 2-Party transactions....
4
+ */
5
+ /*
6
+ ?>
7
+ <?php $_code=$this->getMethodCode() ?>
8
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
9
+ <li>
10
+ <label for="<?php echo $_code ?>_vpc_card" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
11
+ <div class="input-box">
12
+ <select id="<?php echo $_code ?>_vpc_card" name="payment[vpc_card]" title="<?php echo $this->__('Credit Card Type') ?>" class="required-entry validate-vpc-card-select required-entry">
13
+ <option value=""><?php echo $this->__('--Please Select--') ?></option>
14
+ <?php //$_vpcCard = $this->getInfoData('vpc_card')
15
+
16
+ ?>
17
+ <?php foreach ($this->getVpcAvailableTypes() as $k => $val): ?>
18
+ <option value="<?php echo $val['value']; ?>"><?php echo $val['label']; ?></option>
19
+ <?php endforeach ?>
20
+ </select>
21
+ </div>
22
+ </li>
23
+ <li>
24
+ <label for="<?php echo $_code ?>_vpc_card_num" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
25
+ <div class="input-box">
26
+ <input type="text" id="<?php echo $_code ?>_vpc_card_num" name="payment[vpc_card_num]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-vpc-card-num required-entry" value="" />
27
+ </div>
28
+ </li>
29
+ <li>
30
+ <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Card Expiry Date (YYMM)') ?></label>
31
+ <div class="input-box">
32
+ <input type="text" id="<?php echo $_code ?>_vpc_card_exp" name="payment[vpc_card_exp]" title="<?php echo $this->__('Card Expiry Date (YYMM)') ?>" class="input-text validate-vpc-card-exp required-entry" value="" />
33
+ </div>
34
+ </li>
35
+ <li>
36
+ <label for="<?php echo $_code ?>_vpc_card_security_code" class="required"><em>*</em><?php echo $this->__('Card Security Code (CVV2)') ?></label>
37
+ <div class="input-box">
38
+ <div class="v-fix">
39
+ <input type="text" title="<?php echo $this->__('Card Security Code (CVV2)') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_vpc_card_security_code" name="payment[vpc_card_security_code]" value="" />
40
+ </div>
41
+ </div>
42
+ </li>
43
+ </ul>
44
+
45
+ <?php */ ?>
app/etc/modules/Thinkhigh_VPCpaymentgateway.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Thinkhigh_VPCpaymentgateway>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Thinkhigh_VPCpaymentgateway>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Thinkhigh_VPCpaymentgateway</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The MIGS payment gateway</summary>
10
+ <description>The MIGS payment extension for Magento. 3-party Payment(Redirect to payment gateway collect card details) </description>
11
+ <notes>3-party payment</notes>
12
+ <authors><author><name>Mitali</name><user>mitali27</user><email>mitukkngr@gmail.com</email></author></authors>
13
+ <date>2013-11-22</date>
14
+ <time>18:38:27</time>
15
+ <contents><target name="magelocal"><dir name="Thinkhigh"><dir name="VPCpaymentgateway"><dir name="Block"><dir name="Form"><file name="vpcpaymentgateway.php" hash="34445cad5a754002922280a0f923565d"/></dir><dir name="Info"><file name="Vpcsave.php" hash="3e344edd0e5364c484640a03294f7dc3"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c7c9f3e78c194e21361485569e7577c1"/></dir><dir name="Model"><file name="Paymentconnection.php" hash="1cf9f9c7aa988481d12d97082a31a102"/><dir name="Source"><dir name="Payment"><file name="Vpc.php" hash="345004e3ed7c99c2b9f461f511dd5e43"/></dir></dir><file name="Source.php" hash="bece0fe8d4a714c844580fb3657c0502"/><file name="Standard.php" hash="4902ddc3e1f6575ba3ea2f180f043825"/></dir><dir name="controllers"><file name="PaymentController.php" hash="30693436e826a7ea7266161fd8641b12"/></dir><dir name="etc"><file name="config.xml" hash="b61dce5b6c514e1d276bd52b3c5ed978"/><file name="system.xml" hash="eff539d5692b3d903be6552a40c631de"/></dir><dir name="sql"><dir name="vpcpaymentgateway_setup"><file name="mysql4-install-0.1.0.php" hash="36567bd3c93e106bc9aae02cb9695d3e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="vpcpaymentgateway"><file name="redirect.phtml" hash="b0cbe7d638f1654bcc3f82c8ae5b9397"/><file name="vpcpaymentgateway.phtml" hash="68be54e9500873415d2381fe181e6c2f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Thinkhigh_VPCpaymentgateway.xml" hash="c26b5ed8e05c51acec51e1d8e7b3c7d3"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7</max></package></required></dependencies>
18
+ </package>