Using Methods
Refer to the following table to configure your payment page:
addMetaKeyBlocker()
Block meta key combinations (alt or ctrl) for the hosting page.
Some card readers may generate keystrokes that include meta keys even after the card read is complete, causing unnecessary behavior in the browser window.
Tip: To make this setting effective, set the enableReader
member to True
.
<script> ClearentSDK.addMetaKeyBlocker(); </script>
This setting blocks certain meta key combinations, except for closing the window (Ctrl + W), opening a new window (Ctrl + N), or opening a new tab (Ctrl + T).
getPaymentToken()
Receive a token for payment gateway transaction, calling successCallback
on success or errorCallback
on error.
ClearentSDK.getPaymentToken();
None
init(obj)
Initialize the Clearent JavaScript SDK integration and create the Payment Details form for entry.
// Sandbox URL for testing
// use Sandbox public key <script src="https://gateway-sb.clearent.net/js-sdk/js/clearent-host.js"></script> <script> ClearentSDK.init({ "baseUrl": "https://gateway-sb.clearent.net", "pk": "YOUR_SANDBOX_PUBLIC_KEY_HERE", }); </script>
You can set the properties of the JSON-formatted object when you initialize the Clearent JavaScript SDK integration.
removeMetaKeyBlocker()
Remove a meta key combination blocker enabled using the blockMetaKeys
member or the addMetaKeyBlocker
method.
<script> ClearentSDK.removeMetaKeyBlocker(); </script>
reset()
Reset the JavaScript SDK integration.
Warning: When you use the reset()
method, the Clearent Payment iFrame is completely removed.
ClearentSDK.reset();
You can call Clearent.init
to initialise the JavaScript SDK integration.
ClearentCardReadComplete()
Call the function when the card read process is complete using the USB card reader.
function ClearentCardReadComplete(){ console.log("Card Read is complete"); }
You can call the function if it is defined on the host page. This function does not return card data or Europay, Mastercard and Visa (EMV) data to maintain the Payment Card Industry (PCI) compliances.
ClearentCardReadStart()
Call the function when the card read process starts using the USB card reader.
function ClearentCardReadStart(){ console.log("Card Read has started"); }
You can call the function if it is defined on the host page.
ClearentEntryModeChange(mode)
Call the function when the entry mode changes to manual or swipe.
function ClearentEntryModeChange(mode){ console.log("User set SDK to mode: ", mode); }
You can call the function if it is defined on the host page.
ClearentOnPaymentTypeChange(paymentType)
Call the function to receive a raw server response or a JSON-formatted response data object if getPaymentToken
returns successfully.
function ClearentOnPaymentTypeChange(paymentType) { console.log("Payment Type was changed to: " + paymentType); }
You can call the function if it is defined on the host page.
ClearentTokenError(responseRaw, responseJSON)
Call the function to receive a raw server response or a JSON-formatted response data object if getPaymentToken
returns an error.
function ClearentTokenError(responseRaw, responseJSON){ console.log("ClearentTokenError"); console.log(responseRaw); console.log(responseJSON); }
You can call the function if it is defined on the host page.
ClearentTokenSuccess(responseRaw, responseJSON)
Call the function to receive a raw server response or a JSON-formatted response data object if getPaymentToken
is successful.
function ClearentTokenSuccess(responseRaw,responseJSON){ console.log("ClearentTokenSuccess"); console.log(responseRaw); console.log(responseJSON); // now you can send the token to your server // to complete the transaction via mobile-gateway }
You can call the function if it is defined on the host page.
ClearentValidation(messages)
Call the function to validate the payment form fields information that returns the validation message with a JavaScript array.
function ClearentValidation(messages) { console.log("ClearentValidation"); console.log(messages); // you can handle these messages and display in your own form // empty messages array indicates no validation errors }
When the payment fields have valid information, a JavaScript array in the validation message will be empty.
Last updated