Version Notes
Download this release
Release Info
Developer | Optimizer Ltd. |
Extension | SwipeHQ_Checkout |
Version | 1.7.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.0 to 1.7.0
- app/code/community/SwipeHQ/Checkout/Helper/Data.php +0 -0
- app/code/community/SwipeHQ/Checkout/Model/Permittedorderstates.php +0 -0
- app/code/community/SwipeHQ/Checkout/Model/Standard.php +0 -0
- app/code/community/SwipeHQ/Checkout/controllers/PaymentController.php +61 -17
- app/code/community/SwipeHQ/Checkout/etc/config.xml +1 -1
- app/code/community/SwipeHQ/Checkout/etc/system.xml +76 -1
- app/code/community/SwipeHQ/Checkout/etc/test-plugin.php +230 -0
- app/design/frontend/base/default/template/swipehq/redirect.phtml +1 -1
- app/etc/modules/SwipeHQ_Checkout.xml +0 -0
- package.xml +76 -74
- readme.txt +64 -55
app/code/community/SwipeHQ/Checkout/Helper/Data.php
CHANGED
File without changes
|
app/code/community/SwipeHQ/Checkout/Model/Permittedorderstates.php
CHANGED
File without changes
|
app/code/community/SwipeHQ/Checkout/Model/Standard.php
CHANGED
File without changes
|
app/code/community/SwipeHQ/Checkout/controllers/PaymentController.php
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
* Swipe Checkout Controller
|
4 |
-
*
|
5 |
-
* @
|
6 |
-
* @link http://www.swipehq.com/checkout/
|
7 |
*/
|
8 |
|
9 |
class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Action {
|
@@ -22,6 +21,14 @@ class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Acti
|
|
22 |
$currency = !empty($orderData['order_currency_code']) ? $orderData['order_currency_code'] : false;
|
23 |
|
24 |
$acceptedCurrencies = $this->_getAcceptedCurrencies();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
if (in_array($currency, $acceptedCurrencies)) {
|
27 |
$orderTotal = $orderData['grand_total'];
|
@@ -94,7 +101,7 @@ class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Acti
|
|
94 |
if($order->isStateProtected($order_status)){
|
95 |
Mage::throwException('Swipe configuration error: "Paid Order Status" must not be: "'.$order_status.'". Failed to change state.');
|
96 |
}else{
|
97 |
-
$order->setState($order_status, true, 'Swipe has authorized the payment.');
|
98 |
}
|
99 |
|
100 |
$order->sendNewOrderEmail();
|
@@ -102,16 +109,17 @@ class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Acti
|
|
102 |
|
103 |
$order->save();
|
104 |
|
105 |
-
Mage::getSingleton('checkout/session')->unsQuoteId();
|
106 |
} else {
|
107 |
// There is a problem in the response we got
|
108 |
-
$this->cancelAction();
|
109 |
}
|
110 |
die('LPN OK, transaction_id: '.$transaction_id.', is_verified: '.($is_verified?'y':'n'));
|
111 |
|
112 |
//Result page (user redirect)
|
113 |
} elseif (isset($request['result']) && isset($request['user_data'])) {
|
114 |
if ($request['result'] == 'accepted' || $request['result'] == 'test-accepted') {
|
|
|
115 |
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
|
116 |
} elseif ($request['result'] == 'declined' || $request['result'] == 'test-declined') {
|
117 |
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
|
@@ -122,16 +130,35 @@ class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Acti
|
|
122 |
}
|
123 |
|
124 |
// The cancel action is triggered when an order is to be cancelled
|
125 |
-
public function cancelAction() {
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
$order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
|
131 |
}
|
132 |
}
|
133 |
}
|
134 |
-
|
|
|
|
|
|
|
|
|
135 |
/**
|
136 |
* Transaction verification
|
137 |
*
|
@@ -161,19 +188,36 @@ class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Acti
|
|
161 |
}
|
162 |
return false;
|
163 |
}
|
164 |
-
|
165 |
-
|
166 |
$api_url = trim(Mage::getStoreConfig('payment/swipehq/api_url'), '/');
|
|
|
|
|
167 |
|
168 |
-
|
169 |
-
'merchant_id' => Mage::getStoreConfig('payment/swipehq/merchant_id'),
|
170 |
'api_key' => Mage::getStoreConfig('payment/swipehq/api_key'),
|
171 |
);
|
172 |
|
173 |
$resp = $this->_sendRequest($api_url.'/fetchCurrencyCodes.php', $params);
|
174 |
$respArr = json_decode($resp, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
return $respArr['data'];
|
|
|
|
|
|
|
|
|
176 |
}
|
|
|
|
|
177 |
|
178 |
private function _sendRequest($url, $data) {
|
179 |
$ch = curl_init ($url);
|
1 |
<?php
|
2 |
+
/*
|
3 |
* Swipe Checkout Controller
|
4 |
+
* @copyright (c) 2012-2014, OptimizerHQ Ltd.
|
5 |
+
* @link http://www.swipehq.com/
|
|
|
6 |
*/
|
7 |
|
8 |
class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Action {
|
21 |
$currency = !empty($orderData['order_currency_code']) ? $orderData['order_currency_code'] : false;
|
22 |
|
23 |
$acceptedCurrencies = $this->_getAcceptedCurrencies();
|
24 |
+
|
25 |
+
if($acceptedCurrencies && !in_array($currency, $acceptedCurrencies)){
|
26 |
+
|
27 |
+
Mage::getSingleton('checkout/session')->addError('Swipe Checkout does not support currency: '.$currency.'. Swipe supports these currencies: '.join(', ', $acceptedCurrencies).'.');
|
28 |
+
session_write_close(); //THIS LINE IS VERY IMPORTANT!
|
29 |
+
$this->_redirect('checkout/cart');
|
30 |
+
}
|
31 |
+
|
32 |
|
33 |
if (in_array($currency, $acceptedCurrencies)) {
|
34 |
$orderTotal = $orderData['grand_total'];
|
101 |
if($order->isStateProtected($order_status)){
|
102 |
Mage::throwException('Swipe configuration error: "Paid Order Status" must not be: "'.$order_status.'". Failed to change state.');
|
103 |
}else{
|
104 |
+
$order->setState($order_status, true, 'Swipe has authorized the payment.')->save();
|
105 |
}
|
106 |
|
107 |
$order->sendNewOrderEmail();
|
109 |
|
110 |
$order->save();
|
111 |
|
112 |
+
//Mage::getSingleton('checkout/session')->unsQuoteId();
|
113 |
} else {
|
114 |
// There is a problem in the response we got
|
115 |
+
$this->cancelAction($order_id);
|
116 |
}
|
117 |
die('LPN OK, transaction_id: '.$transaction_id.', is_verified: '.($is_verified?'y':'n'));
|
118 |
|
119 |
//Result page (user redirect)
|
120 |
} elseif (isset($request['result']) && isset($request['user_data'])) {
|
121 |
if ($request['result'] == 'accepted' || $request['result'] == 'test-accepted') {
|
122 |
+
Mage::getSingleton('checkout/session')->unsQuoteId();
|
123 |
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
|
124 |
} elseif ($request['result'] == 'declined' || $request['result'] == 'test-declined') {
|
125 |
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
|
130 |
}
|
131 |
|
132 |
// The cancel action is triggered when an order is to be cancelled
|
133 |
+
public function cancelAction($order_id) {
|
134 |
+
|
135 |
+
$testMode = Mage::getStoreConfig('payment/swipehq/test_mode');
|
136 |
+
|
137 |
+
|
138 |
+
$order = Mage::getModel('sales/order');
|
139 |
+
$order->loadByIncrementId($order_id);
|
140 |
+
if (!$order->getId()) {
|
141 |
+
Mage::throwException('No order for processing found');
|
142 |
+
}
|
143 |
+
else{
|
144 |
+
if ($testMode) {
|
145 |
+
$order_status = Mage::getStoreConfig('payment/swipehq/test_order_status');
|
146 |
+
if($order->isStateProtected($order_status)){
|
147 |
+
Mage::throwException('Swipe configuration error: "Paid Order Status" must not be: "'.$order_status.'". Failed to change state.');
|
148 |
+
}else{
|
149 |
+
$order->setState($order_status, true, 'Swipe has declined the payment.')->save();
|
150 |
+
}
|
151 |
+
}
|
152 |
+
else{
|
153 |
$order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
|
154 |
}
|
155 |
}
|
156 |
}
|
157 |
+
|
158 |
+
public function testConfigAction(){
|
159 |
+
include __DIR__ . '/../etc/test-plugin.php';
|
160 |
+
}
|
161 |
+
|
162 |
/**
|
163 |
* Transaction verification
|
164 |
*
|
188 |
}
|
189 |
return false;
|
190 |
}
|
191 |
+
|
192 |
+
protected function _getAcceptedCurrencies(){
|
193 |
$api_url = trim(Mage::getStoreConfig('payment/swipehq/api_url'), '/');
|
194 |
+
$merchant_id = trim(Mage::getStoreConfig('payment/swipehq/merchant_id'), '/');
|
195 |
+
$api_key = trim(Mage::getStoreConfig('payment/swipehq/api_key'), '/');
|
196 |
|
197 |
+
/*$params = array(
|
198 |
+
'merchant_id' => Mage::getStoreConfig('payment/swipehq/merchant_id'),
|
199 |
'api_key' => Mage::getStoreConfig('payment/swipehq/api_key'),
|
200 |
);
|
201 |
|
202 |
$resp = $this->_sendRequest($api_url.'/fetchCurrencyCodes.php', $params);
|
203 |
$respArr = json_decode($resp, true);
|
204 |
+
return $respArr['data'];*/
|
205 |
+
|
206 |
+
if($api_url && $api_key && $merchant_id){
|
207 |
+
$params = array(
|
208 |
+
'merchant_id' => Mage::getStoreConfig('payment/swipehq/merchant_id'),
|
209 |
+
'api_key' => Mage::getStoreConfig('payment/swipehq/api_key'),
|
210 |
+
);
|
211 |
+
$resp = $this->_sendRequest($api_url.'/fetchCurrencyCodes.php', $params);
|
212 |
+
$respArr = json_decode($resp, true);
|
213 |
return $respArr['data'];
|
214 |
+
}else{
|
215 |
+
return null;
|
216 |
+
}
|
217 |
+
|
218 |
}
|
219 |
+
|
220 |
+
|
221 |
|
222 |
private function _sendRequest($url, $data) {
|
223 |
$ch = curl_init ($url);
|
app/code/community/SwipeHQ/Checkout/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<SwipeHQ_Checkout>
|
5 |
-
<version>1.
|
6 |
</SwipeHQ_Checkout>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<SwipeHQ_Checkout>
|
5 |
+
<version>1.7.0</version><!-- todo: what's the point of this version number? where is it used? -->
|
6 |
</SwipeHQ_Checkout>
|
7 |
</modules>
|
8 |
<global>
|
app/code/community/SwipeHQ/Checkout/etc/system.xml
CHANGED
@@ -5,7 +5,82 @@
|
|
5 |
<groups>
|
6 |
<swipehq translate="label comment" module="paygate">
|
7 |
<label>Swipe Checkout</label>
|
8 |
-
<comment><![CDATA[<a href="http://www.swipehq.com/support/support_detail.php?cat=General+Questions&title=Becoming+a+Swipe+HQ+Checkout+merchant" target="_blank">Click here to see how to become a SwipeHQ Checkout merchant</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
<frontend_type>text</frontend_type>
|
10 |
<sort_order>1</sort_order>
|
11 |
<show_in_default>1</show_in_default>
|
5 |
<groups>
|
6 |
<swipehq translate="label comment" module="paygate">
|
7 |
<label>Swipe Checkout</label>
|
8 |
+
<comment><![CDATA[<a href="http://www.swipehq.com/support/support_detail.php?cat=General+Questions&title=Becoming+a+Swipe+HQ+Checkout+merchant" target="_blank">Click here to see how to become a SwipeHQ Checkout merchant</a>
|
9 |
+
<script>
|
10 |
+
function check_config(){
|
11 |
+
var elementToRemove = document.getElementById("check_config_results");
|
12 |
+
if(elementToRemove!=null && typeof(elementToRemove)!="undefined"){
|
13 |
+
$(elementToRemove).remove();
|
14 |
+
}
|
15 |
+
|
16 |
+
var mainForm = document.getElementById("payment_swipehq");
|
17 |
+
var elementToInsert = document.createElement("div");
|
18 |
+
elementToInsert.setAttribute("id", "check_config_results");
|
19 |
+
elementToInsert.setAttribute("style", "width:100%;height:100%");
|
20 |
+
mainForm.appendChild(elementToInsert);
|
21 |
+
elementToInsert.innerHTML = "<p style=\"line-height:1;font-size:50px\">Checking config, please wait...</p>";
|
22 |
+
|
23 |
+
var merchantId = $("payment_swipehq_merchant_id").value;
|
24 |
+
var apiKey = $("payment_swipehq_api_key").value;
|
25 |
+
var apiURL = $("payment_swipehq_api_url").value;
|
26 |
+
var paymentURL = $("payment_swipehq_payment_page_url").value;
|
27 |
+
|
28 |
+
var urlToLoad = "../../../../../../../swipehq/payment/testconfig?merchant_id="+merchantId+"&api_key="+apiKey+"&api_url="+apiURL+"&payment_page_url="+paymentURL;
|
29 |
+
processAjax(urlToLoad);
|
30 |
+
|
31 |
+
function processAjax(url) {
|
32 |
+
var req = null;
|
33 |
+
if (window.XMLHttpRequest) { // Non-IE browsers
|
34 |
+
req = new XMLHttpRequest();
|
35 |
+
try {
|
36 |
+
req.onreadystatechange = targetDiv;
|
37 |
+
req.open("GET", url, true);
|
38 |
+
req.send(null);
|
39 |
+
} catch (e) {
|
40 |
+
alert(e);
|
41 |
+
}
|
42 |
+
|
43 |
+
} else if (window.ActiveXObject) { // IE
|
44 |
+
var req = new ActiveXObject("Microsoft.XMLHTTP");
|
45 |
+
if (req) {
|
46 |
+
req.onreadystatechange = targetDiv;
|
47 |
+
req.open("GET", url, true);
|
48 |
+
req.send();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
function targetDiv() {
|
54 |
+
if(req!=null){
|
55 |
+
if (req.readyState == 4) { // Complete
|
56 |
+
if (req.status == 200) { // OK response
|
57 |
+
document.getElementById("check_config_results").innerHTML = req.responseText;
|
58 |
+
}
|
59 |
+
else{
|
60 |
+
alert("problem");
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
document.observe("dom:loaded", function(){
|
71 |
+
var mainForm = document.getElementById("payment_swipehq");
|
72 |
+
var buttonToInsert = document.createElement("input");
|
73 |
+
buttonToInsert.setAttribute("type", "button");
|
74 |
+
buttonToInsert.setAttribute("value", "Check Config");
|
75 |
+
buttonToInsert.setAttribute("name", "checkconfig");
|
76 |
+
buttonToInsert.setAttribute("onclick", "check_config()");
|
77 |
+
buttonToInsert.setAttribute("style", "margin-top:30px");
|
78 |
+
mainForm.appendChild(buttonToInsert);
|
79 |
+
|
80 |
+
});
|
81 |
+
</script>
|
82 |
+
]]>
|
83 |
+
</comment>
|
84 |
<frontend_type>text</frontend_type>
|
85 |
<sort_order>1</sort_order>
|
86 |
<show_in_default>1</show_in_default>
|
app/code/community/SwipeHQ/Checkout/etc/test-plugin.php
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* A script to test common issues with plugins
|
5 |
+
*/
|
6 |
+
|
7 |
+
|
8 |
+
/*
|
9 |
+
* Constants
|
10 |
+
*/
|
11 |
+
|
12 |
+
$TEST_API = 'connectionTest.php';
|
13 |
+
$SELF_ERROR_MSG = 'Sorry, there was a problem running this test. Please contact us at Swipe support to let us know you got this error.';
|
14 |
+
|
15 |
+
function swipe_curl_call($url){
|
16 |
+
$ch = curl_init($url);
|
17 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
18 |
+
$html = curl_exec($ch);
|
19 |
+
curl_close($ch);
|
20 |
+
return $html;
|
21 |
+
}
|
22 |
+
|
23 |
+
function testResultHtml($result){
|
24 |
+
if($result === true){
|
25 |
+
return '<span style="color:green; font-weight: bold;">OK</span>';
|
26 |
+
}else if($result === false){
|
27 |
+
return '<span style="color:red; font-weight: bold;">Failed</span>';
|
28 |
+
}else{
|
29 |
+
return '<span style="color:gray">Did not run</span>';
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
$_order = new Mage_Sales_Model_Order();
|
34 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
35 |
+
$_order->loadByIncrementId($orderId);
|
36 |
+
|
37 |
+
$orderData = $_order->getData();
|
38 |
+
$currency = !empty($orderData['order_currency_code']) ? $orderData['order_currency_code'] : false;
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
/*
|
45 |
+
* Configuration
|
46 |
+
*/
|
47 |
+
|
48 |
+
$merchantId = isset($_REQUEST['merchant_id']) ? $_REQUEST['merchant_id'] : null;
|
49 |
+
$apiKey = isset($_REQUEST['api_key']) ? $_REQUEST['api_key'] : null;
|
50 |
+
$apiUrl = isset($_REQUEST['api_url']) ? $_REQUEST['api_url'] : null;
|
51 |
+
$paymentPageUrl = isset($_REQUEST['payment_page_url']) ? $_REQUEST['payment_page_url'] : null;
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
/*
|
56 |
+
* Test start
|
57 |
+
*/
|
58 |
+
try{
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
+
// Tests Init
|
63 |
+
$minRequirementsOK = null;
|
64 |
+
$basicConnectionTestOK = null;
|
65 |
+
$credentialsOK = null;
|
66 |
+
$merchantStatusOK = null;
|
67 |
+
$pluginConfigOK = null;
|
68 |
+
|
69 |
+
$basicConnectionTestUrl = $apiUrl . $TEST_API;
|
70 |
+
$credentialsUrl = $apiUrl . $TEST_API . '?' . http_build_query(
|
71 |
+
array(
|
72 |
+
'mode' => 'credentials',
|
73 |
+
'merchant_id' => $merchantId,
|
74 |
+
'api_key' => $apiKey
|
75 |
+
)
|
76 |
+
);
|
77 |
+
|
78 |
+
$merchantStatusUrl = $apiUrl . $TEST_API . '?' . http_build_query(
|
79 |
+
array(
|
80 |
+
'mode' => 'merchant_status',
|
81 |
+
'merchant_id' => $merchantId,
|
82 |
+
'api_key' => $apiKey
|
83 |
+
)
|
84 |
+
);
|
85 |
+
$pluginConfigUrl = $apiUrl . $TEST_API . '?' . http_build_query(
|
86 |
+
array(
|
87 |
+
'mode' => 'plugin_config',
|
88 |
+
'merchant_id' => $merchantId,
|
89 |
+
'api_key' => $apiKey,
|
90 |
+
'payment_page_url' => $paymentPageUrl,
|
91 |
+
'currency' => $currency
|
92 |
+
)
|
93 |
+
);
|
94 |
+
|
95 |
+
// Tests Run
|
96 |
+
$minRequirementsOK = function_exists('curl_version');
|
97 |
+
if($minRequirementsOK){
|
98 |
+
$basicConnectionTestOK = swipe_curl_call($basicConnectionTestUrl) == 'OK';
|
99 |
+
}
|
100 |
+
if($basicConnectionTestOK){
|
101 |
+
$credentialsOK = swipe_curl_call($credentialsUrl) == 'OK';
|
102 |
+
}
|
103 |
+
if($credentialsOK){
|
104 |
+
$merchantStatusOK = swipe_curl_call($merchantStatusUrl) == 'OK';
|
105 |
+
}
|
106 |
+
if($merchantStatusOK){
|
107 |
+
$pluginConfigResponse = swipe_curl_call($pluginConfigUrl);
|
108 |
+
$pluginConfigOK = $pluginConfigResponse == 'OK';
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
?>
|
113 |
+
<style type="text/css">
|
114 |
+
#test_config_table { font-family: sans-serif; }
|
115 |
+
#test_config_table th { text-align: left; background: lightblue; }
|
116 |
+
#test_config_table td { font-size: 12px; }
|
117 |
+
#test_config_table table { border-collapse: collapse; }
|
118 |
+
#test_config_table tr td { padding: 1em 0.5em; border: 1px solid #aaa; }
|
119 |
+
#test_config_table tr th { padding: 1em 0.5em; border: 1px solid #aaa; }
|
120 |
+
#test_config_table .test-title { white-space: nowrap; font-weight: bold; }
|
121 |
+
#test_config_table .test-result { white-space: nowrap; }
|
122 |
+
#test_config_table .technical-details { color: #888; margin: 1em; padding: 0.5em; border: 1px solid #aaa; }
|
123 |
+
</style>
|
124 |
+
|
125 |
+
<div id="test_config_table">
|
126 |
+
<table>
|
127 |
+
<thead>
|
128 |
+
<tr>
|
129 |
+
<th colspan="3">
|
130 |
+
Swipe Plugin Test
|
131 |
+
</th>
|
132 |
+
</tr>
|
133 |
+
</thead>
|
134 |
+
<tbody>
|
135 |
+
<tr>
|
136 |
+
<td class="test-title">
|
137 |
+
1. Minimum Requirements
|
138 |
+
</td>
|
139 |
+
<td class="test-result">
|
140 |
+
<?php echo testResultHtml($minRequirementsOK); ?>
|
141 |
+
</td>
|
142 |
+
<td class="test_info">
|
143 |
+
<?php if($minRequirementsOK === false){ ?>
|
144 |
+
Your shopping cart does not meet the minimum requirements to connect to Swipe. Please contact Swipe support.
|
145 |
+
<div class="technical-details">Technical details: curl is required.</div>
|
146 |
+
<?php } ?>
|
147 |
+
</td>
|
148 |
+
</tr>
|
149 |
+
<tr>
|
150 |
+
<td class="test-title">
|
151 |
+
2. Connection to Swipe
|
152 |
+
</td>
|
153 |
+
<td class="test-result">
|
154 |
+
<?php echo testResultHtml($basicConnectionTestOK); ?>
|
155 |
+
</td>
|
156 |
+
<td class="test_info">
|
157 |
+
<?php if($basicConnectionTestOK === false){ ?>
|
158 |
+
Could not connect to Swipe. Check your API Url: "<?php echo $apiUrl; ?>", comparing it with the API Url
|
159 |
+
in your Swipe Merchant login under Settings -> API Credentials. If you are sure it is correct, Swipe
|
160 |
+
may be temporarily unreachable, please try again later.
|
161 |
+
<div class="technical-details">
|
162 |
+
Technical details: could not connect to: <?php echo htmlentities($basicConnectionTestUrl); ?>
|
163 |
+
</div>
|
164 |
+
<?php } ?>
|
165 |
+
</td>
|
166 |
+
</tr>
|
167 |
+
<tr>
|
168 |
+
<td class="test-title">
|
169 |
+
3. Swipe Merchant Credentials
|
170 |
+
</td>
|
171 |
+
<td class="test-result">
|
172 |
+
<?php echo testResultHtml($credentialsOK); ?>
|
173 |
+
</td>
|
174 |
+
<td class="test_info">
|
175 |
+
<?php if($credentialsOK === false){ ?>
|
176 |
+
Your credentials are incorrect. Check your Merchant ID: "<?php echo $merchantId; ?>" and API Key: "<?php echo $apiKey; ?>",
|
177 |
+
comparing them to the details you see in your Swipe Merchant login under Settings -> API Credentials.
|
178 |
+
A common mistake is to have these two swapped around.
|
179 |
+
<div class="technical-details">
|
180 |
+
Technical details: called: <?php echo $credentialsUrl; ?>
|
181 |
+
</div>
|
182 |
+
<?php } ?>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
+
<tr>
|
186 |
+
<td class="test-title">
|
187 |
+
4. Swipe Merchant Status
|
188 |
+
</td>
|
189 |
+
<td class="test-result">
|
190 |
+
<?php echo testResultHtml($merchantStatusOK); ?>
|
191 |
+
</td>
|
192 |
+
<td class="test_info">
|
193 |
+
<?php if($merchantStatusOK === false){ ?>
|
194 |
+
Your Swipe Merchant account is inactive, or does not have the Payment Page enabled. Please contact Swipe support.
|
195 |
+
<div class="technical-details">
|
196 |
+
Technical details: called: <?php echo $merchantStatusUrl; ?>
|
197 |
+
</div>
|
198 |
+
<?php } ?>
|
199 |
+
</td>
|
200 |
+
</tr>
|
201 |
+
<tr>
|
202 |
+
<td class="test-title">
|
203 |
+
5. Plugin Configuration
|
204 |
+
</td>
|
205 |
+
<td class="test-result">
|
206 |
+
<?php echo testResultHtml($pluginConfigOK); ?>
|
207 |
+
</td>
|
208 |
+
<td class="test_info">
|
209 |
+
<?php if($pluginConfigOK === false){ ?>
|
210 |
+
Your plugin configuration is incorrect. Merchant ID, API Key, and API Url are OK, but something else is incorrectly configured.
|
211 |
+
Please double check your configuration, if the problem persists please contact Swipe support.
|
212 |
+
<div class="technical-details">
|
213 |
+
Technical details: <?php echo $pluginConfigResponse; ?>
|
214 |
+
Request: <?php echo htmlentities($pluginConfigUrl); ?>
|
215 |
+
</div>
|
216 |
+
<?php } ?>
|
217 |
+
</td>
|
218 |
+
</tr>
|
219 |
+
|
220 |
+
|
221 |
+
|
222 |
+
</tbody>
|
223 |
+
</table>
|
224 |
+
</div>
|
225 |
+
<?php
|
226 |
+
|
227 |
+
}catch(Exception $e){
|
228 |
+
echo self::$selfErrorMsg;
|
229 |
+
}
|
230 |
+
|
app/design/frontend/base/default/template/swipehq/redirect.phtml
CHANGED
@@ -10,7 +10,7 @@ if (!empty($identifier_id) && $payment_page_url) {
|
|
10 |
<img src="http://www.swipehq.com/images/checkout-logo.png" width="178" height="76" />
|
11 |
<p>To complete your order, please click Pay Now below, you will be redirected to the secure Swipe Checkout payment page.</p>
|
12 |
|
13 |
-
<form name="swipehq_checkout_form" method="post" action="
|
14 |
<input type="hidden" name="checkout" value="true" />
|
15 |
<input type="hidden" name="identifier_id" value="<?php echo $identifier_id; ?>" />
|
16 |
<button type="submit">Pay Now</button>
|
10 |
<img src="http://www.swipehq.com/images/checkout-logo.png" width="178" height="76" />
|
11 |
<p>To complete your order, please click Pay Now below, you will be redirected to the secure Swipe Checkout payment page.</p>
|
12 |
|
13 |
+
<form name="swipehq_checkout_form" method="post" action="<?php echo $payment_page_url; ?>">
|
14 |
<input type="hidden" name="checkout" value="true" />
|
15 |
<input type="hidden" name="identifier_id" value="<?php echo $identifier_id; ?>" />
|
16 |
<button type="submit">Pay Now</button>
|
app/etc/modules/SwipeHQ_Checkout.xml
CHANGED
File without changes
|
package.xml
CHANGED
@@ -1,74 +1,76 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<package>
|
3 |
-
<name>SwipeHQ_Checkout</name>
|
4 |
-
<version>1.
|
5 |
-
<stability>stable</stability>
|
6 |
-
<license>GNU General Public License (GPL)</license>
|
7 |
-
<channel>community</channel>
|
8 |
-
<extends />
|
9 |
-
<summary>Swipe Checkout payment method</summary>
|
10 |
-
<description></description>
|
11 |
-
<notes></notes>
|
12 |
-
<authors>
|
13 |
-
<author>
|
14 |
-
<name>Optimizer Ltd.</name>
|
15 |
-
<user>swipehq</user>
|
16 |
-
<email>support@swipehq.com</email>
|
17 |
-
</author>
|
18 |
-
</authors>
|
19 |
-
<date>2013-09-
|
20 |
-
<time>00:00:00</time>
|
21 |
-
<contents>
|
22 |
-
<target name="magecommunity">
|
23 |
-
<dir name="SwipeHQ">
|
24 |
-
<dir name="Checkout">
|
25 |
-
<dir name="Helper">
|
26 |
-
<file name="Data.php" hash="8016d7114990c7cc569821b236dc561e" />
|
27 |
-
</dir>
|
28 |
-
<dir name="Model">
|
29 |
-
<file name="Standard.php" hash="29daa1223e187ce11a86831cd67984b5" />
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
<file name="
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
<
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
</
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>SwipeHQ_Checkout</name>
|
4 |
+
<version>1.7.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends />
|
9 |
+
<summary>Swipe Checkout payment method</summary>
|
10 |
+
<description></description>
|
11 |
+
<notes></notes>
|
12 |
+
<authors>
|
13 |
+
<author>
|
14 |
+
<name>Optimizer Ltd.</name>
|
15 |
+
<user>swipehq</user>
|
16 |
+
<email>support@swipehq.com</email>
|
17 |
+
</author>
|
18 |
+
</authors>
|
19 |
+
<date>2013-09-20</date>
|
20 |
+
<time>00:00:00</time>
|
21 |
+
<contents>
|
22 |
+
<target name="magecommunity">
|
23 |
+
<dir name="SwipeHQ">
|
24 |
+
<dir name="Checkout">
|
25 |
+
<dir name="Helper">
|
26 |
+
<file name="Data.php" hash="8016d7114990c7cc569821b236dc561e" />
|
27 |
+
</dir>
|
28 |
+
<dir name="Model">
|
29 |
+
<file name="Standard.php" hash="29daa1223e187ce11a86831cd67984b5" />
|
30 |
+
<file name="Permittedorderstates.php" hash="eccc62e6b03420d9b124bb083e8c8e6b" />
|
31 |
+
</dir>
|
32 |
+
<dir name="controllers">
|
33 |
+
<file name="PaymentController.php" hash="9e549da787ee7d121aed379d33b4e013" />
|
34 |
+
</dir>
|
35 |
+
<dir name="etc">
|
36 |
+
<file name="config.xml" hash="462b6e89f0a043272b45b71e05a7443c" />
|
37 |
+
<file name="system.xml" hash="bf965a12b02363a0371b322b1e8366b6" />
|
38 |
+
<file name="test-plugin.php" hash="6552a4ecc0af27dcbf92336c9d999f8c" />
|
39 |
+
</dir>
|
40 |
+
</dir>
|
41 |
+
</dir>
|
42 |
+
</target>
|
43 |
+
<target name="magedesign">
|
44 |
+
<dir name="frontend">
|
45 |
+
<dir name="base">
|
46 |
+
<dir name="default">
|
47 |
+
<dir name="template">
|
48 |
+
<dir name="swipehq">
|
49 |
+
<file name="redirect.phtml" hash="fc7d961fdec90adc657af711ffd2325b" />
|
50 |
+
</dir>
|
51 |
+
</dir>
|
52 |
+
</dir>
|
53 |
+
</dir>
|
54 |
+
</dir>
|
55 |
+
</target>
|
56 |
+
<target name="mageetc">
|
57 |
+
<dir name="modules">
|
58 |
+
<file name="SwipeHQ_Checkout.xml" hash="0889d10dcd74110d9cca21fd27823057" />
|
59 |
+
</dir>
|
60 |
+
</target>
|
61 |
+
</contents>
|
62 |
+
<compatible />
|
63 |
+
<dependencies>
|
64 |
+
<required>
|
65 |
+
<php>
|
66 |
+
<min>5.1.0</min>
|
67 |
+
<max>6.0.0</max>
|
68 |
+
</php>
|
69 |
+
<extension>
|
70 |
+
<name>curl</name>
|
71 |
+
<min></min>
|
72 |
+
<max></max>
|
73 |
+
</extension>
|
74 |
+
</required>
|
75 |
+
</dependencies>
|
76 |
+
</package>
|
readme.txt
CHANGED
@@ -1,55 +1,64 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
Version: 1.
|
4 |
-
Copyright: (c) 2012-
|
5 |
-
Link: http://www.swipehq.com/
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
REQUIREMENTS
|
10 |
-
---
|
11 |
-
|
12 |
-
* Swipe account
|
13 |
-
* Magento
|
14 |
-
|
15 |
-
|
16 |
-
INSTALLATION
|
17 |
-
---
|
18 |
-
|
19 |
-
1. Please install this extension through the normal Magento installation process (System -> Magento Connect -> Magento Connect Manager, then
|
20 |
-
Install New Extensions, grabbing the key from
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
Callback
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
see
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
-
|
52 |
-
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Swipe Checkout for Magento
|
2 |
+
|
3 |
+
Version: 1.7.0 / 6 May 2014
|
4 |
+
Copyright: (c) 2012-2014, Optimizer Ltd.
|
5 |
+
Link: http://www.swipehq.com/
|
6 |
+
http://www.magentocommerce.com/magento-connect/catalog/product/view/id/15121/
|
7 |
+
|
8 |
+
|
9 |
+
REQUIREMENTS
|
10 |
+
---
|
11 |
+
|
12 |
+
* Swipe account
|
13 |
+
* Magento
|
14 |
+
|
15 |
+
|
16 |
+
INSTALLATION
|
17 |
+
---
|
18 |
+
|
19 |
+
1. Please install this extension through the normal Magento installation process (System -> Magento Connect -> Magento Connect Manager, then
|
20 |
+
Install New Extensions, grabbing the key from the plugin page linked above or Direct Package File Upload, selecting this zip)
|
21 |
+
2. After successful installation it will appear in the list of Packages as "SwipeHQ_Checkout"
|
22 |
+
3. Then configure the plugin, go back to the Magento Admin, then go to System -> Configuration -> Sales -> Payment Methods -> Swipe Checkout,
|
23 |
+
adding the following details from your Swipe Merchant login under Settings -> API Credentials:
|
24 |
+
Merchant ID
|
25 |
+
API Key
|
26 |
+
Payment Page Url
|
27 |
+
Api Url
|
28 |
+
4. And finally configure your Swipe account to send customers back to your shop after they pay.
|
29 |
+
In your Merchant login under Settings -> Payment Notifiers, set:
|
30 |
+
Callback Url: %YOUR_WEBSITE%/swipehq/payment/response
|
31 |
+
Callback pass back user data: on
|
32 |
+
LPN Url: %YOUR_WEBSITE%/swipehq/payment/response
|
33 |
+
making sure to replace %YOUR_WEBSITE% with your website url, e.g. www.example.com/my-shop/swipehq/payment/response
|
34 |
+
5. All done, test it out, add some products to your cart and you will get the option to pay with Swipe.
|
35 |
+
|
36 |
+
|
37 |
+
NOTES
|
38 |
+
---
|
39 |
+
* Magento must be configured to use a currency that your Swipe Merchant Account supports for customers to be able to use Swipe to be a payment option,
|
40 |
+
see Settings -> API Credentials for a list of currencies your Merchant Account supports. And see System -> Manage Currency -> Symbols
|
41 |
+
to see which currency your Magento is using.
|
42 |
+
* Magento allows this plugin to set the order state to only a limited subset of all order states. You must mark orders as complete manually once you ship
|
43 |
+
them.
|
44 |
+
|
45 |
+
|
46 |
+
CHANGE LOG
|
47 |
+
---
|
48 |
+
|
49 |
+
1.3.0:
|
50 |
+
- first version with this readme
|
51 |
+
- fixing bug where magento does not allow you to set an order's state to complete
|
52 |
+
- tested against Magento-1.7.0.2
|
53 |
+
|
54 |
+
1.4.0:
|
55 |
+
- Added test configuration button, fixed bug in package.xml file and added the missing file Permittedorderstates.php in Model directory
|
56 |
+
|
57 |
+
1.5.0:
|
58 |
+
- Fixing bug, changed php short tag to long tag
|
59 |
+
|
60 |
+
1.6.0:
|
61 |
+
- Fixing issue with check config for installs with .htaccess enabled which deny direct access to magento files
|
62 |
+
|
63 |
+
1.7.0:
|
64 |
+
- Bug fixes for updating order status
|