Account Boarding Merchant Agreement
In order to be boarded every Merchant needs to agree to Go Plus Terms and Conditions.
To help Developers integrate Agreement API into their website we are supporting Agreement API through Cardknox iFields.
Step 1: Check the latest stable iFields version here: https://cdn.cardknox.com/ifields/versions.htm
Step 2: Add the ifields.js file after the <head> tag on your website:
<script src=https://cdn.cardknox.com/ifields/**ifields-version-number**/ifields.min.js></script>
Step 1: Add the following iFrame JS snippet inside the <body> where Merchant Agreement is desired.
- Make sure you have an attribute
data-ifields-id="agreement"
as part of <iframe> tag
<iframe id="agreement" class="agreement" data-ifields-id="agreement" src="https://cdn.cardknox.com/ifields/**ifields-version-number**/agreement.htm"></iframe>
Step 2: Create JavaScript function to handle Agreement API callback
function handleAgreementResponse(response) {
let msg = null;
if (!response) {
msg = "Failed to load token. No Response";
} else if (response.status !== iStatus.success) {
msg = "Failed to load token. "+response.statusText || "No Error description available";
} else if (!response.token) {
msg = "Failed to load token. No Token available";
} else {
msg = response.token;
}
setTimeout(() => {alert(msg)}, 10);
}
Step 3: Enable Customer Agreement to get the token
There are two ways to get the token:
- Asynchronously (a callback will be performed once the customer agrees to Terms and Conditions) Just add
enableAgreement
call when the document is loaded (autoAgree
the parameter is set totrue
):
document.addEventListener("DOMContentLoaded", function(event) {
................
ckCustomerAgreement.enableAgreement({
iframeField: 'agreement',
xKey: '<Your ifields xKey>',
autoAgree: true,
callbackName: 'handleAgreementResponse'
});
................
}
- Synchronously (Explicitly calling
getToken
function for example on Submit) AddenableAgreement
call when the document is loaded (autoAgree
the parameter is set tofalse
):
document.addEventListener("DOMContentLoaded", function(event) {
................
ckCustomerAgreement.enableAgreement({
iframeField: 'agreement',
xKey: '<Your ifields xKey>',
autoAgree: false
});
................
}
In your
Submit
function add the following code:ckCustomerAgreement.getToken()
.then(resp => {
handleAgreementResponse(resp);
})
.catch(err => {
console.error("Agreement Token Error", exMsg(err));
handleAgreementResponse(err);
});
const iStatus = {
success: 100,
unsupported: -100,
error: -200
}
The object holding the response with token from Agreement API.
Name | Type | Description |
status | There are 2 possible cases:
| |
statusText | String | When status=iStatus.error this field will be populated with the reason |
token | String | When status=iStatus.success this field will be populated with token
|
Last modified 1yr ago