Home > Pay > Payment Devices > Supported Payment Devices > Prepaid Smart Cards > Smart Card ScriptAPI

SmartCard ScriptAPI

The SmartCard ScriptAPI allows you to read out data fields located on an ACOS SmartCard, for example, using websites (see example below). Although it is also theoretically possible to create new data fields, we have not implemented this feature yet for security reasons. Please contact us if you need concrete information about a possible implementation of this feature.
The SmartCard ScriptAPI is part of the SiteKiosk Object Model.
Go to the end of this page to find a complete example of how to use the SmartCard ScriptAPI on an HTML page.
Please note:
Please understand that we cannot offer you any support (apart from this detailed documentation) in connection with the implementation and the use of the SmartCard API!
1. The SmartCard object

// Member-Functions
Boolean = SiteKiosk.Plugins("SiteCash").Devices("ACOS").IsCardValid();
Boolean = SiteKiosk.Plugins("SiteCash").Devices("ACOS").IsCardInserted();
SiteKiosk.Plugins("SiteCash").Devices("ACOS").Credit(Value);
SiteKiosk.Plugins("SiteCash").Devices("ACOS").Debit(Value);
// Events, Overridable
SiteKiosk.Plugins("SiteCash").Devices("ACOS").OnCardInserted();
SiteKiosk.Plugins("SiteCash").Devices("ACOS").OnCardRemoved();
// Properties
Value = SiteKiosk.Plugins("SiteCash").Devices("ACOS").Balance;
SiteKiosk.Plugins("SiteCash").Devices("ACOS").CustomerData; // Object

2. The CustomerData object

// Member-Functions
QuestionID = CustomerData.GetData(Callback, DataArray);

3. IsCardValid()
This function returns true true if the inserted card is a ACOS SmartCard and has been initialized with the same MasterCard as the terminal. Otherwise, it will return false.
4. IsCardInserted()
This function returns true if a card has been inserted in the SmartCard reader.
5. Credit()
Provided you admitted it in your SmartCard configuration file, this function allows you credit amounts to a card.
6. Debit()
Provided you admitted it in your SmartCard configuration file, this function allows you to deduct credit from a card.
7. OnCardInserted() // overridable
This function is called when someone inserts a card into the SmartCard reader.
8. OnCardRemoved() // overridable
This function is called when an inserted SmartCard is removed from the SmartCard reader.
9. OnCredit(Succeeded, Value) // overridable
This function is called when money has been successfully credited to the card.
The first parameter contains true if the credit operation succeeded. The second parameter contains the value which has or has not been credited.
10. OnDebit(Succeeded, Value) // overridable
This function is called when money has been successfully debited from the card. The first parameter contains true if the debit operation succeeded. The second parameter contains the value which has or has not been debited.
11. GetData(Callback, DataArray)
The first parameter of the GetData function has to be the name of a function with three parameters (see example).
The second parameter accepts an array of IDs or a single ID. The values for this ID will be read.
The return value of the function is a unique ID. The QuestionID of the corresponding callback function call has the same value.
Refer to the table below for the valid IDs which can be passed on to GetData:

0 => username
1 => email
2 => pop server
3 => pop password
4 => freedata string
5 => homepage
6 => currency

Example of GetData:

function UserDataReady(QuestionID, Index, Value)
{
}
SiteKiosk.Plugins("SiteCash").Devices("ACOS")
.CustomerData.GetData(UserDataReady, 1)
// To simply get the email

12. How to use the SmartCard ScriptAPI on an HTML page
A page containing this code must be given scripting permission under Access so that SiteKiosk will execute the code. SmartCard features must be enabled for the example to work in SiteKiosk.

<html>
<body>
<p>
<table>
<tr>
<th align='left'>Card Valid:
<td><span id='cardvaliddiv'></span>
<tr>
<th align='left'>Card Inserted:
<td><span id='cardinserteddiv'></span>
<tr>
<th align='left'>Balance on CardCard:
<td><span id='balancediv'></span>
<tr>
<th align='left'>Status:
<td><span id="DivStatus"></span>
<tr>
<th align='left'>Card Owner:
<td><span id="DivCust0"></span>
<tr>
<th align='left'>Email-Address:
<td><span id="DivCust1"></span>
<tr>
<th align='left'>Email-Server:
<td><span id="DivCust2"></span>
<tr>
<th align='left'>Password:
<td><span id="DivCust3"></span>
<tr>
<th align='left'>Customer ID:
<td><span id="DivCust4"></span>
<tr>
<th align='left'>Currency:
<td><span id="DivCust5"></span>
<tr>
<th align='left'>Transstart:
<td><span id='transstartdiv'></span>
<tr>
<th align='left'>Transend:
<td><span id='transenddiv'></span>
</table>
<p>
<input name='creditinput' type='input' value='0'>
<input type='button' onClick='Credit(creditinput.value)' value='Credit Card'>
<br>
<input name='debitinput' type='input' value='0'>
<input type='button' onClick='Debit(debitinput.value)' value='Debit Card'>
<script language='jscript'>
var question_idx;
window.external.InitScriptInterface();
function CardInserted(cardtype)
{
cardinserteddiv.innerHTML =
SiteKiosk.Plugins("SiteCash").Devices("ACOS").IsCardInserted();
cardvaliddiv.innerHTML =
SiteKiosk.Plugins("SiteCash").Devices("ACOS").IsCardValid();
balancediv.innerHTML =
SiteKiosk.Plugins("SiteCash").Devices("ACOS").Balance;
DivStatus.innerText = "Reading...";
testarray = new Array(0,1,2,3,4,5);
question_idx = SiteKiosk.Plugins("SiteCash").Devices("ACOS").
CustomerData.GetData(UserDataReady, testarray);
DivStatus.innerText = "Found Card in Cardreader.";
}
function CardRemoved()
{
cardvaliddiv.innerHTML = "";
cardinserteddiv.innerHTML = "";
balancediv.innerHTML = "";
DivStatus.innerText = "No Card inserted.";
DivCust0.innerText = "unknown.";
DivCust1.innerText = "unknown.";
DivCust2.innerText = "unknown.";
DivCust3.innerText = "unknown.";
DivCust4.innerText = "unknown.";
DivCust5.innerText = "unknown.";´
}
function UserDataReady(questionid, index, value)
{
}
function TransactionFinished(transid, success)
{
balancediv.innerHTML =
SiteKiosk.Plugins("SiteCash").Devices("ACOS").Balance;
transenddiv.innerHTML = "Transaction - ID: " + transid +
" Success: " + success;
}
function Credit(value)
{
transstartdiv.innerHTML = "Credit - Value: " + value + " ID: " +
SiteKiosk.Plugins("SiteCash").Devices("ACOS").Credit(value);
}
function Debit(value)
{
transstartdiv.innerHTML = "Debit - Value: " + value + " ID: " +
SiteKiosk.Plugins("SiteCash").Devices("ACOS").Debit(value);
}
function UserDataReady(question_id, userdata_index, userdata_value)
{
switch (userdata_index)
{
case 0: DivCust0.innerText = userdata_value;
break;
case 1: DivCust1.innerText = userdata_value;
break;
case 2: DivCust2.innerText = userdata_value;
break;
case 3: DivCust3.innerText = userdata_value;
break;
case 4: DivCust4.innerText = userdata_value;
break;
case 5: DivCust5.innerText = userdata_value;
break;
}
}
SiteKiosk.Plugins("SiteCash").Devices("ACOS").OnCardInserted = CardInserted;
SiteKiosk.Plugins("SiteCash").Devices("ACOS").OnCardRemoved = CardRemoved;
SiteKiosk.Plugins("SiteCash").Devices("ACOS").OnUserDataReady = UserDataReady;
SiteKiosk.Plugins("SiteCash").Devices("ACOS").OnTransactionFinished = TransactionFinished;
if (SiteKiosk.Plugins("SiteCash").Devices("ACOS").IsCardInserted())
CardInserted(0);
else
CardRemoved();
</script>
</body>
</html>

See also

Smart Card Admintool

Back to top