Adding the Payment Form
Follow the below steps to add the payment form into your website using JavaScript SDK solution:
1
Add the div
provided to you into your code to contain the payment form.
<div id="payment-form"></div>
2
Add the script
tag into the JavaScript SDK library.
<script src="https://gateway-sb.clearent.net/js-sdk/js/clearent-host.js"></script> code
3
Add the Global Callback Handlers into your code to receive the success or error messages from the JavaScript SDK. You can also add the Promises to receive the success or error messages alternate to avoid global callback handlers.
<script type="text/javascript">
// When you get a successful token response and
// use this to make a sale/auth on your backend
function ClearentTokenSuccess(raw, json) {
console.log("ClearentTokenSuccess");
console.log(raw);
console.log(json);
// now you can send the token to your server
// to complete the transaction via mobile-gateway
}
function ClearentTokenError(raw, json) {
console.log("ClearentTokenError");
console.log(raw);
console.log(json);
}
</script>java
4
Call the init
method using the baseUrl
and pk
provided to you for your sandbox.
<script type="text/javascript">
ClearentSDK.init({
"baseUrl": "https://gateway-sb.clearent.net",
"pk": "YOUR PUBLIC KEY GOES HERE"
});
</script>
After Adding the Payment Form into your website, the cardholders can enter the payment information using the form.
Last updated
Was this helpful?