Version Notes
All issues fixed. Added product list Payair button functionality.
Download this release
Release Info
Developer | Christian Sanchez |
Extension | Payair_gate |
Version | 4.0.0.27 |
Comparing to | |
See all releases |
Code changes from version 4.0.0.23 to 4.0.0.27
app/code/community/Payair/Gate/controllers/IndexController.php
CHANGED
@@ -80,11 +80,17 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
80 |
"item" => $item,
|
81 |
"suggestedItems" => $suggested_items
|
82 |
);
|
|
|
83 |
$response_json = json_encode($response_array);
|
84 |
-
|
85 |
-
echo $response_json;
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
/**
|
89 |
* The function which take control over the web service request for Cart sync
|
90 |
*/
|
@@ -294,8 +300,7 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
294 |
"totalVat" => $this->getFormattedPrice($totalVat)
|
295 |
);
|
296 |
$response_json = json_encode($response_array);
|
297 |
-
|
298 |
-
echo $response_json;
|
299 |
|
300 |
|
301 |
}
|
@@ -487,8 +492,7 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
487 |
);
|
488 |
|
489 |
$response_json = json_encode($response_array);
|
490 |
-
|
491 |
-
echo $response_json;
|
492 |
|
493 |
}
|
494 |
|
@@ -567,8 +571,7 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
567 |
);
|
568 |
|
569 |
$response_json = json_encode($response_array);
|
570 |
-
|
571 |
-
echo $response_json;
|
572 |
}
|
573 |
|
574 |
/**
|
@@ -671,6 +674,7 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
671 |
*/
|
672 |
private function getServiceRequest() {
|
673 |
$json = file_get_contents('php://input');
|
|
|
674 |
$json = utf8_encode($json);
|
675 |
Mage::log("\n Request JSON is : \n" . print_r($json, true), null, $this->log_file);
|
676 |
return json_decode($json);
|
@@ -892,7 +896,7 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
892 |
$data_array = array(
|
893 |
"currency" => $this->getCurrencyISONumber(),
|
894 |
"totalAmount" => $this->getFormattedPrice($grandTotal),
|
895 |
-
"totalVat" => $totalVat,
|
896 |
"cart" => $item_array
|
897 |
);
|
898 |
|
@@ -1230,8 +1234,9 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
1230 |
}
|
1231 |
|
1232 |
$sort_order = ($total_options - $optionData['sort_order']) + 1; //calulate sort order in reverse to magento
|
|
|
1233 |
if( $sort_order <= 0 ) {
|
1234 |
-
$sort_order = $last_order - 1;
|
1235 |
}
|
1236 |
|
1237 |
$attributes[] = array(
|
@@ -1240,11 +1245,11 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
1240 |
"name" => $optionData['default_title'],
|
1241 |
"attributeValues" => $this->getAttributeValues($option, $product_obj, $cartOptionArr, $syncCartOptionArr),
|
1242 |
"customIdentifier" => $optionData['option_id'],
|
1243 |
-
"sortOrder" => ( $sort_order
|
1244 |
);
|
1245 |
$last_order = $sort_order;
|
1246 |
}
|
1247 |
-
}
|
1248 |
return !empty($attributes) ? $attributes : array();
|
1249 |
}
|
1250 |
|
@@ -1287,7 +1292,7 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
1287 |
"vat" => $this->getFormattedPrice( $this->getVatAmount( $option->getData('default_price'), $this->getVatPercent() ) ),
|
1288 |
"overrideImageUrl" => false,
|
1289 |
"customIdentifier" => $option->getData('option_id'),
|
1290 |
-
"sortOrder" => ( $sort_order
|
1291 |
);
|
1292 |
} else {
|
1293 |
$last_order = 0;
|
@@ -1305,7 +1310,7 @@ class Payair_Gate_IndexController extends Mage_Core_Controller_Front_Action {
|
|
1305 |
"vat" => $this->getFormattedPrice( $this->getVatAmount( $optionValueData['default_price'], $this->getVatPercent() ) ),
|
1306 |
"overrideImageUrl" => false,
|
1307 |
"customIdentifier" => $optionValueData['option_type_id'],
|
1308 |
-
"sortOrder" => ( $sort_order
|
1309 |
);
|
1310 |
$last_order = $sort_order;
|
1311 |
}
|
80 |
"item" => $item,
|
81 |
"suggestedItems" => $suggested_items
|
82 |
);
|
83 |
+
|
84 |
$response_json = json_encode($response_array);
|
85 |
+
$this->sendResponse($response_json, 'item Action');
|
|
|
86 |
}
|
87 |
|
88 |
+
private function sendResponse($data, $controller_name) {
|
89 |
+
Mage::log("\n send response from " . $controller_name . "\n" . print_r($data, true), null, $this->log_file);
|
90 |
+
$this->getResponse()->setHeader('Content-type', 'application/json', true);
|
91 |
+
echo $data;
|
92 |
+
}
|
93 |
+
|
94 |
/**
|
95 |
* The function which take control over the web service request for Cart sync
|
96 |
*/
|
300 |
"totalVat" => $this->getFormattedPrice($totalVat)
|
301 |
);
|
302 |
$response_json = json_encode($response_array);
|
303 |
+
$this->sendResponse($response_json, 'sync Action');
|
|
|
304 |
|
305 |
|
306 |
}
|
492 |
);
|
493 |
|
494 |
$response_json = json_encode($response_array);
|
495 |
+
$this->sendResponse($response_json, 'preverify Action');
|
|
|
496 |
|
497 |
}
|
498 |
|
571 |
);
|
572 |
|
573 |
$response_json = json_encode($response_array);
|
574 |
+
$this->sendResponse($response_json, 'result Action');
|
|
|
575 |
}
|
576 |
|
577 |
/**
|
674 |
*/
|
675 |
private function getServiceRequest() {
|
676 |
$json = file_get_contents('php://input');
|
677 |
+
//$json = '{"reference":"14","user":{"firstName":"Deepak","lastName":"Kumar","email":"deepakk@chetu.com","address1":"Dragarbrunnsgatan","city":"Anchorage","zip":"99501","country":"US","phoneNr":"9990976911","state":"Alaska","locale":"en_GB"},"cart":[]}';
|
678 |
$json = utf8_encode($json);
|
679 |
Mage::log("\n Request JSON is : \n" . print_r($json, true), null, $this->log_file);
|
680 |
return json_decode($json);
|
896 |
$data_array = array(
|
897 |
"currency" => $this->getCurrencyISONumber(),
|
898 |
"totalAmount" => $this->getFormattedPrice($grandTotal),
|
899 |
+
"totalVat" => $this->getFormattedPrice($totalVat),
|
900 |
"cart" => $item_array
|
901 |
);
|
902 |
|
1234 |
}
|
1235 |
|
1236 |
$sort_order = ($total_options - $optionData['sort_order']) + 1; //calulate sort order in reverse to magento
|
1237 |
+
|
1238 |
if( $sort_order <= 0 ) {
|
1239 |
+
$sort_order = $last_order - 1;
|
1240 |
}
|
1241 |
|
1242 |
$attributes[] = array(
|
1245 |
"name" => $optionData['default_title'],
|
1246 |
"attributeValues" => $this->getAttributeValues($option, $product_obj, $cartOptionArr, $syncCartOptionArr),
|
1247 |
"customIdentifier" => $optionData['option_id'],
|
1248 |
+
"sortOrder" => ( $sort_order > 0 ) ? $sort_order : 1
|
1249 |
);
|
1250 |
$last_order = $sort_order;
|
1251 |
}
|
1252 |
+
}
|
1253 |
return !empty($attributes) ? $attributes : array();
|
1254 |
}
|
1255 |
|
1292 |
"vat" => $this->getFormattedPrice( $this->getVatAmount( $option->getData('default_price'), $this->getVatPercent() ) ),
|
1293 |
"overrideImageUrl" => false,
|
1294 |
"customIdentifier" => $option->getData('option_id'),
|
1295 |
+
"sortOrder" => ( $sort_order > 0 ) ? $sort_order : 1
|
1296 |
);
|
1297 |
} else {
|
1298 |
$last_order = 0;
|
1310 |
"vat" => $this->getFormattedPrice( $this->getVatAmount( $optionValueData['default_price'], $this->getVatPercent() ) ),
|
1311 |
"overrideImageUrl" => false,
|
1312 |
"customIdentifier" => $optionValueData['option_type_id'],
|
1313 |
+
"sortOrder" => ( $sort_order > 0 ) ? $sort_order : 1
|
1314 |
);
|
1315 |
$last_order = $sort_order;
|
1316 |
}
|
app/design/frontend/default/default/layout/payair.xml
CHANGED
@@ -30,4 +30,13 @@
|
|
30 |
</reference>
|
31 |
</checkout_onepage_index>
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
</layout>
|
30 |
</reference>
|
31 |
</checkout_onepage_index>
|
32 |
|
33 |
+
<catalog_category_default translate="label">
|
34 |
+
<reference name="head">
|
35 |
+
<action method="addJs">
|
36 |
+
<script>payair/category.js</script>
|
37 |
+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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
function getPayairLocation() {
|
3 |
+
var url = 'https://payair.com/ms/';
|
4 |
+
var src = document.getElementById('Payair_Location').src;
|
5 |
+
|
6 |
+
var locals = [/localhost/, /10\.[0|2]\.[0-9]{1,3}\.[0-9]{1,3}/, /\.\.\//];
|
7 |
+
|
8 |
+
for (var i = 0; i < locals.length; i++) {
|
9 |
+
if (src.match(locals[i])) {
|
10 |
+
var uri = window.location;
|
11 |
+
url = uri.protocol + '//' + uri.host + '/ms/';
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
var matches = src.match(/(test|dev|qa)(?=\.payair\.com\/embed\/)/);
|
16 |
+
if (matches && matches.length > 0) {
|
17 |
+
url = 'https://' + matches[0] + '.payair.com/embed/';
|
18 |
+
}
|
19 |
+
|
20 |
+
return url;
|
21 |
+
}
|
22 |
+
|
23 |
+
function Init()
|
24 |
+
{
|
25 |
+
|
26 |
+
var userAgent = detectUserAgent();
|
27 |
+
|
28 |
+
// Create a Payair wrap which shall contain all Payair info:
|
29 |
+
createPayairProperties();
|
30 |
+
|
31 |
+
// Init scanbox vars:
|
32 |
+
var boxDims = getScanboxWidthHeight();
|
33 |
+
var scanboxWidth = boxDims[0];
|
34 |
+
var scanboxHeight = boxDims[1];
|
35 |
+
|
36 |
+
// Draw Scan infobox and wrapper:
|
37 |
+
drawScanInfo(scanboxWidth, scanboxHeight);
|
38 |
+
drawScanWrapper(userAgent);
|
39 |
+
drawTestIframe();
|
40 |
+
|
41 |
+
// Draw the Payair button on the ID that was returned:
|
42 |
+
drawPayairButton();
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
function getScanboxWidthHeight()
|
47 |
+
{
|
48 |
+
var scanboxWidth = 480;
|
49 |
+
var scanboxHeight = 340;
|
50 |
+
return new Array(scanboxWidth, scanboxHeight);
|
51 |
+
}
|
52 |
+
|
53 |
+
function drawTestIframe() {
|
54 |
+
var parent = document.body;
|
55 |
+
var child = document.createElement('iframe');
|
56 |
+
child.id="payairTestIframe-" + Payair_DATA.articleID;
|
57 |
+
child.target='top';
|
58 |
+
child.src='about:blank';
|
59 |
+
child.style.display = 'none';
|
60 |
+
parent.appendChild(child);
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
function drawScanInfo(width, height)
|
65 |
+
{
|
66 |
+
|
67 |
+
var userAgent = detectUserAgent();
|
68 |
+
// Get document width and height:
|
69 |
+
var dimensions = getViewPort();
|
70 |
+
|
71 |
+
// Draw the scaninfoWRAP at the specified coordinates with MAX width and height:
|
72 |
+
var childGuest = document.createElement("div");
|
73 |
+
childGuest.id = "Payair_scanbox-" + Payair_DATA.articleID;
|
74 |
+
//parentGuest.parentNode.insertBefore(childGuest, parentGuest.nextSibling);
|
75 |
+
document.body.appendChild(childGuest);
|
76 |
+
|
77 |
+
var e = document.getElementById('Payair_scanbox-' + Payair_DATA.articleID);
|
78 |
+
|
79 |
+
// Set styles for the Payair scanbox:
|
80 |
+
e.style.display = 'none';
|
81 |
+
e.style.zIndex = -1;
|
82 |
+
e.style.width = width+'px';
|
83 |
+
e.style.height = height+'px';
|
84 |
+
|
85 |
+
if ((userAgent == 'internet explorer') && (document.documentMode < 7))
|
86 |
+
{
|
87 |
+
e.style.position = 'absolute';
|
88 |
+
}
|
89 |
+
else e.style.position = 'fixed';
|
90 |
+
|
91 |
+
// Draw the contents for the scanbox:
|
92 |
+
drawScanboxContent(width, height);
|
93 |
+
|
94 |
+
// Get the positioning for the scanbox and place it:
|
95 |
+
var xy = getScanboxXY(dimensions, width, height);
|
96 |
+
placeObjectboxXY(xy, document.getElementById('Payair_scanbox-' + Payair_DATA.articleID));
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
function drawScanboxContent(width, height)
|
101 |
+
{
|
102 |
+
var closeTopMargin = -10;
|
103 |
+
var closeRightMargin = -10;
|
104 |
+
var Payair_main_location = Payair_DATA.getPayairLocation();
|
105 |
+
|
106 |
+
var e = document.getElementById('Payair_scanbox-' + Payair_DATA.articleID);
|
107 |
+
e.innerHTML = '<div onClick="hideScanWrapper('+Payair_DATA.articleID+'); hideScanBox('+Payair_DATA.articleID+'); return false;" id="Payair_close_iFrame-'+ Payair_DATA.articleID+'" style="position: absolute; top: '+closeTopMargin+'px; width: 25px; height: 25px; right: '+closeRightMargin+'px; z-index: 25000;"><img src="'+Payair_main_location+'img/close_button.png" onMouseOver="this.style.opacity = 0.75;" onmouseout="this.style.opacity = 1;" style="cursor: pointer; border: 0px;"></div><iframe id="Payair_iFrame-'+Payair_DATA.articleID+'" allowTransparency="true" name="Payair_iFrame-'+Payair_DATA.articleID+'" style="overflow:hidden; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,0.50); -moz-border-radius: 10px; -webkit-border-radius: 10px; -moz-box-shadow: 0 10px 40px rgba(0,0,0,0.50); -webkit-box-shadow: 0 10px 40px rgba(0,0,0,0.50); border: 0" width="480" height="340" scrolling="no"></iframe>';
|
108 |
+
}
|
109 |
+
|
110 |
+
function placeObjectboxXY(xy, e)
|
111 |
+
{
|
112 |
+
|
113 |
+
// Make y HALF of the height IF not IE QUIRKS:
|
114 |
+
xy[1] = Math.floor(xy[1] / 2);
|
115 |
+
|
116 |
+
e.style.left = xy[0]+'px';
|
117 |
+
e.style.top = xy[1]+'px';
|
118 |
+
}
|
119 |
+
|
120 |
+
function resizeWrapper()
|
121 |
+
{
|
122 |
+
setScanWrapXY(document.getElementById('Payair_scanwrap-' + Payair_DATA.articleID));
|
123 |
+
setScanWrapXY(document.getElementById('Payair_scanwrap_clickable-' + Payair_DATA.articleID));
|
124 |
+
}
|
125 |
+
|
126 |
+
function moveWrapper()
|
127 |
+
{
|
128 |
+
var userAgent = detectUserAgent();
|
129 |
+
if ((userAgent == 'internet explorer') && (document.documentMode < 7))
|
130 |
+
{
|
131 |
+
var e = document.getElementById('Payair_scanwrap-' + Payair_DATA.articleID);
|
132 |
+
e.style.top = document.body.scrollTop;
|
133 |
+
e.style.left = document.body.scrollLeft;
|
134 |
+
|
135 |
+
e = document.getElementById('Payair_scanwrap_clickable-' + Payair_DATA.articleID);
|
136 |
+
e.style.top = document.body.scrollTop;
|
137 |
+
e.style.left = document.body.scrollLeft;
|
138 |
+
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
function getScanboxXY(dimensions, width, height)
|
143 |
+
{
|
144 |
+
var ret = [];
|
145 |
+
|
146 |
+
var widthOffset;
|
147 |
+
var heightOffset;
|
148 |
+
var userAgent = detectUserAgent();
|
149 |
+
|
150 |
+
if ((userAgent == 'internet explorer') && (document.documentMode < 7))
|
151 |
+
{
|
152 |
+
var scrolledTop = document.body.scrollTop;
|
153 |
+
widthOffset = Math.floor((dimensions[0] - width) / 2);
|
154 |
+
heightOffset = (scrolledTop + Math.floor(((dimensions[1] - height) / 1.5))) * 2;
|
155 |
+
}
|
156 |
+
else
|
157 |
+
{
|
158 |
+
widthOffset = Math.floor(((dimensions[0] - width) / 2));
|
159 |
+
heightOffset = Math.floor(((dimensions[1] - height) / 1.5));
|
160 |
+
}
|
161 |
+
|
162 |
+
ret.push(widthOffset);
|
163 |
+
ret.push(heightOffset);
|
164 |
+
return ret;
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
function drawScanWrapper(userAgent)
|
169 |
+
{
|
170 |
+
// Get document width and height:
|
171 |
+
var dimensions = getDocDimensions();
|
172 |
+
|
173 |
+
// Draw the scaninfoWRAP at the specified coordinates with MAX width and height:
|
174 |
+
var childGuest = document.createElement("div");
|
175 |
+
childGuest.id = "Payair_scanwrap-" + Payair_DATA.articleID;
|
176 |
+
//parentGuest.parentNode.insertBefore(childGuest, parentGuest.nextSibling);
|
177 |
+
document.body.appendChild(childGuest);
|
178 |
+
|
179 |
+
var e = document.getElementById(childGuest.id);
|
180 |
+
|
181 |
+
// Set some styles to the scan wrapper:
|
182 |
+
e.style.display = 'none';
|
183 |
+
e.style.position = 'fixed';
|
184 |
+
e.style.top = '0';
|
185 |
+
e.style.left = '0';
|
186 |
+
e.style.right = '0';
|
187 |
+
e.style.bottom = '0';
|
188 |
+
|
189 |
+
if ((userAgent == 'internet explorer') && (document.documentMode < 7))
|
190 |
+
{
|
191 |
+
e.style.width = dimensions[0];
|
192 |
+
e.style.height = dimensions[1];
|
193 |
+
}
|
194 |
+
|
195 |
+
// Add the element that responds to a click inside the scanwrap:
|
196 |
+
e.innerHTML = '<div id="Payair_scanwrap_clickable-'+Payair_DATA.articleID+'" onClick="hideScanWrapper('+Payair_DATA.articleID+'); hideScanBox('+Payair_DATA.articleID+'); return false;" style="top: 0; left: 0; right: 0; bottom: 0"></div>';
|
197 |
+
|
198 |
+
// Set some styles to it:
|
199 |
+
e = document.getElementById('Payair_scanwrap_clickable-' + Payair_DATA.articleID);
|
200 |
+
e.style.display = 'none';
|
201 |
+
e.style.backgroundColor = '#000';
|
202 |
+
e.style.position = 'fixed';
|
203 |
+
e.style.top = '0';
|
204 |
+
e.style.left = '0';
|
205 |
+
e.style.right = '0';
|
206 |
+
e.style.bottom = '0';
|
207 |
+
|
208 |
+
// Alpha transparency?
|
209 |
+
if (userAgent == 'internet explorer')
|
210 |
+
{
|
211 |
+
e.style.filter ='progid:DXImageTransform.Microsoft.Alpha(Opacity=80)';
|
212 |
+
if (document.documentMode < 7)
|
213 |
+
{
|
214 |
+
e.style.width = dimensions[0];
|
215 |
+
e.style.height = dimensions[1];
|
216 |
+
e.style.position = 'absolute';
|
217 |
+
}
|
218 |
+
}
|
219 |
+
else
|
220 |
+
{
|
221 |
+
e.style.filter = 'alpha(opacity=0.1)';
|
222 |
+
e.style.opacity = 0.7;
|
223 |
+
}
|
224 |
+
|
225 |
+
setScanWrapXY(document.getElementById('Payair_scanwrap-' + Payair_DATA.articleID));
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
function setScanWrapXY(e)
|
230 |
+
{
|
231 |
+
var dimensions = getViewPort();
|
232 |
+
e.style.width = dimensions[0]+'px';
|
233 |
+
e.style.height = dimensions[1]+'px';
|
234 |
+
}
|
235 |
+
|
236 |
+
function startIframe(paramstring, articleID)
|
237 |
+
{
|
238 |
+
var e = document.getElementById('Payair_iFrame-' + articleID);
|
239 |
+
var Payair_main_location = Payair_DATA.getPayairLocation();
|
240 |
+
e.src=Payair_main_location+'index.html?'+paramstring;
|
241 |
+
}
|
242 |
+
|
243 |
+
function setParamStringForIframe(merchantreference, articleID, product_name, product_price, product_currency)
|
244 |
+
{
|
245 |
+
return 'type=product&merchant_reference='+merchantreference+'&article_id='+articleID+'&product_name='+product_name+'&product_price='+product_price+'&product_currency='+product_currency;
|
246 |
+
}
|
247 |
+
|
248 |
+
function showScanInfo(articleID)
|
249 |
+
{
|
250 |
+
// Set box to slighty more than wrapper:
|
251 |
+
var e = document.getElementById('Payair_scanbox-' + articleID);
|
252 |
+
e.style.zIndex = 20000;
|
253 |
+
e.style.display = 'inline';
|
254 |
+
|
255 |
+
var flashnodes = Payair_DATA.toArray(document.getElementsByTagName('object'));
|
256 |
+
|
257 |
+
var loop = 0;
|
258 |
+
while (loop < flashnodes.length)
|
259 |
+
{
|
260 |
+
flashnodes[loop].style.visibility = 'hidden';
|
261 |
+
loop++;
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
265 |
+
|
266 |
+
function showScanWrapper(articleID)
|
267 |
+
{
|
268 |
+
// Set Wrapper zIndex to slightly less than actual box:
|
269 |
+
var e = document.getElementById('Payair_scanwrap-' + articleID);
|
270 |
+
e.style.zIndex = 9000;
|
271 |
+
e.style.display = 'inline';
|
272 |
+
|
273 |
+
e = document.getElementById('Payair_scanwrap_clickable-' + articleID);
|
274 |
+
|
275 |
+
e.style.zIndex = 9000;
|
276 |
+
e.style.display = 'inline';
|
277 |
+
|
278 |
+
e = document.getElementById('Payair_button-' + articleID);
|
279 |
+
e.style.visibility = 'hidden';
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
function hideScanWrapper(articleID)
|
284 |
+
{
|
285 |
+
|
286 |
+
var e = document.getElementById('Payair_scanwrap-' + articleID);
|
287 |
+
e.style.display = 'none';
|
288 |
+
|
289 |
+
e = document.getElementById('Payair_button-' + articleID);
|
290 |
+
e.style.visibility = 'visible';
|
291 |
+
}
|
292 |
+
|
293 |
+
function hideScanBox(articleID)
|
294 |
+
{
|
295 |
+
var e = document.getElementById('Payair_scanbox-' + articleID);
|
296 |
+
e.style.display = 'none';
|
297 |
+
e.style.zIndex = -1;
|
298 |
+
|
299 |
+
var flashnodes = Payair_DATA.toArray(document.getElementsByTagName('object'));
|
300 |
+
|
301 |
+
var loop = 0;
|
302 |
+
while (loop < flashnodes.length)
|
303 |
+
{
|
304 |
+
flashnodes[loop].style.visibility = 'visible';
|
305 |
+
loop++;
|
306 |
+
}
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
function createPayairProperties()
|
311 |
+
{
|
312 |
+
var parentGuest = document.getElementById("Payair_QR-"+Payair_DATA.articleID);
|
313 |
+
var childGuest = document.createElement("div");
|
314 |
+
childGuest.id = "Payair_mainwrap-"+Payair_DATA.articleID;
|
315 |
+
parentGuest.parentNode.insertBefore(childGuest, parentGuest.nextSibling);
|
316 |
+
|
317 |
+
return childGuest.id;
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
function drawPayairButton()
|
322 |
+
{
|
323 |
+
|
324 |
+
// Create a button and make scanwrap its parent:
|
325 |
+
var parentGuest = document.getElementById("Payair_mainwrap-" + Payair_DATA.articleID);
|
326 |
+
var childGuest = document.createElement("div");
|
327 |
+
childGuest.id = "Payair_button-" + Payair_DATA.articleID;
|
328 |
+
parentGuest.parentNode.insertBefore(childGuest, parentGuest.nextSibling);
|
329 |
+
|
330 |
+
// Create a reference to the mainID:
|
331 |
+
var target = childGuest.id;
|
332 |
+
// Add contents to string:
|
333 |
+
var text = '';
|
334 |
+
|
335 |
+
if (detectMobileDevice() == false)
|
336 |
+
{
|
337 |
+
text = '<img onMouseOver="this.style.opacity = 0.75;" onmouseout="this.style.opacity = 1;" src="' + getPayairLocation() + 'img/payair_button.png" onClick="Payair_DATA.releaseHelpActive(); startProductPopup('+Payair_DATA.articleID+'); showScanInfo('+Payair_DATA.articleID+'); showScanWrapper('+Payair_DATA.articleID+'); return false;" style="cursor: pointer;" />';
|
338 |
+
}
|
339 |
+
else
|
340 |
+
{
|
341 |
+
text = '<img onMouseOver="this.style.opacity = 0.75;" onmouseout="this.style.opacity = 1;" src="' + getPayairLocation() + 'img/payair_button.png" onClick="redirectByProduct(); return false;" style="cursor: pointer;">';
|
342 |
+
}
|
343 |
+
// Apply string to target:
|
344 |
+
document.getElementById(target).innerHTML=text;
|
345 |
+
|
346 |
+
var e = document.getElementById('Payair_button-' + Payair_DATA.articleID);
|
347 |
+
e.style.display = 'inline';
|
348 |
+
e.style.zIndex = 10000;
|
349 |
+
|
350 |
+
}
|
351 |
+
|
352 |
+
function getStoreFallback() {
|
353 |
+
|
354 |
+
var fallbackUrl;
|
355 |
+
|
356 |
+
if ((detectMobileDevice() == 'iphone') || (detectMobileDevice() == 'ipad')) fallbackUrl = 'http://itunes.apple.com/se/app/payair/id411434027?mt=8';
|
357 |
+
else if (detectMobileDevice() == 'android') fallbackUrl = 'https://market.android.com/details?id=com.most.android';
|
358 |
+
|
359 |
+
return fallbackUrl;
|
360 |
+
}
|
361 |
+
|
362 |
+
function redirectByProduct() {
|
363 |
+
|
364 |
+
var varStatus = Payair_DATA.getVarStatus();
|
365 |
+
var v_id;
|
366 |
+
|
367 |
+
if (varStatus[0] === '0') {
|
368 |
+
v_id = '1_';
|
369 |
+
varStatus[0] = '';
|
370 |
+
}
|
371 |
+
else v_id = '1_02';
|
372 |
+
|
373 |
+
var URL = 'payair://'+v_id+''+varStatus[0]+''+varStatus[1];
|
374 |
+
|
375 |
+
var MARKET = "https://market.android.com/details?id=com.most.android";
|
376 |
+
var ITUNES = "http://itunes.apple.com/se/app/payair/id411434027?mt=8";
|
377 |
+
|
378 |
+
if (navigator.userAgent.match(/Android/)) {
|
379 |
+
|
380 |
+
if (navigator.userAgent.match(/Chrome/)) {
|
381 |
+
// Jelly Bean with Chrome browser
|
382 |
+
setTimeout(function() {
|
383 |
+
if (!document.webkitHidden)
|
384 |
+
window.location = MARKET;
|
385 |
+
}, 1000);
|
386 |
+
|
387 |
+
window.location = URL;
|
388 |
+
} else {
|
389 |
+
// Older Android browser
|
390 |
+
var iframe = document.createElement("iframe");
|
391 |
+
iframe.style.border = "none";
|
392 |
+
iframe.style.width = "1px";
|
393 |
+
iframe.style.height = "1px";
|
394 |
+
|
395 |
+
if (navigator.userAgent.match(/HTC/)) {
|
396 |
+
// HTC
|
397 |
+
var e = (new Date()).getTime();
|
398 |
+
setTimeout(function () {
|
399 |
+
var a = (new Date()).getTime();
|
400 |
+
if ((a - e) < 1000) {
|
401 |
+
setTimeout(function() { document.location.href = MARKET; }, 0);
|
402 |
+
}
|
403 |
+
}, 500);
|
404 |
+
|
405 |
+
} else {
|
406 |
+
// Other
|
407 |
+
var t = setTimeout(function() {
|
408 |
+
window.location = MARKET;
|
409 |
+
}, 1000);
|
410 |
+
|
411 |
+
if (window.attachEvent) window.attachEvent('onload', clearTimeout(t));
|
412 |
+
else window.addEventListener('load', function() {
|
413 |
+
clearTimeout(t);
|
414 |
+
}, false);
|
415 |
+
}
|
416 |
+
|
417 |
+
iframe.src = URL;
|
418 |
+
document.body.appendChild(iframe);
|
419 |
+
}
|
420 |
+
|
421 |
+
} else if (navigator.userAgent.match(/iPhone|iPad|iPod/)) {
|
422 |
+
// IOS
|
423 |
+
|
424 |
+
setTimeout(function() {
|
425 |
+
if (!document.webkitHidden) {
|
426 |
+
window.location = ITUNES;
|
427 |
+
}
|
428 |
+
}, 25);
|
429 |
+
|
430 |
+
window.location = URL;
|
431 |
+
}
|
432 |
+
else {
|
433 |
+
// No matching device, try launch:
|
434 |
+
document.location.href = URL;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
function getEmbedVars(vars)
|
439 |
+
{
|
440 |
+
// Set local vars:
|
441 |
+
var merchantreference = false;
|
442 |
+
var articleID = false;
|
443 |
+
|
444 |
+
var product_price = false;
|
445 |
+
var product_name = false;
|
446 |
+
var product_currency = false;
|
447 |
+
var payairFailure = false;
|
448 |
+
var errormsgs = [];
|
449 |
+
|
450 |
+
/*
|
451 |
+
//script gets the src attribute based on ID of page's script element:
|
452 |
+
var requestURL = document.getElementById("Payair_QR").getAttribute("src");
|
453 |
+
|
454 |
+
//next use substring() to get querystring part of src
|
455 |
+
var queryString = requestURL.substring(requestURL.indexOf("?") + 1, requestURL.length);
|
456 |
+
|
457 |
+
//Next split the querystring into array
|
458 |
+
var params = queryString.split("&");
|
459 |
+
|
460 |
+
var payairFailure = false;
|
461 |
+
|
462 |
+
|
463 |
+
//Next loop through params
|
464 |
+
for(var i = 0; i < params.length; i++)
|
465 |
+
{
|
466 |
+
var value = params[i].substring(params[i].indexOf("=") + 1, params[i].length);
|
467 |
+
|
468 |
+
params[i] = params[i].replace(value, "'" + value + "'");
|
469 |
+
|
470 |
+
eval(params[i]);
|
471 |
+
}
|
472 |
+
*/
|
473 |
+
|
474 |
+
// A long segment of if statements regarding if the variables sent with the embed code is valid and set:
|
475 |
+
if (vars.product_price === false)
|
476 |
+
{
|
477 |
+
errormsgs.push('Parameter/variable "product_price" was not set, contained illegal characters, or was not numeric. Please specify numbers only without blankspaces. (Example: checkout_price=599)');
|
478 |
+
payairFailure = true;
|
479 |
+
}
|
480 |
+
else Payair_DATA.setProductPrice(vars.product_price);
|
481 |
+
|
482 |
+
if (vars.product_name == false)
|
483 |
+
{
|
484 |
+
errormsgs.push('Parameter/variable "product_name" was not set or contained illegal characters. Please specify a valid product_name. (Example: product_name=LED TV 42 Inches)');
|
485 |
+
payairFailure = true;
|
486 |
+
}
|
487 |
+
else Payair_DATA.setProductName(vars.product_name);
|
488 |
+
|
489 |
+
if (vars.product_currency == false)
|
490 |
+
{
|
491 |
+
errormsgs.push('Parameter/variable "product_currency" was not set or contained illegal characters. Please specify a valid product_currency. (Example: product_currency=SEK)');
|
492 |
+
payairFailure = true;
|
493 |
+
}
|
494 |
+
else Payair_DATA.setProductCurrency(vars.product_currency);
|
495 |
+
|
496 |
+
if (vars.merchantreference === false)
|
497 |
+
{
|
498 |
+
errormsgs.push('Parameter/variable "merchantreference" was not set or contained illegal characters. Please specify a valid merchantreference. (Example: merchantreference=100019)');
|
499 |
+
payairFailure = true;
|
500 |
+
}
|
501 |
+
else Payair_DATA.setMerchantReference(vars.merchantreference);
|
502 |
+
|
503 |
+
if (vars.articleID == false)
|
504 |
+
{
|
505 |
+
errormsgs.push('Parameter/variable "articleID" was not set or contained illegal characters. Please specify a valid merchantreference. (Example: articleID=373-BB-33)');
|
506 |
+
payairFailure = true;
|
507 |
+
}
|
508 |
+
else Payair_DATA.setArticleID(vars.articleID);
|
509 |
+
|
510 |
+
if (payairFailure == true)
|
511 |
+
{
|
512 |
+
logErrorsToConsole(errormsgs);
|
513 |
+
return false;
|
514 |
+
}
|
515 |
+
Payair_DATA.setVarStatus();
|
516 |
+
return true;
|
517 |
+
|
518 |
+
}
|
519 |
+
|
520 |
+
function logErrorsToConsole(msgs)
|
521 |
+
{
|
522 |
+
|
523 |
+
// Function for logging errors to console:
|
524 |
+
console.log('One or more errors found, dumping error data:');
|
525 |
+
|
526 |
+
var loop = 0;
|
527 |
+
// Go through the loop and log the errors that are sent with the array:
|
528 |
+
while (loop < msgs.length)
|
529 |
+
{
|
530 |
+
console.log('Error: '+msgs[loop]);
|
531 |
+
loop++;
|
532 |
+
}
|
533 |
+
|
534 |
+
console.log('- Please refer to this documentation for further assistance: http://www.payair.com/dev/eng/qr_implementation.php');
|
535 |
+
console.log('- - End of Payair error messages, exiting..');
|
536 |
+
}
|
537 |
+
|
538 |
+
function IsNumeric(strString)
|
539 |
+
// check for valid numeric strings
|
540 |
+
{
|
541 |
+
var strValidChars = "0123456789.-";
|
542 |
+
var strChar;
|
543 |
+
var blnResult = true;
|
544 |
+
|
545 |
+
if (strString.length == 0) return false;
|
546 |
+
|
547 |
+
// test strString consists of valid characters listed above
|
548 |
+
for (var i = 0; i < strString.length && blnResult == true; i++)
|
549 |
+
{
|
550 |
+
strChar = strString.charAt(i);
|
551 |
+
if (strValidChars.indexOf(strChar) == -1)
|
552 |
+
{
|
553 |
+
blnResult = false;
|
554 |
+
}
|
555 |
+
}
|
556 |
+
return blnResult;
|
557 |
+
}
|
558 |
+
|
559 |
+
function startIframeInfoOnly()
|
560 |
+
{
|
561 |
+
Payair_DATA.setHelpActive();
|
562 |
+
|
563 |
+
var e = document.getElementById('Payair_iFrame-' + Payair_DATA.articleID);
|
564 |
+
var Payair_main_location = Payair_DATA.getPayairLocation();
|
565 |
+
e.src=Payair_main_location+'index.html?page=help';
|
566 |
+
showScanInfo(Payair_DATA.articleID);
|
567 |
+
showScanWrapper(Payair_DATA.articleID);
|
568 |
+
}
|
569 |
+
|
570 |
+
function getViewPort()
|
571 |
+
{
|
572 |
+
// ALWAYS GET THE VIEWPORT IF WINDOW WOULD HAVE BEEN RESIZED:
|
573 |
+
|
574 |
+
var viewportwidth;
|
575 |
+
var viewportheight;
|
576 |
+
|
577 |
+
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
|
578 |
+
|
579 |
+
if (typeof window.innerWidth != 'undefined')
|
580 |
+
{
|
581 |
+
viewportwidth = window.innerWidth;
|
582 |
+
viewportheight = window.innerHeight;
|
583 |
+
}
|
584 |
+
|
585 |
+
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
|
586 |
+
|
587 |
+
else if (typeof document.documentElement != 'undefined'
|
588 |
+
&& typeof document.documentElement.clientWidth !=
|
589 |
+
'undefined' && document.documentElement.clientWidth != 0)
|
590 |
+
{
|
591 |
+
viewportwidth = document.documentElement.clientWidth;
|
592 |
+
viewportheight = document.documentElement.clientHeight;
|
593 |
+
}
|
594 |
+
|
595 |
+
// older versions of IE
|
596 |
+
|
597 |
+
else
|
598 |
+
{
|
599 |
+
viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
|
600 |
+
viewportheight = document.getElementsByTagName('body')[0].clientHeight;
|
601 |
+
}
|
602 |
+
|
603 |
+
// Return an array with the width and height of the viewport:
|
604 |
+
return [viewportwidth, viewportheight];
|
605 |
+
}
|
606 |
+
|
607 |
+
function getDocDimensions()
|
608 |
+
{
|
609 |
+
var D = document;
|
610 |
+
|
611 |
+
var maxwidth = Math.max(
|
612 |
+
Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
|
613 |
+
Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
|
614 |
+
Math.max(D.body.clientWidth, D.documentElement.clientWidth)
|
615 |
+
);
|
616 |
+
var maxheight = Math.max(
|
617 |
+
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
|
618 |
+
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
|
619 |
+
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
|
620 |
+
);
|
621 |
+
return [maxwidth, maxheight];
|
622 |
+
}
|
623 |
+
|
624 |
+
function prepareScanboxReposition()
|
625 |
+
{
|
626 |
+
|
627 |
+
var dimensions;
|
628 |
+
// Get the width and height of document:
|
629 |
+
dimensions = getViewPort();
|
630 |
+
|
631 |
+
// Get and Set Scanbox Position:
|
632 |
+
var boxDims = getScanboxWidthHeight();
|
633 |
+
|
634 |
+
// Set width and height from result:
|
635 |
+
var width = boxDims[0];
|
636 |
+
var height = boxDims[1];
|
637 |
+
|
638 |
+
var xy = getScanboxXY(dimensions, width, height);
|
639 |
+
placeObjectboxXY(xy,document.getElementById('Payair_scanbox-' + Payair_DATA.articleID));
|
640 |
+
|
641 |
+
}
|
642 |
+
|
643 |
+
function detectUserAgent()
|
644 |
+
{
|
645 |
+
var browser = navigator.userAgent.toLowerCase();
|
646 |
+
var appname = navigator.appName.toLowerCase();
|
647 |
+
|
648 |
+
var useragents = ['internet explorer', 'opera', 'firefox', 'chrome'];
|
649 |
+
var loop = 0;
|
650 |
+
while (loop < useragents.length)
|
651 |
+
{
|
652 |
+
|
653 |
+
// If a mobile device browser is found, set the agentfound to true:
|
654 |
+
if ((browser.indexOf(useragents[loop]) != -1) || (appname.indexOf(useragents[loop]) != -1))
|
655 |
+
{
|
656 |
+
var userAgent = useragents[loop];
|
657 |
+
break;
|
658 |
+
}
|
659 |
+
loop++;
|
660 |
+
}
|
661 |
+
|
662 |
+
return userAgent;
|
663 |
+
|
664 |
+
}
|
665 |
+
|
666 |
+
function detectMobileDevice()
|
667 |
+
{
|
668 |
+
|
669 |
+
// Set the possible user agents for cellphones:
|
670 |
+
var useragents = ['ipod', 'iphone', 'ipad', 'android', 'windows phone'];
|
671 |
+
|
672 |
+
var loop = 0;
|
673 |
+
|
674 |
+
// Mobile device OS is NOT found by default:
|
675 |
+
var agentfound = false;
|
676 |
+
var browser = navigator.userAgent.toLowerCase();
|
677 |
+
|
678 |
+
// Go through the loop for useragent checks:
|
679 |
+
while (loop < useragents.length)
|
680 |
+
{
|
681 |
+
|
682 |
+
// If a mobile device browser is found, set the agentfound to true:
|
683 |
+
if (browser.indexOf(useragents[loop]) != -1)
|
684 |
+
{
|
685 |
+
agentfound = useragents[loop];
|
686 |
+
break;
|
687 |
+
}
|
688 |
+
loop++;
|
689 |
+
}
|
690 |
+
|
691 |
+
// Return true or false depending if mobile device was found or not:
|
692 |
+
return agentfound;
|
693 |
+
}
|
694 |
+
|
695 |
+
function WindowResized()
|
696 |
+
{
|
697 |
+
prepareScanboxReposition();
|
698 |
+
resizeWrapper();
|
699 |
+
}
|
700 |
+
|
701 |
+
function WindowScrolled()
|
702 |
+
{
|
703 |
+
prepareScanboxReposition();
|
704 |
+
moveWrapper();
|
705 |
+
}
|
706 |
+
function po (d) {
|
707 |
+
var o = '';
|
708 |
+
for (i in d) {
|
709 |
+
o += i + " : " + d[i] + "\n";
|
710 |
+
}
|
711 |
+
alert(o);
|
712 |
+
}
|
713 |
+
function startProductPopup(articleID)
|
714 |
+
{
|
715 |
+
var varStatus = Payair_DATA.getVarStatus(articleID);
|
716 |
+
var paramstring = setParamStringForIframe(varStatus[0], varStatus[1], varStatus[2], varStatus[3], varStatus[4]);
|
717 |
+
|
718 |
+
startIframe(paramstring, articleID);
|
719 |
+
|
720 |
+
}
|
721 |
+
|
722 |
+
function onReadyInit()
|
723 |
+
{
|
724 |
+
//if (payair_vars != false)
|
725 |
+
//{
|
726 |
+
//Init();
|
727 |
+
|
728 |
+
//}
|
729 |
+
}
|
730 |
+
|
731 |
+
|
732 |
+
Payair_DATA = {
|
733 |
+
|
734 |
+
// Checkout:
|
735 |
+
articleID: false,
|
736 |
+
product_name: false,
|
737 |
+
product_price: false,
|
738 |
+
product_currency: false,
|
739 |
+
merchantreference: false,
|
740 |
+
help_active: true,
|
741 |
+
payair_location: getPayairLocation(),
|
742 |
+
|
743 |
+
setArticleID: function(input)
|
744 |
+
{
|
745 |
+
this.articleID = input
|
746 |
+
},
|
747 |
+
|
748 |
+
setProductPrice: function(input)
|
749 |
+
{
|
750 |
+
this.product_price = input
|
751 |
+
},
|
752 |
+
|
753 |
+
setProductName: function(input)
|
754 |
+
{
|
755 |
+
this.product_name = input
|
756 |
+
},
|
757 |
+
|
758 |
+
setProductCurrency: function(input)
|
759 |
+
{
|
760 |
+
this.product_currency = input
|
761 |
+
},
|
762 |
+
|
763 |
+
setMerchantReference: function(input)
|
764 |
+
{
|
765 |
+
this.merchantreference = input
|
766 |
+
},
|
767 |
+
|
768 |
+
setHelpActive: function()
|
769 |
+
{
|
770 |
+
this.help_active = true
|
771 |
+
},
|
772 |
+
|
773 |
+
releaseHelpActive: function()
|
774 |
+
{
|
775 |
+
this.help_active = false;
|
776 |
+
},
|
777 |
+
|
778 |
+
getVarStatus: function(articalId)
|
779 |
+
{
|
780 |
+
//return new Array(this.merchantreference, this.articleID, this.product_name, this.product_price, this.product_currency);
|
781 |
+
return this.collection_varstatus[articalId];
|
782 |
+
},
|
783 |
+
setVarStatus: function () {
|
784 |
+
if (this.collection_varstatus===undefined) {
|
785 |
+
this.collection_varstatus = Array();
|
786 |
+
this.collection_varstatus[this.articleID] = new Array(this.merchantreference, this.articleID, this.product_name, this.product_price, this.product_currency);
|
787 |
+
} else {
|
788 |
+
this.collection_varstatus[this.articleID] = new Array(this.merchantreference, this.articleID, this.product_name, this.product_price, this.product_currency);
|
789 |
+
}
|
790 |
+
},
|
791 |
+
getPayairLocation: function()
|
792 |
+
{
|
793 |
+
return this.payair_location;
|
794 |
+
},
|
795 |
+
toArray: function (collection) {
|
796 |
+
var arr = [];
|
797 |
+
|
798 |
+
for (var i = collection.length >>> 0; i--;) {
|
799 |
+
arr[i] = collection[i];
|
800 |
+
}
|
801 |
+
|
802 |
+
return arr;
|
803 |
+
}
|
804 |
+
};
|
805 |
+
|
806 |
+
//var payair_vars = getEmbedVars(Payair_DATA);
|
807 |
+
|
808 |
+
onReadyInit();
|
809 |
+
|
810 |
+
function bindReady(handler){
|
811 |
+
var called = false;
|
812 |
+
function ready() {
|
813 |
+
if (called) return;
|
814 |
+
called = true;
|
815 |
+
handler();
|
816 |
+
}
|
817 |
+
if ( document.addEventListener ) {
|
818 |
+
document.addEventListener( "DOMContentLoaded", function(){
|
819 |
+
ready()
|
820 |
+
}, false )
|
821 |
+
} else if ( document.attachEvent ) {
|
822 |
+
if ( document.documentElement.doScroll && window == window.top ) {
|
823 |
+
function tryScroll(){
|
824 |
+
if (called) return;
|
825 |
+
if (!document.body) return;
|
826 |
+
try {
|
827 |
+
document.documentElement.doScroll("left");
|
828 |
+
ready()
|
829 |
+
} catch(e) {
|
830 |
+
setTimeout(tryScroll, 0)
|
831 |
+
}
|
832 |
+
}
|
833 |
+
tryScroll();
|
834 |
+
}
|
835 |
+
document.attachEvent("onreadystatechange", function(){
|
836 |
+
if ( document.readyState === "complete" ) {
|
837 |
+
ready();
|
838 |
+
}
|
839 |
+
})
|
840 |
+
}
|
841 |
+
if (window.addEventListener) window.addEventListener('load', ready, false);
|
842 |
+
else if (window.attachEvent) window.attachEvent('onload', ready);
|
843 |
+
/* else // use this 'else' statement for very old browsers :)
|
844 |
+
window.onload=ready
|
845 |
+
*/
|
846 |
+
}
|
847 |
+
readyList = [];
|
848 |
+
function onReady(handler) {
|
849 |
+
if (!readyList.length) {
|
850 |
+
bindReady(function() {
|
851 |
+
for(var i=0; i<readyList.length; i++) {
|
852 |
+
readyList[i]()
|
853 |
+
}
|
854 |
+
})
|
855 |
+
}
|
856 |
+
readyList.push(handler)
|
857 |
+
}
|
858 |
+
|
859 |
+
window.onresize = WindowResized;
|
860 |
+
window.onscroll = WindowScrolled;
|
861 |
+
|
862 |
+
onReady(function() {
|
863 |
+
setScanWrapXY(document.getElementById('Payair_scanwrap-' + Payair_DATA.articleID));
|
864 |
+
setScanWrapXY(document.getElementById('Payair_scanwrap_clickable-' + Payair_DATA.articleID));
|
865 |
+
});
|
media/payair/test.html
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script>
|
2 |
+
|
3 |
+
var url = 'https://payair.com/ms/';
|
4 |
+
alert(1);
|
5 |
+
var src = document.getElementById('Payair_QR').src;
|
6 |
+
|
7 |
+
var locals = [/localhost/, /10\.[0|2]\.[0-9]{1,3}\.[0-9]{1,3}/, /\.\.\//];
|
8 |
+
|
9 |
+
for (var i = 0; i < locals.length; i++) {
|
10 |
+
if (src.match(locals[i])) {
|
11 |
+
alert(locals[i]);
|
12 |
+
var uri = window.location;
|
13 |
+
url = uri.protocol + '//' + uri.host + '/ms/';
|
14 |
+
}
|
15 |
+
}
|
16 |
+
</script>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Payair_gate</name>
|
4 |
-
<version>4.0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Payair payment gateway version 4</summary>
|
10 |
-
<description>
|
11 |
-
<notes>All issues fixed.</notes>
|
12 |
-
<authors><author><name>
|
13 |
-
<date>2013-
|
14 |
-
<time>17:
|
15 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Payair_Gate.xml" hash="ab09c7de9ca9ce3629379a8375ae7fc3"/><file name="Payair_Adminhtml.xml" hash="051013e3888ebf812048921073dae688"/></dir></target><target name="magecommunity"><dir name="Payair"><dir name="Gate"><dir name="Block"><file name="Paycheckout.php" hash="80d88175ae9a5e5070e9c18e40bb6249"/><file name="Paymentjs.php" hash="0b609f0c6f4eee18661d0bbb789c9d58"/><file name="Payproduct.php" hash="aa7ae8f31495bdc5a86c4a5103affd9f"/></dir><dir name="Helper"><file name="Data.php" hash="d57a44055ef38461cb28fe3879db9d4b"/></dir><dir name="Model"><file name="Checkout.php" hash="393cb22fb500e95d79ab254c0464b56f"/><file name="Display.php" hash="9f7c3918df8535f1256759271e50f86e"/><file name="Environment.php" hash="f131e5aa46136420acbaffcbef41a10b"/><file name="Observer.php" hash="65a788233ddee12440477d940d8ca927"/><dir name="Order"><dir name="Api"><file name="V2.php" hash="918fdca710f1e424093bc6e8f386bf3c"/></dir><file name="Api.php" hash="73bf707e89776d73fb7acba455bb157e"/></dir><file name="Payair.php" hash="99d39c96bbfdb533249f7746f882c057"/><file name="RestConnect_Model_Oauth_Client.php" hash="2b25cd997acb20d8b67cb2443357bb5c"/></dir><dir name="controllers"><file name="IndexController.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Payair_gate</name>
|
4 |
+
<version>4.0.0.27</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Payair payment gateway version 4</summary>
|
10 |
+
<description>Simplified and secure shopping solution for your customers. Allows checkout in less than 10 seconds.</description>
|
11 |
+
<notes>All issues fixed. Added product list Payair button functionality.</notes>
|
12 |
+
<authors><author><name>Christian Sanchez</name><user>payair</user><email>christian.sanchez@payair.com</email></author></authors>
|
13 |
+
<date>2013-10-01</date>
|
14 |
+
<time>17:47:40</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Payair_Gate.xml" hash="ab09c7de9ca9ce3629379a8375ae7fc3"/><file name="Payair_Adminhtml.xml" hash="051013e3888ebf812048921073dae688"/></dir></target><target name="magecommunity"><dir name="Payair"><dir name="Gate"><dir name="Block"><file name="Paycheckout.php" hash="80d88175ae9a5e5070e9c18e40bb6249"/><file name="Paymentjs.php" hash="0b609f0c6f4eee18661d0bbb789c9d58"/><file name="Payproduct.php" hash="aa7ae8f31495bdc5a86c4a5103affd9f"/></dir><dir name="Helper"><file name="Data.php" hash="d57a44055ef38461cb28fe3879db9d4b"/></dir><dir name="Model"><file name="Checkout.php" hash="393cb22fb500e95d79ab254c0464b56f"/><file name="Display.php" hash="9f7c3918df8535f1256759271e50f86e"/><file name="Environment.php" hash="f131e5aa46136420acbaffcbef41a10b"/><file name="Observer.php" hash="65a788233ddee12440477d940d8ca927"/><dir name="Order"><dir name="Api"><file name="V2.php" hash="918fdca710f1e424093bc6e8f386bf3c"/></dir><file name="Api.php" hash="73bf707e89776d73fb7acba455bb157e"/></dir><file name="Payair.php" hash="99d39c96bbfdb533249f7746f882c057"/><file name="RestConnect_Model_Oauth_Client.php" hash="2b25cd997acb20d8b67cb2443357bb5c"/></dir><dir name="controllers"><file name="IndexController.php" hash="3c5bab8c0377069be5caf0d8aa492899"/></dir><dir name="etc"><file name="config.xml" hash="cf1b4df4baf2e1d7fec1fe995f8fa4d3"/><file name="system.xml" hash="5fda863ccaf4ccc70e92f00fbfc7bc2f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="gate"><file name="button.phtml" hash="fae99d344c5a3900c6bf52104b633e17"/><file name="checkout.phtml" hash="06b37288aafb0a4da7d735dc89c93804"/><file name="product.phtml" hash="cac4a0d9dbc33f80086042c8868e5918"/></dir></dir><dir name="layout"><file name="payair.xml" hash="6f4ee086cddac14e810cec8503a7fb3e"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="payair.css" hash="9faab5311b422d70708626ac641251ea"/></dir><dir name="js"><dir name="payair"><file name="payaircheckout.js" hash="d37d8ae1ddb2dee75ced96bc1db970c9"/></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="payair"><file name="android_video_thumb_small.png" hash="21253916e7b3141eaf6993e6962bc798"/><file name="express_checkout_banner_v3.png" hash="e5ea47cbd4545abd43e4fae504ebdea2"/><file name="express_checkout_bg_383.png" hash="72de32e7645b966296c321a421ccee84"/><file name="test.html" hash="bbc041d0154bebdd5413af6fe993a2ee"/></dir></target><target name="mageweb"><dir name="js"><dir name="payair"><file name="category.js" hash="8876366398c0efe0c4a9769e4d6c81cd"/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|