Account Boarding Merchant Agreement

Overview

​
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.

Integrate Agreement API using ifields

Obtain your ifields xKey from the Cardknox Support team

Adding Reference to 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>

Adding iFrame and JavaScript Objects for Merchant Agreement

​
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
1
function handleAgreementResponse(response) {
2
let msg = null;
3
if (!response) {
4
msg = "Failed to load token. No Response";
5
} else if (response.status !== iStatus.success) {
6
msg = "Failed to load token. "+response.statusText || "No Error description available";
7
} else if (!response.token) {
8
msg = "Failed to load token. No Token available";
9
} else {
10
msg = response.token;
11
}
12
setTimeout(() => {alert(msg)}, 10);
13
}
Copied!
For response object reference refer here: Agreement Response​
Step 3: Enable Customer Agreement to get the token
There are two ways to get the token:
  • Asynchronously (a callback will be performed once customer agrees to Terms and Conditions) Just add enableAgreement call when document is loaded (autoAgree parameter is set to true):
1
document.addEventListener("DOMContentLoaded", function(event) {
2
................
3
ckCustomerAgreement.enableAgreement({
4
iframeField: 'agreement',
5
xKey: '<Your ifields xKey>',
6
autoAgree: true,
7
callbackName: 'handleAgreementResponse'
8
});
9
................
10
}
Copied!
  • Synchronously (Explicitly calling getToken function for example on Submit) Add enableAgreement call when document is loaded (autoAgree parameter is set to false):
1
document.addEventListener("DOMContentLoaded", function(event) {
2
................
3
ckCustomerAgreement.enableAgreement({
4
iframeField: 'agreement',
5
xKey: '<Your ifields xKey>',
6
autoAgree: false
7
});
8
................
9
}
Copied!
In your Submit function add the following code:
1
ckCustomerAgreement.getToken()
2
.then(resp => {
3
handleAgreementResponse(resp);
4
})
5
.catch(err => {
6
console.error("Agreement Token Error", exMsg(err));
7
handleAgreementResponse(err);
8
});
Copied!

Objects Reference

​

iStatus

1
const iStatus = {
2
success: 100,
3
unsupported: -100,
4
error: -200
5
}
Copied!

Agreement Response

The object holding the response with token from Agreement API.
Name
Type
Description
status
​iStatus​
There are 2 possible cases:
  • Agreement was accepted and Token was obtained status=iStatus.success
  • Agreement wasn’t accepted or an error occurred obtaining the token: status=iStatus.error
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 25d ago