Version Notes
First stable release.
Download this release
Release Info
Developer | Patrick White |
Extension | Quantum_Gateway_ILF_API |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/Quantum/ILF/Block/Form.php +44 -0
- app/code/local/Quantum/ILF/Block/Iframe.php +34 -0
- app/code/local/Quantum/ILF/Helper/Data.php +174 -0
- app/code/local/Quantum/ILF/Model/Gateway.php +51 -0
- app/code/local/Quantum/ILF/Model/Gateway/Response.php +22 -0
- app/code/local/Quantum/ILF/Model/Resource/Gateway/Response.php +11 -0
- app/code/local/Quantum/ILF/Model/Resource/Setup.php +9 -0
- app/code/local/Quantum/ILF/controllers/Adminhtml/ILFController.php +214 -0
- app/code/local/Quantum/ILF/controllers/ResponseController.php +77 -0
- app/code/local/Quantum/ILF/etc/config.xml +150 -0
- app/code/local/Quantum/ILF/etc/system.xml +121 -0
- app/code/local/Quantum/ILF/sql/quantum_setup/install-0.1.0.php +51 -0
- app/design/frontend/base/default/layout/quantum.xml +17 -0
- app/design/frontend/base/default/template/quantum/ilf/iframe.phtml +10 -0
- app/design/frontend/base/default/template/quantum/ilf/info.phtml +7 -0
- app/etc/modules/Quantum_ILF.xml +17 -0
- js/quantum/quantum.js +35 -0
- package.xml +20 -0
app/code/local/Quantum/ILF/Block/Form.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* To change this template, choose Tools | Templates
|
5 |
+
* and open the template in the editor.
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
|
9 |
+
<?php
|
10 |
+
class Quantum_ILF_Block_Form extends Mage_Payment_Block_Form_Cc {
|
11 |
+
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->setTemplate('quantum/ilf/info.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
protected function _toHtml()
|
19 |
+
{
|
20 |
+
if ($this->getMethod()->getCode() != Mage::getSingleton('quantum_ilf/gateway')->getCode()) {
|
21 |
+
return null;
|
22 |
+
}
|
23 |
+
|
24 |
+
return parent::_toHtml();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Set method info
|
29 |
+
*
|
30 |
+
* @return Mage_Authorizenet_Block_Directpost_Form
|
31 |
+
*/
|
32 |
+
public function setMethodInfo()
|
33 |
+
{
|
34 |
+
$payment = Mage::getSingleton('checkout/type_onepage')
|
35 |
+
->getQuote()
|
36 |
+
->getPayment();
|
37 |
+
$this->setMethod($payment->getMethodInstance());
|
38 |
+
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
?>
|
app/code/local/Quantum/ILF/Block/Iframe.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* To change this template, choose Tools | Templates
|
5 |
+
* and open the template in the editor.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Description of Quantum_ILF_Block_Iframe
|
10 |
+
*
|
11 |
+
* @author packy
|
12 |
+
*/
|
13 |
+
class Quantum_ILF_Block_Iframe extends Mage_Payment_Block_Form {
|
14 |
+
//put your code here
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Render block HTML
|
18 |
+
* If method is not quantum - nothing to return
|
19 |
+
*
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
protected function _toHtml()
|
23 |
+
{
|
24 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
25 |
+
if ($quote->getPayment()->getData('method') != Mage::getSingleton('quantum_ilf/gateway')->getCode()) {
|
26 |
+
return null;
|
27 |
+
}
|
28 |
+
|
29 |
+
return parent::_toHtml();
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
?>
|
app/code/local/Quantum/ILF/Helper/Data.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Quantum_ILF_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _l($thing) {
|
7 |
+
Mage::log(Zend_Debug::dump($thing, null, false));
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Get an authentication token from Quantum
|
12 |
+
* @return string Authentication token, or "error" on failure
|
13 |
+
*/
|
14 |
+
public function authenticate() {
|
15 |
+
$random = mt_rand(1111111111,9999999999);
|
16 |
+
$h = Mage::helper('core'); $m = Mage::getModel('quantum_ilf/gateway');
|
17 |
+
|
18 |
+
$client = new Zend_Http_Client($m->getConfigData('quantum_auth_url'));
|
19 |
+
$client->setMethod(Zend_Http_Client::POST);
|
20 |
+
$client->setParameterPost('API_Username', $h->decrypt($m->getConfigData('api_username')));
|
21 |
+
$client->setParameterPost('API_Key', $h->decrypt($m->getConfigData('api_password')));
|
22 |
+
$client->setParameterPost('randval', $random);
|
23 |
+
$client->setParameterPost('lastip', Mage::helper('core/http')->getRemoteAddr());
|
24 |
+
$response = $client->request();
|
25 |
+
return $response == "error" ? null : $response->getBody();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Assemble an array with all the customer/ILF information
|
30 |
+
* @param Mage_Sales_Model_Quote $quote Magento quote
|
31 |
+
* @return array Customer/ILF information
|
32 |
+
*/
|
33 |
+
|
34 |
+
protected function _getParams($quote = null) {
|
35 |
+
$billing = $quote->getBillingAddress();
|
36 |
+
$shipping = $quote->getShippingAddress();
|
37 |
+
|
38 |
+
$params = array(
|
39 |
+
'FNAME' => $billing->getFirstname(),
|
40 |
+
'LNAME' => $billing->getLastname(),
|
41 |
+
'BADDR1' => implode(' ', $billing->getStreet()),
|
42 |
+
'BCITY' => $billing->getCity(),
|
43 |
+
'BSTATE' => $billing->getState(),
|
44 |
+
'BZIP1' => $billing->getPostcode(),
|
45 |
+
'BCOUNTRY' => $billing->getCountry(),
|
46 |
+
'phone' => $billing->getTelephone(),
|
47 |
+
'BCUST_EMAIL' => $billing->getEmail(),
|
48 |
+
'fax' => '',
|
49 |
+
'footer_email' => '',
|
50 |
+
'footer_receipt' => '',
|
51 |
+
'header_email' => '',
|
52 |
+
'page_heading' => '',
|
53 |
+
'payment_heading' => '',
|
54 |
+
'header_receipt' => '',
|
55 |
+
'CustomerID' => $quote->getCustomerID(),
|
56 |
+
'invoicen_num' => '',
|
57 |
+
'invoice_description' => '',
|
58 |
+
'override_email_customer' => 'email',
|
59 |
+
'override_trans_email' => 'merchant email',
|
60 |
+
'AddToVault' => '?',
|
61 |
+
'ID' => $quote->getReservedOrderId(),
|
62 |
+
'METHOD' => '',
|
63 |
+
'SADDR1' => implode(' ', $shipping->getStreet()),
|
64 |
+
'SCITY' => $shipping->getCity(),
|
65 |
+
'SSTATE' => $shipping->getState(),
|
66 |
+
'SZIP1' => $shipping->getPostcode(),
|
67 |
+
'SCOUNTRY' => $shipping->getCountry(),
|
68 |
+
'skip_shipping_info' => 'Y', //$m->getConfig('skip_shipping'),
|
69 |
+
'RID' => '',
|
70 |
+
'recur_times' => '',
|
71 |
+
'override_recur' => '',
|
72 |
+
'OverRideRecurDay' => '',
|
73 |
+
'Amount' => $quote->getGrandTotal()
|
74 |
+
);
|
75 |
+
|
76 |
+
return $params;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* URL encode all of the keys and values and return a GET query string
|
81 |
+
* @param array $params Quantum ILF information array
|
82 |
+
* @return string GET query string
|
83 |
+
*/
|
84 |
+
protected function _buildQueryString($params = null) {
|
85 |
+
if ($params === null) return null;
|
86 |
+
|
87 |
+
//Loop through each item and urlencode the key and values,
|
88 |
+
// Then mix them together
|
89 |
+
$z = array();
|
90 |
+
foreach ($params as $k => $v) {
|
91 |
+
array_push($z, urlencode($k)."=".urlencode($v));
|
92 |
+
}
|
93 |
+
|
94 |
+
return implode('&', $z); //join the strings together with & and return
|
95 |
+
}
|
96 |
+
|
97 |
+
public function getConfig($value) {
|
98 |
+
return Mage::getModel('quantum_ilf/gateway')->getConfigData($value);
|
99 |
+
}
|
100 |
+
|
101 |
+
public function buildVerificationHash($transID, $amount) {
|
102 |
+
$gw_login = $this->getConfig('gateway_login');
|
103 |
+
$secret = Mage::helper('core')->decrypt($this->getConfig('quantum_psk'));
|
104 |
+
|
105 |
+
$plaintext = $secret.$gw_login.$transID.$amount;
|
106 |
+
return md5($plaintext);
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Load an order by increment ID
|
111 |
+
* @param string $increment_id
|
112 |
+
* @return Mage_Sales_Model_Order
|
113 |
+
*/
|
114 |
+
public function loadOrderFromIncrementId($increment_id = null) {
|
115 |
+
if(!$increment_id) { return null; }
|
116 |
+
return Mage::getModel("sales/order")->load($increment_id, 'increment_id');
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get a reserved order ID for a quote if one doesn't exist
|
121 |
+
* @param Mage_Sales_Model_Quote $quote
|
122 |
+
* @return string
|
123 |
+
*/
|
124 |
+
public function safeOrderId($quote = null) {
|
125 |
+
if(!$quote->getReservedOrderId()) {
|
126 |
+
$quote->reserveOrderId();
|
127 |
+
}
|
128 |
+
return $quote->getReservedOrderId();
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get a reserved order ID for a quote if one doesn't exist
|
133 |
+
* @param Mage_Sales_Model_Quote $quote
|
134 |
+
* @return Quantum_ILF_Helper_Data
|
135 |
+
*/
|
136 |
+
public function _startQuoteTracking($quote = null) {
|
137 |
+
$new_response = Mage::getModel("quantum_ilf/gateway_response")->load($quote->getReservedOrderId(), 'order_id');
|
138 |
+
|
139 |
+
$new_response->setAmount($quote->getGrandTotal());
|
140 |
+
$new_response->setOrderId($quote->getReservedOrderId());
|
141 |
+
$new_response->save();
|
142 |
+
return $this;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Get the URL to the ILF frame for this transaction
|
147 |
+
* @param Mage_Sales_Order_Quote $quote
|
148 |
+
* @return string src URL to the ILF iframe
|
149 |
+
*/
|
150 |
+
public function getIframeUrl($quote = null) {
|
151 |
+
if ($quote === null) {
|
152 |
+
Mage::throwException("Received a null quote");
|
153 |
+
return null;
|
154 |
+
}
|
155 |
+
|
156 |
+
$authkey = $this->authenticate();
|
157 |
+
if ($authkey != "error") {
|
158 |
+
$quote->reserveOrderId()->save();
|
159 |
+
|
160 |
+
$params = $this->_buildQueryString($this->_getParams($quote));
|
161 |
+
|
162 |
+
$m = Mage::getModel('quantum_ilf/gateway');
|
163 |
+
$quantum_url = $m->getConfigData('quantum_url');
|
164 |
+
$ip = Mage::helper('core/http')->getRemoteAddr();
|
165 |
+
|
166 |
+
//Authenticated, send Iframe request to QGW
|
167 |
+
$iframe_src = $quantum_url."?k=$authkey&ip=$ip&$params";
|
168 |
+
$this->_startQuoteTracking($quote);
|
169 |
+
return $iframe_src;
|
170 |
+
}
|
171 |
+
|
172 |
+
return null; //Something went awry.
|
173 |
+
}
|
174 |
+
}
|
app/code/local/Quantum/ILF/Model/Gateway.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Quantum_ILF_Model_Gateway extends Mage_Payment_Model_Method_Abstract
|
4 |
+
{
|
5 |
+
protected $_code = 'quantum_ilf';
|
6 |
+
protected $_isGateway = true;
|
7 |
+
protected $_canAuthorize = true;
|
8 |
+
protected $_canCapture = true;
|
9 |
+
protected $_canCapturePartial = false;
|
10 |
+
protected $_canRefund = true;
|
11 |
+
protected $_canVoid = true;
|
12 |
+
protected $_canUseInternal = true;
|
13 |
+
protected $_canUseCheckout = true;
|
14 |
+
protected $_canUseForMultishipping = false;
|
15 |
+
protected $_formBlockType = 'quantum_ilf/form';
|
16 |
+
protected $_infoBlockType = 'payment/info';
|
17 |
+
|
18 |
+
public function isAvailable($quote = null) {
|
19 |
+
return parent::isAvailable($quote);
|
20 |
+
}
|
21 |
+
|
22 |
+
public function _construct()
|
23 |
+
{
|
24 |
+
parent::_construct();
|
25 |
+
$this->_init('quantum_ilf/gateway');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Send capture request to gateway
|
30 |
+
*
|
31 |
+
* @param Varien_Object $payment
|
32 |
+
* @param decimal $amount
|
33 |
+
* @return Quantum_ILF_Model_Gateway
|
34 |
+
* @throws Mage_Core_Exception
|
35 |
+
*/
|
36 |
+
public function capture(Varien_Object $payment, $amount) {
|
37 |
+
/* @var $gw_response Quantum_ILF_Model_Gateway_Response */
|
38 |
+
$gw_response = Mage::getModel('quantum_ilf/gateway_response')->load($payment->getOrder()->getIncrementId(), 'order_id');
|
39 |
+
|
40 |
+
if($gw_response->getResult() != "DECLINED")
|
41 |
+
Mage::throwException("This order was placed, but the card was not approved. Reason: ".$gw_response->getDeclineReason());
|
42 |
+
|
43 |
+
if($gw_response->getAmount() != $amount)
|
44 |
+
Mage::throwException("The amount being captured is different than the amount that was approved. ".$gw_response->getAmount()."was authorized.");
|
45 |
+
|
46 |
+
if($gw_response->getResult() == "APPROVED")
|
47 |
+
return $this;
|
48 |
+
|
49 |
+
Mage::throwException("Unknown auth result encountered");
|
50 |
+
}
|
51 |
+
}
|
app/code/local/Quantum/ILF/Model/Gateway/Response.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Quantum_ILF_Model_Gateway_Response extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @method string getResponseId()
|
7 |
+
* @method string getTransactionId()
|
8 |
+
* @method Quantum_ILF_Model_Gateway_Response setTransactionId(string $txid)
|
9 |
+
* @method string getOrderId()
|
10 |
+
* @method Quantum_ILF_Model_Gateway_Response setOrderId(string $orderid)
|
11 |
+
* @method string getResult()
|
12 |
+
* @method Quantum_ILF_Model_Gateway_Response setResult(string $result)
|
13 |
+
* @method string getDeclineReason()
|
14 |
+
* @method Quantum_ILF_Model_Gateway_Response setDeclineReason(string $reason)
|
15 |
+
* @method string getErrorCode()
|
16 |
+
* @method Quantum_ILF_Model_Gateway_Response setErrorCode(string $errorcode)
|
17 |
+
*/
|
18 |
+
|
19 |
+
public function _construct() {
|
20 |
+
$this->_init("quantum_ilf/gateway_response");
|
21 |
+
}
|
22 |
+
}
|
app/code/local/Quantum/ILF/Model/Resource/Gateway/Response.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Quantum_ILF_Model_Resource_Gateway_Response extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
$this->_init('quantum_ilf/gateway_response', 'response_id');
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
11 |
+
?>
|
app/code/local/Quantum/ILF/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Quantum_ILF_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
4 |
+
{
|
5 |
+
public function _construct() {
|
6 |
+
$this->_init("quantum_ilf/gateway_response", "response_id");
|
7 |
+
}
|
8 |
+
}
|
9 |
+
?>
|
app/code/local/Quantum/ILF/controllers/Adminhtml/ILFController.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Quantum_ILF_Adminhtml_ILFController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('ilf/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('ilf/ilf')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('ilf_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('ilf/items');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('ilf/adminhtml_ilf_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('ilf/adminhtml_ilf_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ilf')->__('Item does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($data = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$data['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
$model = Mage::getModel('ilf/ilf');
|
85 |
+
$model->setData($data)
|
86 |
+
->setId($this->getRequest()->getParam('id'));
|
87 |
+
|
88 |
+
try {
|
89 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
90 |
+
$model->setCreatedTime(now())
|
91 |
+
->setUpdateTime(now());
|
92 |
+
} else {
|
93 |
+
$model->setUpdateTime(now());
|
94 |
+
}
|
95 |
+
|
96 |
+
$model->save();
|
97 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ilf')->__('Item was successfully saved'));
|
98 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
99 |
+
|
100 |
+
if ($this->getRequest()->getParam('back')) {
|
101 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
$this->_redirect('*/*/');
|
105 |
+
return;
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
108 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
109 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ilf')->__('Unable to find item to save'));
|
114 |
+
$this->_redirect('*/*/');
|
115 |
+
}
|
116 |
+
|
117 |
+
public function deleteAction() {
|
118 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
119 |
+
try {
|
120 |
+
$model = Mage::getModel('ilf/ilf');
|
121 |
+
|
122 |
+
$model->setId($this->getRequest()->getParam('id'))
|
123 |
+
->delete();
|
124 |
+
|
125 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
} catch (Exception $e) {
|
128 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
129 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->_redirect('*/*/');
|
133 |
+
}
|
134 |
+
|
135 |
+
public function massDeleteAction() {
|
136 |
+
$ilfIds = $this->getRequest()->getParam('ilf');
|
137 |
+
if(!is_array($ilfIds)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
139 |
+
} else {
|
140 |
+
try {
|
141 |
+
foreach ($ilfIds as $ilfId) {
|
142 |
+
$ilf = Mage::getModel('ilf/ilf')->load($ilfId);
|
143 |
+
$ilf->delete();
|
144 |
+
}
|
145 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
146 |
+
Mage::helper('adminhtml')->__(
|
147 |
+
'Total of %d record(s) were successfully deleted', count($ilfIds)
|
148 |
+
)
|
149 |
+
);
|
150 |
+
} catch (Exception $e) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
152 |
+
}
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/index');
|
155 |
+
}
|
156 |
+
|
157 |
+
public function massStatusAction()
|
158 |
+
{
|
159 |
+
$ilfIds = $this->getRequest()->getParam('ilf');
|
160 |
+
if(!is_array($ilfIds)) {
|
161 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
162 |
+
} else {
|
163 |
+
try {
|
164 |
+
foreach ($ilfIds as $ilfId) {
|
165 |
+
$ilf = Mage::getSingleton('ilf/ilf')
|
166 |
+
->load($ilfId)
|
167 |
+
->setStatus($this->getRequest()->getParam('status'))
|
168 |
+
->setIsMassupdate(true)
|
169 |
+
->save();
|
170 |
+
}
|
171 |
+
$this->_getSession()->addSuccess(
|
172 |
+
$this->__('Total of %d record(s) were successfully updated', count($ilfIds))
|
173 |
+
);
|
174 |
+
} catch (Exception $e) {
|
175 |
+
$this->_getSession()->addError($e->getMessage());
|
176 |
+
}
|
177 |
+
}
|
178 |
+
$this->_redirect('*/*/index');
|
179 |
+
}
|
180 |
+
|
181 |
+
public function exportCsvAction()
|
182 |
+
{
|
183 |
+
$fileName = 'ilf.csv';
|
184 |
+
$content = $this->getLayout()->createBlock('ilf/adminhtml_ilf_grid')
|
185 |
+
->getCsv();
|
186 |
+
|
187 |
+
$this->_sendUploadResponse($fileName, $content);
|
188 |
+
}
|
189 |
+
|
190 |
+
public function exportXmlAction()
|
191 |
+
{
|
192 |
+
$fileName = 'ilf.xml';
|
193 |
+
$content = $this->getLayout()->createBlock('ilf/adminhtml_ilf_grid')
|
194 |
+
->getXml();
|
195 |
+
|
196 |
+
$this->_sendUploadResponse($fileName, $content);
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
200 |
+
{
|
201 |
+
$response = $this->getResponse();
|
202 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
203 |
+
$response->setHeader('Pragma', 'public', true);
|
204 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
205 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
206 |
+
$response->setHeader('Last-Modified', date('r'));
|
207 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
208 |
+
$response->setHeader('Content-Length', strlen($content));
|
209 |
+
$response->setHeader('Content-type', $contentType);
|
210 |
+
$response->setBody($content);
|
211 |
+
$response->sendResponse();
|
212 |
+
die;
|
213 |
+
}
|
214 |
+
}
|
app/code/local/Quantum/ILF/controllers/ResponseController.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Quantum_ILF_ResponseController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function pollAction() {
|
5 |
+
$checkout = Mage::getSingleton('checkout/session');
|
6 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
7 |
+
$quote = $checkout->getQuote();
|
8 |
+
$order_id = $quote->getReservedOrderId();
|
9 |
+
|
10 |
+
$poll_timeout = Mage::getModel('quantum_ilf/gateway')->getConfigData('poll_interval');
|
11 |
+
|
12 |
+
$result_code = null;
|
13 |
+
for($i=0; $i < $poll_timeout; $i++) {
|
14 |
+
$gw_response = Mage::getModel('quantum_ilf/gateway_response')->load($order_id, 'order_id');
|
15 |
+
$result_code = $gw_response->getResult();
|
16 |
+
if($result_code) {
|
17 |
+
break; // Got a result, break out
|
18 |
+
} else {
|
19 |
+
sleep(1); //No result, try again in a second
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
// TODO: Delete the declined entry so as not to DoS the database
|
24 |
+
|
25 |
+
$result = array('result' => $result_code); //result code will either be null, approve or decline
|
26 |
+
|
27 |
+
$response = $this->getResponse();
|
28 |
+
$response->setHeader("Content-Type", "application/json");
|
29 |
+
$response->setBody(Mage::helper('core')->jsonEncode($result));
|
30 |
+
}
|
31 |
+
|
32 |
+
public function indexAction()
|
33 |
+
{
|
34 |
+
$req = $this->getRequest();
|
35 |
+
|
36 |
+
//Nab the stuff from the GET query
|
37 |
+
$order_id = $req->getParam('ID');
|
38 |
+
$result = $req->getParam('trans_result');
|
39 |
+
$txid = $req->getParam('transID');
|
40 |
+
$amount = $req->getParam('Amount');
|
41 |
+
$gw_hash = $req->getParam('md5_hash');
|
42 |
+
|
43 |
+
if($result == "DECLINED") {
|
44 |
+
$reason = $req->getParam('decline_reason');
|
45 |
+
$error_code = $req->getParam('errorcode');
|
46 |
+
}
|
47 |
+
|
48 |
+
$r = Mage::getModel("quantum_ilf/gateway_response")->load($order_id, 'order_id');
|
49 |
+
if(!$r->getData()) { //If we can't find the response, we're done
|
50 |
+
echo "Unable to locate response";
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
|
54 |
+
//Validate amounts and authenticator data
|
55 |
+
if($amount != $r->getAmount()) {
|
56 |
+
echo "Invalid amount";
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
|
60 |
+
if($gw_hash != Mage::helper('quantum_ilf')->buildVerificationHash($txid, $amount) ) {
|
61 |
+
echo "Incorrect hash";
|
62 |
+
return;
|
63 |
+
}
|
64 |
+
|
65 |
+
$r->setResult( $result );
|
66 |
+
$r->setTransactionId( $txid );
|
67 |
+
if ($result=="DECLINED") {
|
68 |
+
//Card was declined, add reason and code.
|
69 |
+
$r->setDeclineReason($reason);
|
70 |
+
$r->setErrorCode($error_code);
|
71 |
+
}
|
72 |
+
|
73 |
+
$r->save();
|
74 |
+
|
75 |
+
echo "OK";
|
76 |
+
}
|
77 |
+
}
|
app/code/local/Quantum/ILF/etc/config.xml
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Quantum
|
5 |
+
* @package Quantum_ILF
|
6 |
+
* @author Patrick White
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Quantum_ILF>
|
13 |
+
<version>0.1.0</version>
|
14 |
+
</Quantum_ILF>
|
15 |
+
</modules>
|
16 |
+
<frontend>
|
17 |
+
<routers>
|
18 |
+
<quantum>
|
19 |
+
<use>standard</use>
|
20 |
+
<args>
|
21 |
+
<module>Quantum_ILF</module>
|
22 |
+
<frontName>quantum</frontName>
|
23 |
+
</args>
|
24 |
+
</quantum>
|
25 |
+
</routers>
|
26 |
+
<layout>
|
27 |
+
<updates>
|
28 |
+
<quantum>
|
29 |
+
<file>quantum.xml</file>
|
30 |
+
</quantum>
|
31 |
+
</updates>
|
32 |
+
</layout>
|
33 |
+
</frontend>
|
34 |
+
|
35 |
+
<default>
|
36 |
+
<payment>
|
37 |
+
<quantum_ilf>
|
38 |
+
<active>1</active>
|
39 |
+
<title>Credit Card</title>
|
40 |
+
<model>quantum_ilf/gateway</model>
|
41 |
+
<order_status>pending</order_status>
|
42 |
+
<quantum_auth_url>https://secure.quantumgateway.com/cgi/ilf_authenticate.php</quantum_auth_url>
|
43 |
+
<quantum_url>https://secure.quantumgateway.com/cgi/ilf.php</quantum_url>
|
44 |
+
<quantum_iframe_style>width:100%; height:410px; border:none;</quantum_iframe_style>
|
45 |
+
<title>Credit Card (Quantum Gateway)</title>
|
46 |
+
<poll_interval>10</poll_interval>
|
47 |
+
<cctypes>AE,VI,MC,DI</cctypes>
|
48 |
+
<payment_action>authorize</payment_action>
|
49 |
+
<allowspecific>0</allowspecific>
|
50 |
+
</quantum_ilf>
|
51 |
+
</payment>
|
52 |
+
</default>
|
53 |
+
|
54 |
+
<!--
|
55 |
+
<admin>
|
56 |
+
<routers>
|
57 |
+
<ilf>
|
58 |
+
<use>admin</use>
|
59 |
+
<args>
|
60 |
+
<module>Quantum_ILF</module>
|
61 |
+
<frontName>ilf</frontName>
|
62 |
+
</args>
|
63 |
+
</ilf>
|
64 |
+
</routers>
|
65 |
+
</admin>
|
66 |
+
<adminhtml>
|
67 |
+
<menu>
|
68 |
+
<ilf module="ilf">
|
69 |
+
<title>ILF</title>
|
70 |
+
<sort_order>71</sort_order>
|
71 |
+
<children>
|
72 |
+
<items module="ilf">
|
73 |
+
<title>Manage Items</title>
|
74 |
+
<sort_order>0</sort_order>
|
75 |
+
<action>ilf/adminhtml_ilf</action>
|
76 |
+
</items>
|
77 |
+
</children>
|
78 |
+
</ilf>
|
79 |
+
</menu>
|
80 |
+
<acl>
|
81 |
+
<resources>
|
82 |
+
<all>
|
83 |
+
<title>Allow Everything</title>
|
84 |
+
</all>
|
85 |
+
<admin>
|
86 |
+
<children>
|
87 |
+
<Quantum_ILF>
|
88 |
+
<title>ILF Module</title>
|
89 |
+
<sort_order>10</sort_order>
|
90 |
+
</Quantum_ILF>
|
91 |
+
</children>
|
92 |
+
</admin>
|
93 |
+
</resources>
|
94 |
+
</acl>
|
95 |
+
<layout>
|
96 |
+
<updates>
|
97 |
+
<ilf>
|
98 |
+
<file>ilf.xml</file>
|
99 |
+
</ilf>
|
100 |
+
</updates>
|
101 |
+
</layout>
|
102 |
+
</adminhtml> -->
|
103 |
+
<global>
|
104 |
+
<models>
|
105 |
+
<quantum_ilf>
|
106 |
+
<class>Quantum_ILF_Model</class>
|
107 |
+
<resourceModel>quantum_ilf_resource</resourceModel>
|
108 |
+
</quantum_ilf>
|
109 |
+
<quantum_ilf_resource>
|
110 |
+
<class>Quantum_ILF_Model_Resource</class>
|
111 |
+
<entities>
|
112 |
+
<gateway_response>
|
113 |
+
<table>quantum_ilf_gateway_response</table>
|
114 |
+
</gateway_response>
|
115 |
+
</entities>
|
116 |
+
</quantum_ilf_resource>
|
117 |
+
</models>
|
118 |
+
<resources>
|
119 |
+
<quantum_setup>
|
120 |
+
<setup>
|
121 |
+
<module>Quantum_ILF</module>
|
122 |
+
<class>Quantum_ILF_Model_Resource_Setup</class>
|
123 |
+
</setup>
|
124 |
+
<connection>
|
125 |
+
<use>core_setup</use>
|
126 |
+
</connection>
|
127 |
+
</quantum_setup>
|
128 |
+
<quantum_write>
|
129 |
+
<connection>
|
130 |
+
<use>core_write</use>
|
131 |
+
</connection>
|
132 |
+
</quantum_write>
|
133 |
+
<quantum_read>
|
134 |
+
<connection>
|
135 |
+
<use>core_read</use>
|
136 |
+
</connection>
|
137 |
+
</quantum_read>
|
138 |
+
</resources>
|
139 |
+
<blocks>
|
140 |
+
<quantum_ilf>
|
141 |
+
<class>Quantum_ILF_Block</class>
|
142 |
+
</quantum_ilf>
|
143 |
+
</blocks>
|
144 |
+
<helpers>
|
145 |
+
<quantum_ilf>
|
146 |
+
<class>Quantum_ILF_Helper</class>
|
147 |
+
</quantum_ilf>
|
148 |
+
</helpers>
|
149 |
+
</global>
|
150 |
+
</config>
|
app/code/local/Quantum/ILF/etc/system.xml
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<sections>
|
5 |
+
<payment>
|
6 |
+
<groups>
|
7 |
+
<quantum_ilf translate="label" module="quantum_ilf">
|
8 |
+
<label>Quantum Gateway Inline Frame</label>
|
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>10</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 |
+
|
23 |
+
<order_status translate="label">
|
24 |
+
<label>New order status</label>
|
25 |
+
<frontend_type>select</frontend_type>
|
26 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
27 |
+
<sort_order>30</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>0</show_in_store>
|
31 |
+
</order_status>
|
32 |
+
|
33 |
+
<title translate="label">
|
34 |
+
<label>Title</label>
|
35 |
+
<fronted_type>text</fronted_type>
|
36 |
+
<sort_order>40</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>0</show_in_store>
|
40 |
+
</title>
|
41 |
+
|
42 |
+
<gateway_login translate="label">
|
43 |
+
<label>Quantum Gateway Login</label>
|
44 |
+
<frontend_type>text</frontend_type>
|
45 |
+
<sort_order>40</sort_order>
|
46 |
+
<show_in_default>1</show_in_default>
|
47 |
+
<show_in_website>1</show_in_website>
|
48 |
+
<show_in_store>0</show_in_store>
|
49 |
+
</gateway_login>
|
50 |
+
|
51 |
+
<quantum_url translate="label">
|
52 |
+
<label>Inline Frames URL</label>
|
53 |
+
<frontend_type>text</frontend_type>
|
54 |
+
<sort_order>40</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>0</show_in_store>
|
58 |
+
</quantum_url>
|
59 |
+
|
60 |
+
<quantum_auth_url translate="label">
|
61 |
+
<label>Inline Frames Authentication URL</label>
|
62 |
+
<frontend_type>text</frontend_type>
|
63 |
+
<sort_order>40</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>0</show_in_store>
|
67 |
+
</quantum_auth_url>
|
68 |
+
|
69 |
+
<api_username translate="label">
|
70 |
+
<label>API Username</label>
|
71 |
+
<frontend_type>obscure</frontend_type>
|
72 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
73 |
+
<sort_order>50</sort_order>
|
74 |
+
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>0</show_in_store>
|
77 |
+
</api_username>
|
78 |
+
|
79 |
+
<api_password translate="label">
|
80 |
+
<label>API Password</label>
|
81 |
+
<frontend_type>obscure</frontend_type>
|
82 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
83 |
+
<sort_order>60</sort_order>
|
84 |
+
<show_in_default>1</show_in_default>
|
85 |
+
<show_in_website>1</show_in_website>
|
86 |
+
<show_in_store>0</show_in_store>
|
87 |
+
</api_password>
|
88 |
+
|
89 |
+
<quantum_psk translate="label">
|
90 |
+
<label>Quantum MD5-Hash Value</label>
|
91 |
+
<frontend_type>obscure</frontend_type>
|
92 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
93 |
+
<sort_order>61</sort_order>
|
94 |
+
<show_in_default>1</show_in_default>
|
95 |
+
<show_in_website>1</show_in_website>
|
96 |
+
<show_in_store>0</show_in_store>
|
97 |
+
</quantum_psk>
|
98 |
+
|
99 |
+
<poll_interval translate="label">
|
100 |
+
<label>Checkout Polling Interval</label>
|
101 |
+
<frontend_type>text</frontend_type>
|
102 |
+
<sort_order>70</sort_order>
|
103 |
+
<show_in_default>1</show_in_default>
|
104 |
+
<show_in_website>1</show_in_website>
|
105 |
+
<show_in_store>0</show_in_store>
|
106 |
+
</poll_interval>
|
107 |
+
|
108 |
+
<quantum_iframe_style translate="label">
|
109 |
+
<label>Iframe Style (CSS)</label>
|
110 |
+
<frontend_type>text</frontend_type>
|
111 |
+
<sort_order>80</sort_order>
|
112 |
+
<show_in_default>1</show_in_default>
|
113 |
+
<show_in_website>1</show_in_website>
|
114 |
+
<show_in_store>0</show_in_store>
|
115 |
+
</quantum_iframe_style>
|
116 |
+
</fields>
|
117 |
+
</quantum_ilf>
|
118 |
+
</groups>
|
119 |
+
</payment>
|
120 |
+
</sections>
|
121 |
+
</config>
|
app/code/local/Quantum/ILF/sql/quantum_setup/install-0.1.0.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/** @var $installer Mage_Sales_Model_Entity_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Create table 'sales/order'
|
9 |
+
*/
|
10 |
+
$table = $installer->getConnection()
|
11 |
+
->newTable($installer->getTable('quantum_ilf/gateway_response'))
|
12 |
+
->addColumn('response_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
13 |
+
'identity' => true,
|
14 |
+
'unsigned' => true,
|
15 |
+
'nullable' => false,
|
16 |
+
'primary' => true,
|
17 |
+
), 'Response Id')
|
18 |
+
->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
19 |
+
), 'Transaction ID')
|
20 |
+
->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
21 |
+
), 'Order ID')
|
22 |
+
->addColumn('result', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
23 |
+
), 'Result')
|
24 |
+
->addColumn('decline_reason', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
25 |
+
), 'Decline Reason')
|
26 |
+
->addColumn('error_code', Varien_Db_Ddl_Table::TYPE_TEXT, 50, array(
|
27 |
+
), 'Error Code')
|
28 |
+
->addcolumn('amount', Varien_Db_Ddl_Table::TYPE_CHAR, 10, array(
|
29 |
+
), 'Amount');
|
30 |
+
|
31 |
+
$installer->getConnection()->createTable($table);
|
32 |
+
|
33 |
+
/*
|
34 |
+
$installer->run("
|
35 |
+
|
36 |
+
-- DROP TABLE IF EXISTS {$this->getTable('quantum_ilf/gateway_response')};
|
37 |
+
CREATE TABLE {$this->getTable('quantum_ilf_gateway_response')} (
|
38 |
+
`ilf_id` int(11) unsigned NOT NULL auto_increment,
|
39 |
+
`title` varchar(255) NOT NULL default '',
|
40 |
+
`filename` varchar(255) NOT NULL default '',
|
41 |
+
`content` text NOT NULL default '',
|
42 |
+
`status` smallint(6) NOT NULL default '0',
|
43 |
+
`created_time` datetime NULL,
|
44 |
+
`update_time` datetime NULL,
|
45 |
+
PRIMARY KEY (`ilf_id`)
|
46 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
47 |
+
|
48 |
+
");
|
49 |
+
*/
|
50 |
+
|
51 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/quantum.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
|
3 |
+
<layout version="0.1.0">
|
4 |
+
<checkout_onepage_index>
|
5 |
+
<reference name="head">
|
6 |
+
<action method="addJs"><file>quantum/quantum.js</file></action>
|
7 |
+
</reference>
|
8 |
+
</checkout_onepage_index>
|
9 |
+
<checkout_onepage_review>
|
10 |
+
<!-- <remove name="checkout.onepage.review.button"/> -->
|
11 |
+
<reference name="checkout.onepage.review.info.items.after">
|
12 |
+
<block type="quantum_ilf/iframe" name="payment.form.quantum.ilf" template="quantum/ilf/iframe.phtml">
|
13 |
+
<action method="setMethodInfo"></action>
|
14 |
+
</block>
|
15 |
+
</reference>
|
16 |
+
</checkout_onepage_review>
|
17 |
+
</layout>
|
app/design/frontend/base/default/template/quantum/ilf/iframe.phtml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$q = Mage::getSingleton('checkout/session')->getQuote();
|
3 |
+
$ilf_url = Mage::helper('quantum_ilf')->getIframeUrl($q);
|
4 |
+
$ilf_style = Mage::getModel('quantum_ilf/gateway')->getConfigData('quantum_iframe_style');
|
5 |
+
$polling_url = Mage::getURL('quantum/response/poll');
|
6 |
+
?>
|
7 |
+
|
8 |
+
<div class="buttons-set">
|
9 |
+
<iframe style="<?php echo $ilf_style; ?>" onLoad='quantum_iframe_loaded("<?php echo $polling_url; ?>");' src="<?php echo $ilf_url; ?>"></iframe>
|
10 |
+
</div>
|
app/design/frontend/base/default/template/quantum/ilf/info.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none">
|
4 |
+
<li>
|
5 |
+
<?php echo $this->__('You will be required to enter your payment details before you place an order.') ?>
|
6 |
+
</li>
|
7 |
+
</ul>
|
app/etc/modules/Quantum_ILF.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Quantum
|
5 |
+
* @package Quantum_ILF
|
6 |
+
* @author ModuleCreator
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Quantum_ILF>
|
13 |
+
<active>true</active>
|
14 |
+
<codePool>local</codePool>
|
15 |
+
</Quantum_ILF>
|
16 |
+
</modules>
|
17 |
+
</config>
|
js/quantum/quantum.js
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* To change this template, choose Tools | Templates
|
3 |
+
* and open the template in the editor.
|
4 |
+
*/
|
5 |
+
|
6 |
+
function quantum_iframe_loaded(url) {
|
7 |
+
$$('#review-buttons-container .btn-checkout')[0].remove();
|
8 |
+
|
9 |
+
quantum_start_polling(url);
|
10 |
+
}
|
11 |
+
|
12 |
+
function quantum_start_polling(url) {
|
13 |
+
new Ajax.Request(url, {
|
14 |
+
onSuccess: function(response) {
|
15 |
+
//I know what you're thinking: "CLIENT SIDE APPROVAL CHECKING?!?"
|
16 |
+
//Relax, it's checked on the server side, too, and we don't
|
17 |
+
//allow orders to process if it wasn't approved by the gateway
|
18 |
+
//Yes, it will place an order, but it won't proceed beyond that.
|
19 |
+
//Nuisance at worst.
|
20 |
+
|
21 |
+
var result = response.responseJSON['result'];
|
22 |
+
switch(result) {
|
23 |
+
case "APPROVED":
|
24 |
+
review.save();
|
25 |
+
break;
|
26 |
+
case "DECLINED":
|
27 |
+
//do something for declined
|
28 |
+
break;
|
29 |
+
default:
|
30 |
+
//this is our no-response-yet land, start polling again.
|
31 |
+
quantum_start_polling(url);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
});
|
35 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Quantum_Gateway_ILF_API</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Quantum Gateway ILF payment method</summary>
|
10 |
+
<description>Adds support for handling credit card transactions via Quantum Gateway using the ILF API.
|
11 |
+

|
12 |
+
The iframe appears in the final step of the checkout process and removes the "Place Order" button in favor of the checkout button of the iframe.</description>
|
13 |
+
<notes>First stable release.</notes>
|
14 |
+
<authors><author><name>Patrick White</name><user>cdgpatrick</user><email>patrick.white@cdgcommerce.com</email></author></authors>
|
15 |
+
<date>2012-05-10</date>
|
16 |
+
<time>19:42:31</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Quantum"><dir name="ILF"><dir name="Block"><file name="Form.php" hash="5a05205072e643ae81fa1cc8368ec389"/><file name="Iframe.php" hash="dda86a5277550790e255e3e686062595"/></dir><dir name="Helper"><file name="Data.php" hash="bc96ef91d71d4f4b6592603165db6ca9"/></dir><dir name="Model"><dir name="Gateway"><file name="Response.php" hash="18efafbd516f843c19cd8b0c1e190d55"/></dir><file name="Gateway.php" hash="d1727df9f574cb2493828b0fe57f97ff"/><dir name="Resource"><dir name="Gateway"><file name="Response.php" hash="65b4413d650f1b0e4753c441e38a4b59"/></dir><file name="Setup.php" hash="4a7d5ef125b603cd0d5b19112aa1a991"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ILFController.php" hash="b6869f7e23035f7147d87c62d151807b"/></dir><file name="ResponseController.php" hash="aa82c8dceae5c21630e6a611b2c181b2"/></dir><dir name="etc"><file name="config.xml" hash="4edc0a7c8b0e6e735e49041b635ce4db"/><file name="system.xml" hash="833b704c04b6f1931e035d6097ad91e0"/></dir><dir name="sql"><dir name="quantum_setup"><file name="install-0.1.0.php" hash="d48d5696bd9767154a7d6cb807c42dc4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="quantum.xml" hash="755d2b91a302f768bc5c7d57285e22dd"/></dir><dir name="template"><dir name="quantum"><dir name="ilf"><file name="iframe.phtml" hash="cfede2a3475cfe86971dc70d31173f93"/><file name="info.phtml" hash="35ac92a5d3b185a3b287db7228cefde7"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="quantum"><file name="quantum.js" hash="375e18bfb757c7c8d8dca2676bdbfe6c"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Quantum_ILF.xml" hash="c2caf07792b2a2f23be4222af47ca22b"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
+
</package>
|