SwipeHQ_Checkout - Version 1.6.0

Version Notes

Download this release

Release Info

Developer Optimizer Ltd.
Extension SwipeHQ_Checkout
Version 1.6.0
Comparing to
See all releases


Code changes from version 1.3.0 to 1.6.0

app/code/community/SwipeHQ/Checkout/controllers/PaymentController.php CHANGED
@@ -131,7 +131,11 @@ class SwipeHQ_Checkout_PaymentController extends Mage_Core_Controller_Front_Acti
131
  }
132
  }
133
  }
134
-
 
 
 
 
135
  /**
136
  * Transaction verification
137
  *
131
  }
132
  }
133
  }
134
+
135
+ public function testConfigAction(){
136
+ include __DIR__ . '/../etc/test-plugin.php';
137
+ }
138
+
139
  /**
140
  * Transaction verification
141
  *
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>]]></comment>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
34
+
35
+
36
+
37
+ /*
38
+ * Configuration
39
+ */
40
+
41
+ $merchantId = isset($_REQUEST['merchant_id']) ? $_REQUEST['merchant_id'] : null;
42
+ $apiKey = isset($_REQUEST['api_key']) ? $_REQUEST['api_key'] : null;
43
+ $apiUrl = isset($_REQUEST['api_url']) ? $_REQUEST['api_url'] : null;
44
+ $paymentPageUrl = isset($_REQUEST['payment_page_url']) ? $_REQUEST['payment_page_url'] : null;
45
+ $currency = isset($_REQUEST['currency']) ? $_REQUEST['currency'] : null;
46
+
47
+
48
+
49
+ /*
50
+ * Test start
51
+ */
52
+ try{
53
+
54
+
55
+
56
+ // Tests Init
57
+ $minRequirementsOK = null;
58
+ $basicConnectionTestOK = null;
59
+ $credentialsOK = null;
60
+ $merchantStatusOK = null;
61
+ $pluginConfigOK = null;
62
+
63
+ $basicConnectionTestUrl = $apiUrl . $TEST_API;
64
+ $credentialsUrl = $apiUrl . $TEST_API . '?' . http_build_query(
65
+ array(
66
+ 'mode' => 'credentials',
67
+ 'merchant_id' => $merchantId,
68
+ 'api_key' => $apiKey
69
+ )
70
+ );
71
+
72
+ $merchantStatusUrl = $apiUrl . $TEST_API . '?' . http_build_query(
73
+ array(
74
+ 'mode' => 'merchant_status',
75
+ 'merchant_id' => $merchantId,
76
+ 'api_key' => $apiKey
77
+ )
78
+ );
79
+ $pluginConfigUrl = $apiUrl . $TEST_API . '?' . http_build_query(
80
+ array(
81
+ 'mode' => 'plugin_config',
82
+ 'merchant_id' => $merchantId,
83
+ 'api_key' => $apiKey,
84
+ 'payment_page_url' => $paymentPageUrl,
85
+ 'currency' => $currency
86
+ )
87
+ );
88
+
89
+ // Tests Run
90
+ $minRequirementsOK = function_exists('curl_version');
91
+ if($minRequirementsOK){
92
+ $basicConnectionTestOK = swipe_curl_call($basicConnectionTestUrl) == 'OK';
93
+ }
94
+ if($basicConnectionTestOK){
95
+ $credentialsOK = swipe_curl_call($credentialsUrl) == 'OK';
96
+ }
97
+ if($credentialsOK){
98
+ $merchantStatusOK = swipe_curl_call($merchantStatusUrl) == 'OK';
99
+ }
100
+ if($merchantStatusOK){
101
+ $pluginConfigResponse = swipe_curl_call($pluginConfigUrl);
102
+ $pluginConfigOK = $pluginConfigResponse == 'OK';
103
+ }
104
+
105
+
106
+ ?>
107
+ <style type="text/css">
108
+ #test_config_table { font-family: sans-serif; }
109
+ #test_config_table th { text-align: left; background: lightblue; }
110
+ #test_config_table td { font-size: 12px; }
111
+ #test_config_table table { border-collapse: collapse; }
112
+ #test_config_table tr td { padding: 1em 0.5em; border: 1px solid #aaa; }
113
+ #test_config_table tr th { padding: 1em 0.5em; border: 1px solid #aaa; }
114
+ #test_config_table .test-title { white-space: nowrap; font-weight: bold; }
115
+ #test_config_table .test-result { white-space: nowrap; }
116
+ #test_config_table .technical-details { color: #888; margin: 1em; padding: 0.5em; border: 1px solid #aaa; }
117
+ </style>
118
+
119
+ <div id="test_config_table">
120
+ <table>
121
+ <thead>
122
+ <tr>
123
+ <th colspan="3">
124
+ Swipe Plugin Test
125
+ </th>
126
+ </tr>
127
+ </thead>
128
+ <tbody>
129
+ <tr>
130
+ <td class="test-title">
131
+ 1. Minimum Requirements
132
+ </td>
133
+ <td class="test-result">
134
+ <?php echo testResultHtml($minRequirementsOK); ?>
135
+ </td>
136
+ <td class="test_info">
137
+ <?php if($minRequirementsOK === false){ ?>
138
+ Your shopping cart does not meet the minimum requirements to connect to Swipe. Please contact Swipe support.
139
+ <div class="technical-details">Technical details: curl is required.</div>
140
+ <?php } ?>
141
+ </td>
142
+ </tr>
143
+ <tr>
144
+ <td class="test-title">
145
+ 2. Connection to Swipe
146
+ </td>
147
+ <td class="test-result">
148
+ <?php echo testResultHtml($basicConnectionTestOK); ?>
149
+ </td>
150
+ <td class="test_info">
151
+ <?php if($basicConnectionTestOK === false){ ?>
152
+ Could not connect to Swipe. Check your API Url: "<?php echo $apiUrl; ?>", comparing it with the API Url
153
+ in your Swipe Merchant login under Settings -> API Credentials. If you are sure it is correct, Swipe
154
+ may be temporarily unreachable, please try again later.
155
+ <div class="technical-details">
156
+ Technical details: could not connect to: <?php echo htmlentities($basicConnectionTestUrl); ?>
157
+ </div>
158
+ <?php } ?>
159
+ </td>
160
+ </tr>
161
+ <tr>
162
+ <td class="test-title">
163
+ 3. Swipe Merchant Credentials
164
+ </td>
165
+ <td class="test-result">
166
+ <?php echo testResultHtml($credentialsOK); ?>
167
+ </td>
168
+ <td class="test_info">
169
+ <?php if($credentialsOK === false){ ?>
170
+ Your credentials are incorrect. Check your Merchant ID: "<?php echo $merchantId; ?>" and API Key: "<?php echo $apiKey; ?>",
171
+ comparing them to the details you see in your Swipe Merchant login under Settings -> API Credentials.
172
+ A common mistake is to have these two swapped around.
173
+ <div class="technical-details">
174
+ Technical details: called: <?php echo $credentialsUrl; ?>
175
+ </div>
176
+ <?php } ?>
177
+ </td>
178
+ </tr>
179
+ <tr>
180
+ <td class="test-title">
181
+ 4. Swipe Merchant Status
182
+ </td>
183
+ <td class="test-result">
184
+ <?php echo testResultHtml($merchantStatusOK); ?>
185
+ </td>
186
+ <td class="test_info">
187
+ <?php if($merchantStatusOK === false){ ?>
188
+ Your Swipe Merchant account is inactive, or does not have the Payment Page enabled. Please contact Swipe support.
189
+ <div class="technical-details">
190
+ Technical details: called: <?php echo $merchantStatusUrl; ?>
191
+ </div>
192
+ <?php } ?>
193
+ </td>
194
+ </tr>
195
+ <tr>
196
+ <td class="test-title">
197
+ 5. Plugin Configuration
198
+ </td>
199
+ <td class="test-result">
200
+ <?php echo testResultHtml($pluginConfigOK); ?>
201
+ </td>
202
+ <td class="test_info">
203
+ <?php if($pluginConfigOK === false){ ?>
204
+ Your plugin configuration is incorrect. Merchant ID, API Key, and API Url are OK, but something else is incorrectly configured.
205
+ Please double check your configuration, if the problem persists please contact Swipe support.
206
+ <div class="technical-details">
207
+ Technical details: <?php echo $pluginConfigResponse; ?>
208
+ Request: <?php echo htmlentities($pluginConfigUrl); ?>
209
+ </div>
210
+ <?php } ?>
211
+ </td>
212
+ </tr>
213
+
214
+
215
+
216
+ </tbody>
217
+ </table>
218
+ </div>
219
+ <?php
220
+
221
+ }catch(Exception $e){
222
+ echo self::$selfErrorMsg;
223
+ }
224
+
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="<?=$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>
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>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SwipeHQ_Checkout</name>
4
- <version>1.3.0</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
@@ -16,7 +16,7 @@
16
  <email>support@swipehq.com</email>
17
  </author>
18
  </authors>
19
- <date>2013-09-18</date>
20
  <time>00:00:00</time>
21
  <contents>
22
  <target name="magecommunity">
@@ -27,13 +27,15 @@
27
  </dir>
28
  <dir name="Model">
29
  <file name="Standard.php" hash="29daa1223e187ce11a86831cd67984b5" />
 
30
  </dir>
31
  <dir name="controllers">
32
- <file name="PaymentController.php" hash="c235c54ee5f74593c6f94cafcbf385f0" />
33
  </dir>
34
  <dir name="etc">
35
- <file name="config.xml" hash="d469840c842a7ce1fa6125a36f9f5a6a" />
36
- <file name="system.xml" hash="6e106a4b51f5ddf7337b218f003168b9" />
 
37
  </dir>
38
  </dir>
39
  </dir>
@@ -44,7 +46,7 @@
44
  <dir name="default">
45
  <dir name="template">
46
  <dir name="swipehq">
47
- <file name="redirect.phtml" hash="3d081595a365f5332d522c876f1f0541" />
48
  </dir>
49
  </dir>
50
  </dir>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SwipeHQ_Checkout</name>
4
+ <version>1.6.0</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
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">
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="2fe38578c75addf07ab085bc9f915857" />
34
  </dir>
35
  <dir name="etc">
36
+ <file name="config.xml" hash="7dde071fe23e46ecdaf812432bdb5dde" />
37
+ <file name="system.xml" hash="175df78d0682e6df02873879b7ac37c6" />
38
+ <file name="test-plugin.php" hash="6ac73d7459e6c14a8a521dd6578465e5" />
39
  </dir>
40
  </dir>
41
  </dir>
46
  <dir name="default">
47
  <dir name="template">
48
  <dir name="swipehq">
49
+ <file name="redirect.phtml" hash="20a654b8ea3b604860316f81c1abd35d" />
50
  </dir>
51
  </dir>
52
  </dir>
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
- Hikashop Swipe plugin
2
 
3
- Version: 1.3.0 / 18 Sep 2013
4
  Copyright: (c) 2012-2013, Optimizer Ltd.
5
  Link: http://www.swipehq.com/checkout/
6
-
7
 
8
 
9
  REQUIREMENTS
@@ -17,8 +17,7 @@ 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 http://www.magentocommerce.com/magento-connect/catalog/product/view/id/15121/ or Direct
21
- Package File Upload, selecting this zip)
22
  2. After successful installation it will appear in the list of Packages as "SwipeHQ_Checkout"
23
  3. Then configure the plugin, go back to the Magento Admin, then go to System -> Configuration -> Sales -> Payment Methods -> Swipe Checkout,
24
  adding the following details from your Swipe Merchant login under Settings -> API Credentials:
@@ -38,7 +37,7 @@ INSTALLATION
38
  NOTES
39
  ---
40
  * 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,
41
- see Settings -> API Credentials for a list of currencies your Merchant Account supports. And see System -> Manage Currency -> Symboles
42
  to see which currency your Magento is using.
43
  * 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
44
  them.
@@ -52,4 +51,13 @@ CHANGE LOG
52
  - fixing bug where magento does not allow you to set an order's state to complete
53
  - tested against Magento-1.7.0.2
54
 
 
 
 
 
 
 
 
 
55
 
 
1
+ Swipe Checkout for Magento
2
 
3
+ Version: 1.6.0 / 3 Dec 2013
4
  Copyright: (c) 2012-2013, Optimizer Ltd.
5
  Link: http://www.swipehq.com/checkout/
6
+ http://www.magentocommerce.com/magento-connect/catalog/product/view/id/15121/
7
 
8
 
9
  REQUIREMENTS
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:
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.
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
+