SwipeHQ_Checkout - Version 1.4.0

Version Notes

Download this release

Release Info

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


Code changes from version 1.3.0 to 1.4.0

app/code/community/SwipeHQ/Checkout/etc/system.xml CHANGED
@@ -5,7 +5,95 @@
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
+
29
+ var currentURL = document.URL;
30
+ var urlToLoad = null;
31
+ var indexFound = currentURL.indexOf("index.php");
32
+
33
+ if(indexFound!=-1){
34
+ urlToLoad = currentURL.substring(0, indexFound)+"app/code/community/SwipeHQ/Checkout/etc/test-plugin.php?merchant_id="+merchantId+"&api_key="+apiKey+"&api_url="+apiURL+"&payment_page_url="+paymentURL;
35
+ }
36
+
37
+
38
+
39
+
40
+ if(urlToLoad!=null){
41
+ processAjax(urlToLoad);
42
+ }
43
+
44
+ function processAjax(url) {
45
+ var req = null;
46
+ if (window.XMLHttpRequest) { // Non-IE browsers
47
+ req = new XMLHttpRequest();
48
+ try {
49
+ req.onreadystatechange = targetDiv;
50
+ req.open("GET", url, true);
51
+ req.send(null);
52
+ } catch (e) {
53
+ alert(e);
54
+ }
55
+
56
+ } else if (window.ActiveXObject) { // IE
57
+ var req = new ActiveXObject("Microsoft.XMLHTTP");
58
+ if (req) {
59
+ req.onreadystatechange = targetDiv;
60
+ req.open("GET", url, true);
61
+ req.send();
62
+ }
63
+ }
64
+
65
+
66
+ function targetDiv() {
67
+ if(req!=null){
68
+ if (req.readyState == 4) { // Complete
69
+ if (req.status == 200) { // OK response
70
+ document.getElementById("check_config_results").innerHTML = req.responseText;
71
+ }
72
+ else{
73
+ alert("problem");
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+
81
+ }
82
+
83
+ document.observe("dom:loaded", function(){
84
+ var mainForm = document.getElementById("payment_swipehq");
85
+ var buttonToInsert = document.createElement("input");
86
+ buttonToInsert.setAttribute("type", "button");
87
+ buttonToInsert.setAttribute("value", "Check Config");
88
+ buttonToInsert.setAttribute("name", "checkconfig");
89
+ buttonToInsert.setAttribute("onclick", "check_config()");
90
+ buttonToInsert.setAttribute("style", "margin-top:30px");
91
+ mainForm.appendChild(buttonToInsert);
92
+
93
+ });
94
+ </script>
95
+ ]]>
96
+ </comment>
97
  <frontend_type>text</frontend_type>
98
  <sort_order>1</sort_order>
99
  <show_in_default>1</show_in_default>
app/code/community/SwipeHQ/Checkout/etc/test-plugin.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 td, th { padding: 1em 0.5em; border: 1px solid #aaa; }
113
+ #test_config_table .test-title { white-space: nowrap; font-weight: bold; }
114
+ #test_config_table .test-result { white-space: nowrap; }
115
+ #test_config_table .technical-details { color: #888; margin: 1em; padding: 0.5em; border: 1px solid #aaa; }
116
+ </style>
117
+
118
+ <div id="test_config_table">
119
+ <table>
120
+ <thead>
121
+ <tr>
122
+ <th colspan="3">
123
+ Swipe Plugin Test
124
+ </th>
125
+ </tr>
126
+ </thead>
127
+ <tbody>
128
+ <tr>
129
+ <td class="test-title">
130
+ 1. Minimum Requirements
131
+ </td>
132
+ <td class="test-result">
133
+ <?php echo testResultHtml($minRequirementsOK); ?>
134
+ </td>
135
+ <td class="test_info">
136
+ <?php if($minRequirementsOK === false){ ?>
137
+ Your shopping cart does not meet the minimum requirements to connect to Swipe. Please contact Swipe support.
138
+ <div class="technical-details">Technical details: curl is required.</div>
139
+ <?php } ?>
140
+ </td>
141
+ </tr>
142
+ <tr>
143
+ <td class="test-title">
144
+ 2. Connection to Swipe
145
+ </td>
146
+ <td class="test-result">
147
+ <?php echo testResultHtml($basicConnectionTestOK); ?>
148
+ </td>
149
+ <td class="test_info">
150
+ <?php if($basicConnectionTestOK === false){ ?>
151
+ Could not connect to Swipe. Check your API Url: "<?php echo $apiUrl; ?>", comparing it with the API Url
152
+ in your Swipe Merchant login under Settings -> API Credentials. If you are sure it is correct, Swipe
153
+ may be temporarily unreachable, please try again later.
154
+ <div class="technical-details">
155
+ Technical details: could not connect to: <?php echo htmlentities($basicConnectionTestUrl); ?>
156
+ </div>
157
+ <?php } ?>
158
+ </td>
159
+ </tr>
160
+ <tr>
161
+ <td class="test-title">
162
+ 3. Swipe Merchant Credentials
163
+ </td>
164
+ <td class="test-result">
165
+ <?php echo testResultHtml($credentialsOK); ?>
166
+ </td>
167
+ <td class="test_info">
168
+ <?php if($credentialsOK === false){ ?>
169
+ Your credentials are incorrect. Check your Merchant ID: "<?php echo $merchantId; ?>" and API Key: "<?php echo $apiKey; ?>",
170
+ comparing them to the details you see in your Swipe Merchant login under Settings -> API Credentials.
171
+ A common mistake is to have these two swapped around.
172
+ <div class="technical-details">
173
+ Technical details: called: <?php echo $credentialsUrl; ?>
174
+ </div>
175
+ <?php } ?>
176
+ </td>
177
+ </tr>
178
+ <tr>
179
+ <td class="test-title">
180
+ 4. Swipe Merchant Status
181
+ </td>
182
+ <td class="test-result">
183
+ <?php echo testResultHtml($merchantStatusOK); ?>
184
+ </td>
185
+ <td class="test_info">
186
+ <?php if($merchantStatusOK === false){ ?>
187
+ Your Swipe Merchant account is inactive, or does not have the Payment Page enabled. Please contact Swipe support.
188
+ <div class="technical-details">
189
+ Technical details: called: <?php echo $merchantStatusUrl; ?>
190
+ </div>
191
+ <?php } ?>
192
+ </td>
193
+ </tr>
194
+ <tr>
195
+ <td class="test-title">
196
+ 5. Plugin Configuration
197
+ </td>
198
+ <td class="test-result">
199
+ <?php echo testResultHtml($pluginConfigOK); ?>
200
+ </td>
201
+ <td class="test_info">
202
+ <?php if($pluginConfigOK === false){ ?>
203
+ Your plugin configuration is incorrect. Merchant ID, API Key, and API Url are OK, but something else is incorrectly configured.
204
+ Please double check your configuration, if the problem persists please contact Swipe support.
205
+ <div class="technical-details">
206
+ Technical details: <?php echo $pluginConfigResponse; ?>
207
+ Request: <?php echo htmlentities($pluginConfigUrl); ?>
208
+ </div>
209
+ <?php } ?>
210
+ </td>
211
+ </tr>
212
+
213
+
214
+
215
+ </tbody>
216
+ </table>
217
+ </div>
218
+ <?php
219
+
220
+ }catch(Exception $e){
221
+ echo self::$selfErrorMsg;
222
+ }
223
+
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.4.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,6 +1,6 @@
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
 
@@ -38,7 +38,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 +52,5 @@ 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 HQ Checkout plugin for Magento E-Commerce
2
 
3
+ Version: 1.4.0 / 20 Sep 2013
4
  Copyright: (c) 2012-2013, Optimizer Ltd.
5
  Link: http://www.swipehq.com/checkout/
6
 
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 -> Symbols
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
  - 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.4.0:
56
+ - Added test configuration button, fixed bug in package.xml file and added the missing file Permittedorderstates.php in Model directory