-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCreditCardScript.js
48 lines (44 loc) · 1.49 KB
/
CreditCardScript.js
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
// Handler for cardswipe
window.OnCardSwiped = function (data, plugin, device) {
try {
if (document.getElementById("CardNumber") != null) {
// Card name
document.getElementById("CardName").value = data.Name;
// Card number
document.getElementById("CardNumber").value = data.CardNumber;
// Expiration date
var ExpDate = data.Expiration.split("/");
// Expiration month
if (ExpDate[0].length == 1)
ExpDate[0] = "0" + ExpDate[0];
document.getElementById("ExpirationMonth").value = ExpDate[0];
// Expiration year
if (ExpDate[1].length == 2)
ExpDate[1] = "20" + ExpDate[1];
document.getElementById("ExpirationYear").value = ExpDate[1];
}
} catch (err) {
alert(err);
}
}
// Shortcut to check if KS is initialized
function K() {
return !(typeof KioskSimple === 'undefined')
}
function init() {
// Initialize KioskSimple
try {
window.external.KioskSimpleAPIInit();
KioskSimple.Plugins.GetPlugin('_devices').EnableAllDevicesByCategory("CreditCard");
}
catch (err) {
alert(err);
}
// Wireup handler
if (K()) {
KioskSimple.Plugins.GetPlugin('Bank').OnCardSwiped = OnCardSwiped;
} else {
alert('KioskSimple Cardswiped handler NOT attached');
}
}
document.addEventListener("DOMContentLoaded", init);