-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcheckout.html
474 lines (439 loc) · 24.3 KB
/
checkout.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>JSE Checkout</title>
<link rel="icon" type="image/png" sizes="32x32" href="https://jsecoin.com/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="https://jsecoin.com/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://jsecoin.com/favicon-16x16.png">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/metisMenu/2.7.0/metisMenu.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" integrity="sha384-OHBBOqpYHNsIqQy8hL1U+8OXf9hH6QRxi0+EODezv82DfnZoV7qoHAZDwMwEJvSw" crossorigin="anonymous">
<link href="css/style.min.css?v=1.8.11" rel="stylesheet">
<style>
html, body {
height: 100%;
margin: 0;
}
body {
font-family: Nunito, Arial, sans-serif;
background: #F7F7F7;
font-size: 14px;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
button { background: #1B5794; color: #FFF; border-radius: 3px; border: none; padding: 5px 20px; cursor: pointer; }
#checkout-outer-container { color: #444; }
#checkout-logo-container { width: 100%; max-width: 500px !important; text-align: center; display: inline-table; margin-bottom: 10px;}
#checkout-logo-image-login { margin-bottom: 20px; max-width: 200px; }
#checkout-logo-dual-container { width: 100%; display: inline-block; vertical-align: middle; text-align: center; }
.checkout-logo-dual-images { width:44%; margin: auto 3%; max-width: 200px !important; }
#checkout-outer-container { max-width: 500px; margin: 10px auto;}
#checkout-currency-container { background: #FFF; border: 1px solid #CCC; padding: 15px 30px 30px 30px; border-radius: 3px; min-width: 300px; }
#checkout-currency-title { width: 100%; text-align: center; font-size: 14px; }
.checkout-currency-option { width: 100%; text-align: left; height: 50px; background: #F7F7F7; font-size: 18px; line-height: 50px; vertical-align: middle; margin-top: 10px; cursor: pointer; }
.checkout-currency-icon { width: 40px; height: 40px; margin: -4px 20px 0px 20px; }
#checkout-btceth-container { background: #FFF; border: 1px solid #CCC; padding: 15px 10px 30px 10px; border-radius: 3px; width: 300px; display: none; }
#checkout-btceth-info { font-size: 12px; margin-top: 10px; }
#checkout-btceth-monitoring { font-size: 12px; margin-top: 10px; }
.checkout-btceth-refresh { float:right; margin: -3px 3px; font-size: 20px; }
#checkout-btceth-address { padding: 5px; font-size: 11px; border: 1px solid #CCC; border-radius: 3px; margin: 10px 0px; }
#checkout-login-container { background: #FFF; border: 1px solid #CCC; padding: 30px; border-radius: 3px; min-width: 300px; display: none; }
#checkout-login-title { width: 100%; text-align: center; font-size: 14px; }
#checkout-complete-container { background: #FCFCFC; border: 1px solid #CCC; padding: 30px 50px; display: none; border-radius: 3px; }
.checkout-text-input { border-radius: 3px; border: 1px solid #DDD; padding: 5px; width: 200px; }
.checkout-select-input { border-radius: 3px; border: 1px solid #DDD; padding: 5px 5px; }
#checkout-login-email-container { margin-top: 20px; }
#checkout-login-buttons { margin-top: 10px; }
#checkout-form { margin: 0px auto; width: 200px; }
#checkout-footer { font-size: 10px; color: #666; width: 100%; text-align: center; margin-top: 5px; }
#checkout-footer a { font-size: 10px; color: #666; text-decoration: none; }
#checkout-footer-padlock { height: 13px; opacity: 0.4; position: relative; top: -2px; left: 3px; }
#checkout-logo-image-complete { margin-bottom: 20px; width: 150px; }
#checkout-complete-title { font-size: 14px; font-weight: bold; }
#checkout-contract { font-style: italic; font-size: 12px; padding: 20px; }
#checkout-complete-body { min-height: 300px; }
#checkout-complete-cart { height: 14px; opacity: 0.9; float: right; }
#checkout-complete-buttons { width: 100%; text-align: center; margin-top: 15px; }
#checkout-delivery-address { font-size: 12px; border: 1px solid #CCC; padding: 15px; margin: 5px 0px; background: #FFF; border-radius: 2px; }
#checkout-jse-icon { height: 16px; opacity: 0.6; position: relative; top: -2px; }
#checkout-delivery-title { margin-top: 10px; }
#checkout-payment-method-container { width: 350px; margin: 10px auto; }
#checkout-payment-method { margin-left: 30px; }
#checkout-item-container { width: 350px; margin: 0px auto; }
#checkout-complete-item { margin-left: 60px; }
#checkout-hide-address-container { float: right; margin-right: 5px; margin-top: 2px }
#checkout-hide-address-label { font-weight: normal; margin-left: 2px; font-size: 10px; }
#checkout-hide-address { position: relative; top: 3px; }
</style>
</head>
<body>
<div id="checkout-outer-container">
<div id="checkout-logo-container">
<img id="checkout-logo-image-login" src="img/merchant-logo.png" alt="JSEcoin" />
</div>
<div id="checkout-currency-container">
<div id="checkout-currency-title">Select your payment currency</div>
<div class="checkout-currency-option" onclick="$('#checkout-currency-container').hide(); loadBtcEth('btc');">
<img class="checkout-currency-icon" src="img/bitcoin.png" />
Bitcoin
</div>
<div class="checkout-currency-option" onclick="$('#checkout-currency-container').hide(); loadBtcEth('eth');">
<img class="checkout-currency-icon" src="img/ethereum.png" />
Ethereum
</div>
<div class="checkout-currency-option" onclick="$('#checkout-currency-container').hide(); $('#checkout-login-container').show();">
<img class="checkout-currency-icon" src="img/jsecoin.png" />
JSEcoin
</div>
</div>
<div id="checkout-btceth-container">
<div id="checkout-btceth-title"></div>
<div id="checkout-btceth-address"></div>
<button class="btn btn-primary" onclick="copyToClipboard('checkout-btceth-address');">Copy</button>
<button class="btn btn-primary" onclick="$('#checkout-btceth-container').hide(); $('#checkout-currency-container').show();">Return</button>
<div id="checkout-btceth-qrcode" style="width:120px; height:120px; margin: 2px; float: right;"></div>
<div id="checkout-btceth-info">Payment will be received automatically after two block confirmations and you will be returned to the merchants website.</div>
<div style="clear: both;"></div>
<div id="checkout-btceth-monitoring">
Monitoring blockchain for incoming payment
<i class="checkout-btceth-refresh fa fa-spinner fa-spin" aria-hidden="true"></i>
</div>
</div>
<div id="checkout-login-container">
<div id="checkout-login-title">Log in to complete your payment</div>
<div id="checkout-form">
<div id="checkout-login-email-container">
<div id="checkout-email" class="checkout-title">E-mail:</div>
<input type="text" id="loginemail" class="checkout-text-input">
</div>
<div id="checkout-login-password-container">
<div id="checkout-password" class="checkout-title">Password:</div>
<input type="password" id="loginpassword" class="checkout-text-input">
</div>
<div id="checkout-login-buttons">
<button type="submit" data-sitekey="6Lfl8S8UAAAAAAWfKHLDyRbcanMwKKSBckVYuQLZ" data-callback="login" class="g-recaptcha btn btn-primary" onclick="$(this).addClass('animated tada');">Login</button>
<script src='https://www.google.com/recaptcha/api.js'></script>
<button id="checkout-register-button" class="btn btn-secondary" onclick="window.open('https://platform.jsecoin.com/?lander=2', '_blank');">Register</button>
</div>
<div class="checkout-login-tip">
Always check the domain in the browser address bar is https://platform.jsecoin.com
</div>
</div>
</div>
<div id="checkout-complete-container">
<div id="checkout-complete-body">
<img id="checkout-complete-cart" src="img/cart.png" alt="" />
<div id="checkout-complete-title">Complete your payment</div>
<div id="checkout-contract"></div>
<div class="checkout-title" id="checkout-item-container">Item <span id="checkout-complete-item"></span></div>
<div class="checkout-title" id="checkout-payment-method-container">Pay with <span id="checkout-payment-method"></span></div>
<div class="checkout-title" id="checkout-delivery-title">Delivery Address</div>
<div id="checkout-hide-address-container"><input type="checkbox" id="checkout-hide-address" value="1" onclick="checkoutHideAddress();" /><label for="checkout-hide-address" id="checkout-hide-address-label" >hide</label></div>
<div id="checkout-delivery-address" contenteditable="true"></div>
<div id="checkout-complete-buttons">
<button id="checkout-cancel-button" class="btn btn-primary" onclick="cancelCheckout();">Cancel</button>
<button id="checkout-complete-button" class="btn btn-primary" onclick="completeCheckout();">Make Payment</button>
</div>
</div>
</div>
<div id="checkout-footer">
<a href="https://jsecoin.com/en/support/contact" target="_blank">Feedback</a> |
<a href="https://jsecoin.com/en/legal/privacyPolicy" target="_blank">Privacy</a> |
<a href="https://jsecoin.com/en/legal/terms" target="_blank">Terms</a> |
© <a href="https://jsecoin.com" target="_blank">JSEcoin</a> <img src="img/padlock.png" alt="" id="checkout-footer-padlock" />
</div>
</div>
<div class="modal fade" id="tmpmodal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body breakword" id="tmpmodalbody">
</div>
</div>
</div>
</div>
<div class="alert alert-success text-center hide" id="notify" role="alert">
<button type="button" class="close alertx" onclick="closeAlert()">
<span aria-hidden="true">×</span>
</button>
<div class="notifycontent mt5"></div>
</div>
<div class="check-pin-container hide">
<div class="check-pin">
<h4>Please enter your pin number:</h4>
<form action="javascript:void(0);">
<input type="text" id="pin" class="w150c text-center" autocomplete="off" name="pinNumber" /><br>
<button class="btn btn-primary mt5" onclick="checkPinFunction();">Confirm</button>
</form>
<br>
<a href="javascript:void(0)" onclick="forgotPin();">Forgot Pin?</a>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="js/jsecoin.min.js?v=1.9.1"></script>
<script src="js/qrcode.min.js"></script>
<script>
function cleanURL(stringRaw) { // includes &={}
var stringClean = String(stringRaw);
stringClean = stringClean.split(/[^ {}&=.$*+?\\\-_:/,@a-zA-Z0-9\s]/).join('');
stringClean = stringClean.substr(0, 255);
return stringClean;
}
function getQueryParams(qs) {
qs = qs.split("+").join(" ");
var params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) { params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); }
return params;
}
var get = getQueryParams(document.location.search);
var checkout = {};
if (typeof get.encoded !== 'undefined') {
var getParsed = JSON.parse(atob(get.encoded));
} else {
var getParsed = get;
}
checkout.uid = cleanString(getParsed.uid);
checkout.sAuth = cleanString(getParsed.sAuth);
checkout.item = cleanString(getParsed.item);
if (typeof getParsed.rebillFrequency !== 'undefined') {
$('#checkout-currency-container').hide();
$('#checkout-login-container').show(); // Only JSE for recurring payments
checkout.initialPrice = cleanString(getParsed.initialPrice);
checkout.recurringPrice = cleanString(getParsed.recurringPrice);
checkout.rebillFrequency = cleanString(getParsed.rebillFrequency);
var now = new Date();
if (checkout.rebillFrequency === 'daily') {
checkout.payableDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 11, 0, 0);
} else if (checkout.rebillFrequency === 'weekly') {
checkout.payableDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 7, 11, 0, 0);
} else if (checkout.rebillFrequency === 'monthly') {
checkout.payableDate = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate(), 11, 0, 0);
} else if (checkout.rebillFrequency === 'annually') {
checkout.payableDate = new Date(now.getFullYear() + 1, now.getMonth(), now.getDate(), 11, 0, 0);
}
checkout.payableDateString = new Date(checkout.payableDate.getTime() + 3600000).toLocaleString();
} else {
checkout.singlePrice = cleanString(getParsed.singlePrice);
}
if (typeof getParsed.currency !== 'undefined' && getParsed.currency !== 'JSE') { // leave blank if JSE
checkout.currency = cleanString(getParsed.currency);
}
var initialOrSinglePrice = checkout.singlePrice || checkout.initialPrice;
checkout.completionURL = cleanURL(getParsed.completionURL).split('{item}').join(checkout.item).split('{price}').join(initialOrSinglePrice).split('{c1}').join(cleanString(getParsed.c1)).split('{c2}').join(cleanString(getParsed.c2)).split('{c3}').join(cleanString(getParsed.c3)); // buyeremail and reference added later
if (typeof getParsed.cancellationURL !== 'undefined') {
checkout.cancellationURL = cleanURL(getParsed.cancellationURL).split('{item}').join(checkout.item).split('{price}').join(initialOrSinglePrice).split('{c1}').join(cleanString(getParsed.c1)).split('{c2}').join(cleanString(getParsed.c2)).split('{c3}').join(cleanString(getParsed.c3));
}
if (typeof getParsed.ipnURL !== 'undefined') {
checkout.ipnURL = cleanURL(getParsed.ipnURL).split('{item}').join(checkout.item).split('{price}').join(initialOrSinglePrice).split('{c1}').join(cleanString(getParsed.c1)).split('{c2}').join(cleanString(getParsed.c2)).split('{c3}').join(cleanString(getParsed.c3)); // buyer email added later, IPN added server side
}
if (typeof getParsed.logoURL !== 'undefined') {
checkout.logoURL = cleanURL(getParsed.logoURL);
if (checkout.logoURL.match(/\.(jpeg|jpg|gif|png)$/) != null && checkout.logoURL.indexOf('?') == -1) {
$('#checkout-logo-container').html(`<img class="checkout-logo-dual-images" src="img/merchant-logo.png" alt="JSEcoin" /><img class="checkout-logo-dual-images" src="${checkout.logoURL}" alt="JSEcoin" /><div style="clear: both;"></div>`);
}
}
checkout.ts = new Date().getTime();
//checkout.completedTS = new Date().getTime();
//checkout.cancelledTS = new Date().getTime();
function checkoutHideAddress() {
if ($('#checkout-delivery-address').text() == 'Hidden') {
$('#checkout-delivery-address').html(user.address+'<br>'+user.country);
} else {
$('#checkout-delivery-address').text('Hidden');
}
}
function merchantCheckoutLogin() {
$('#checkout-login-container').hide();
$('#checkout-complete-container').show();
if (checkout.currency) {
// Get live exchange rates
$.ajax({url:jseServer+'/stats/',type:'GET',contentType:'application/json'}).done(function(publicStatsJSON) {
var publicStats = JSON.parse(publicStatsJSON);
if (publicStats.exchangeRates[checkout.currency+'JSE']) {
if (typeof checkout.rebillFrequency !== 'undefined') {
checkout.calculatedPrice = Math.round(checkout.initialPrice / publicStats.exchangeRates[checkout.currency+'JSE']);
$('#checkout-complete-title').html('Complete your payment for '+checkout.calculatedPrice+' JSE ('+checkout.initialPrice+' '+checkout.currency+')');
$('#checkout-contract').html('Make payment for '+checkout.calculatedPrice+' JSE ('+checkout.initialPrice+' '+checkout.currency+') with a recurring '+checkout.rebillFrequency+' payment of '+checkout.recurringPrice+' '+checkout.currency+' in JSE. First recurring payment will <b>automatically be billed on the '+checkout.payableDateString+'</b>, you will receive e-mail notification 24hrs in advance. This billing agreement is cancellable at any time.');
} else {
checkout.calculatedPrice = Math.round(checkout.singlePrice / publicStats.exchangeRates[checkout.currency+'JSE']);
$('#checkout-complete-title').html('Complete your payment for '+checkout.calculatedPrice+' JSE ('+checkout.singlePrice+' '+checkout.currency+')');
$('#checkout-contract').html('Make a single payment for '+checkout.calculatedPrice+' JSE ('+checkout.singlePrice+' '+checkout.currency+')');
}
} else {
notify('Error: live exchange rates not found, please refresh and try again in 30 seconds');
return false;
}
});
} else {
if (typeof checkout.rebillFrequency !== 'undefined') {
$('#checkout-complete-title').html('Complete your payment for '+checkout.initialPrice+' JSE');
$('#checkout-contract').html('Make payment for '+checkout.initialPrice+' JSE with a recurring '+checkout.rebillFrequency+' payment of '+checkout.recurringPrice+' JSE. First recurring payment will <b>automatically be billed on the '+checkout.payableDateString+'</b>, you will receive e-mail notification 24hrs in advance. This billing agreement is cancellable at any time.');
} else {
$('#checkout-complete-title').html('Complete your payment for '+checkout.singlePrice+' JSE');
$('#checkout-contract').html('Make a single payment for '+checkout.singlePrice+' JSE');
}
}
$('#checkout-complete-item').html(checkout.item);
$('#checkout-delivery-address').html(user.address+'<br>'+user.country);
$('#checkout-payment-method').html('<img src="img/jseicon.png" id="checkout-jse-icon" /> User ID '+user.uid+' - Balance '+user.balance+' JSE');
checkout.buyer = {};
checkout.session = user.session; // sensative data
checkout.buyer.uid = user.uid;
checkout.buyer.email = user.email;
checkout.buyer.name = user.name;
checkout.buyer.address = user.address;
checkout.buyer.country = user.country;
//checkout.buyer.deliveryAddress = $('#checkout-delivery-address').html(); // done on completion
checkout.buyer.balance = user.balance;
if (typeof checkout.ipnURL !== 'undefined') {
checkout.ipnURL = checkout.ipnURL.split('{buyeremail}').join(encodeURIComponent(checkout.buyer.email));
}
if (typeof checkout.completionURL !== 'undefined') {
checkout.completionURL = checkout.completionURL.split('{buyeremail}').join(encodeURIComponent(checkout.buyer.email));
}
if (typeof getParsed.hideAddress !== 'undefined') {
checkoutHideAddress();
$('#checkout-hide-address').prop('checked', true);
} else {
// focus on contenteditable address div?
}
}
function notify(msg) {
if (app === false) {
$('.notifycontent').html(msg+'<br><button type="button" class="btn btn-sm btn-primary alertbutton" onclick="closeAlert()">OK</button>');
$(".alert").removeClass('hide animated fadeOutUp').addClass('animated fadeInDown');
} else {
console.log('NOTIFY: '+msg);
}
}
function notifyThen(msg,callback) {
notify(msg);
$(".alertbutton").click(function() {
closeAlert();
callback();
});
}
function loadBtcEth(btcEth) {
$('#checkout-btceth-container').show();
$('#checkout-btceth-address').html('Generating Address...');
$('#checkout-btceth-qrcode').html('');
var qrBtcEthElement = new QRCode(document.getElementById("checkout-btceth-qrcode"), { width : 120, height : 120 });
let longCurrency = 'Bitcoin';
if (btcEth === 'eth') longCurrency = 'Ethereum';
$('#checkout-btceth-title').html(`Please make your ${longCurrency} payment for <span id="checkout-btceth-amount">...</span> within the next hour to:`);
if (!checkout.payAddress || (checkout.payCurrency && checkout.payCurrency !== btcEth)) {
checkout.payCurrency = btcEth;
$.ajax({url:jseServer+'/checkout/setuptransaction/',type:'POST',contentType:'application/json',data: JSON.stringify(checkout)}).done(function(data) {
var transactionData = JSON.parse(data);
checkout.payAddress = transactionData.payAddress;
if (btcEth === 'eth') checkout.payAddress = checkout.payAddress.toLowerCase(); // fit in long hex address
checkout.payPrice = transactionData.payPrice;
checkout.calculatedPrice = transactionData.calculatedPrice;
checkout.pendingRef = transactionData.pendingRef;
$('#checkout-btceth-amount').html(`${checkout.payPrice.toFixed(8).replace(/\.?0+$/,"")} <small>${checkout.payCurrency.toUpperCase()}</small>`);
$('#checkout-btceth-address').html(checkout.payAddress);
qrBtcEthElement.makeCode(checkout.payAddress);
});
setTimeout(function() { checkPendingPayment(); }, 60000);
} else {
$('#checkout-btceth-amount').html(`${checkout.payPrice.toFixed(8).replace(/\.?0+$/,"")} <small>${checkout.payCurrency.toUpperCase()}</small>`);
$('#checkout-btceth-address').html(checkout.payAddress);
qrBtcEthElement.makeCode(checkout.payAddress);
}
}
var paymentReceived = false;
function checkPendingPayment() {
$.ajax({url:jseServer+'/checkout/checkpending/'+checkout.pendingRef+'/',type:'GET',contentType:'application/json'}).done(function(data) {
var paymentCheckData = JSON.parse(data);
paymentReceived = paymentCheckData.paymentReceived;
if (paymentReceived) {
notifyThen('Payment completed, redirecting back to merchant website',function() {
if (paymentCheckData.reference) {
window.location.href = checkout.completionURL.split('{reference}').join(paymentCheckData.reference); // reference sent back from JSON response
} else {
window.location.href = checkout.completionURL;
}
});
}
});
if (!paymentReceived) {
setTimeout(function() { checkPendingPayment(); }, 60000);
}
}
function cancelCheckout() {
$('#checkout-complete-buttons').hide();
notifyThen('Checkout has been cancelled',function() {
checkout.cancelledTS = new Date().getTime();
if (typeof checkout.cancellationURL !== 'undefined') {
window.location.href = checkout.cancellationURL;
} else {
$('#checkout-complete-container').html('<div id="checkout-complete-body"><div id="checkout-complete-title">Please use the back button to navigate back to the merchant website</div></div>');
}
});
}
function completeCheckout() {
$('#checkout-complete-buttons').hide();
checkPin(function() {
checkout.completedTS = new Date().getTime();
checkout.deliveryAddress = $('#checkout-delivery-address').text();
if (get.encoded && get.hash) {
checkout.encoded = get.encoded;
checkout.hash = get.hash;
}
checkout.pin = getPin();
$.ajax({url:jseServer+'/checkout/',type:'POST',contentType:'application/json',data: JSON.stringify(checkout)}).done(function(data) {
var response = JSON.parse(data);
if (response.fail) {
notify(response.notification);
grecaptcha.reset();
$('#checkout-complete-buttons').show();
} else {
notifyThen('Payment completed, redirecting back to merchant website', function() {
if (response.reference) {
window.location.href = checkout.completionURL.split('{reference}').join(response.reference); // reference sent back from JSON response
} else {
window.location.href = checkout.completionURL;
}
});
}
return false;
}).fail(function(data2) {
var failObj = JSON.parse(data2.responseText);
if (failObj && failObj.notification) { notify(failObj.notification); }
$('#checkout-complete-buttons').show();
return false;
});
});
}
</script>
<!-- PIXELS -->
<script>
if ((document.getElementById('JSEW-pixels') === null) && (String(document.location).indexOf('localhost') === -1) && (String(document.location).indexOf('privacyPolicy') === -1)) {
var iframe = document.createElement('iframe');
iframe.id="JSEW-pixels";
iframe.src = 'https://jsecoin.com/pixels.php?rt=jsecoin.com';
document.body.appendChild(iframe);
}
</script>
<!-- Google Analytics Code -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-48537439-15', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>