Checkout.js reference
We've gathered all those hard-to-find bits of information in this handy Checkout.js reference guide to help you build your integration with ease.
Configuration options
This is a complete list of Checkout.js configuration options.
Required
Please note: You can only create payments in currencies that have been enabled for your account. Please contact your customer success manager if you need to process in additional currencies.
Data-key-attributes | JavaScript keys | Description |
---|---|---|
data-public-key | publicKey | Your public key — find it in the Hub. |
|
| Your payment token. This is only required when creating an alternative payment charge with payment token. |
|
| The customer's email address. |
|
| The payment value displayed in the payment lightbox. |
|
| The payment currency displayed in the payment lightbox. |
|
| Specifies the available payment methods.
cards or mixed . |
|
| Set to cardTokenisation (i.e. cardFormMode: cardTokenisation ). This does not apply for alternative payments. |
Optional
Date-key-attributes | JavaScript keys | Description | Default |
---|---|---|---|
|
| Set to | n/a |
|
| Customize the default Checkout namespace. | n/a |
Customer details
Please note:
billingDetails
is the only way to send customer details when using Checkout.js.
Data-key-attributes | JavaScript keys | Description | Default |
---|---|---|---|
data-customer-name | customerName | The name of the customer. | n/a |
Sorry, not supported. |
| Payment billing details: | n/a |
Billing details example
<form class="payment-form" method="POST" action="https://merchant.com/chargeCard">
<script>
window.CKOConfig = {
publicKey: 'pk_test_6ff46046-30af-41d9-bf58-929022d2cd14',
paymentToken: 'pay_tok_SPECIMEN-000',
customerEmail: '[email protected]',
value: 100,
customerName: 'John Smith',
billingDetails: {
'addressLine1': "623 Slade Street",
'addressLine2': "Apartment 8",
'postcode': "31313",
'country': "US",
'city': "Hinesville",
'phone': {'number': "9125084652"}
}
};
</script>
<script async src="https://cdn.checkout.com/sandbox/js/checkout.js"></script>
</form>
In a live environment, replace
<script async src="https://cdn.checkout.com/sandbox/js/checkout.js"></script>
with<script async src="https://cdn.checkout.com/js/checkout.js"></script>
.
Payment details
Data-key-attributes | JavaScript keys | Description | Default |
---|---|---|---|
data-payment-mode | paymentMode | Specifies the available payment methods:
| mixed |
|
| Defines a single alternative payment method within the payment widget. For example, iDEAL: | n/a |
|
| Deprecated – please use | n/a |
|
| Boolean value that displays ISO3 currency code (e.g.,
| false |
|
| ISO2 country code (e.g., | n/a |
Widget options
These are applicable when integrating via Checkout.configure(), as it does not display the payment widget.
Data-key-attributes | JavaScript keys | Description | Default |
---|---|---|---|
data-widget-color | widgetColor | HEX value of your chosen widget color. |
|
|
| HEX value of your chosen button color. |
|
|
| HEX value of your chosen button text color. |
|
|
| String value that sets the text inside the widget button. |
|
|
| The .class or #id of the element acting as the parent for the widget button. | n/a |
Sorry, not supported |
| The .class or #id of the element hosting the Checkout.js widget. |
|
|
| The .class or #id of the element hosting the Checkout.js widget card icons. | Same element as Pay Now button |
|
|
|
|
Lightbox options
Data-key-attributes | JavaScript keys | Description | Default |
---|---|---|---|
data-title | title | The title of your payment form. | n/a |
|
| The subtitle of your payment form. | n/a |
|
| The URL of your logo (180 x 36 pixels) beginning with | Checkout.com's Logo |
|
| HEX value of your chosen theme color. |
|
Sorry, not supported. |
| HEX value of your chosen icon color. |
|
|
| String value that sets the text inside the lightbox form's submit button. |
|
|
| Boolean value that forces redirect to the payment app instead of opening the payment app in an iframe.
|
|
|
| Boolean value that forces mobile redirection instead of using tabs.
|
|
Sorry, not supported. |
| The URL where a cardholder would be redirected once their card details are submitted via the payment app. IfforceRedirect or forceMobileRedirect are enabled, a redirectUrl must be specified. If the redirect URL parameter is specified it will override the FORM action URL. | n/a |
|
| Boolean value that preloads lightbox.
| true |
|
| Boolean value that locks the lightbox into a single state.
| false |
|
| Sets the colour scheme of the lightbox. Available options include:
| standard |
Sorry, not supported. |
| Enables payments with a card token. Please see Checkout.js for examples. |
|
Sorry, not supported. |
| Opens the payment app inside the merchant checkout screen on mobile devices. | false |
Localization
Data-key-attributes | JavaScript keys | Description | Default |
---|---|---|---|
data-localisation | localisation | Defines language of the (supplied) text displayed in the payment widget and payment lightbox. Available options include:
|
Advanced styling
You can define advanced styling and customization of Checkout.js using the Javascript API and setting the styling property in the configuration object.
// Method A
window.CKOConfig.styling = {
formButtonColor: "#591459",
overlayShade: "light"
};
// Method B
Checkout.render({
...
styling: {
formButtonColor: "#591459",
overlayShade: "light"
}
});
The available options for the styling object:
Data-key-attributes | Javascript keys | Description | Default |
---|---|---|---|
n/a | formButtonColor | HEX value of your chosen lightbox submit button color. | #00b660 |
n/a |
| HEX value of your chosen lightbox submit button label color. |
|
n/a |
| Sets the color of the overlay behind the payment lightbox. Available options include:
|
|
n/a |
| Opacity of the overlay displayed behind the payment lightbox, expressed as a number between 0.8 and 1. |
|
|
| Boolean value that displays widget icons on mobile.
|
|
|
| Sets size of the payment widget icons. Available options include:
|
|
Handlers
With Checkout.js, we dispatch events which you can handle for various purposes. The table below provides the full list of events — use them to attach to one or more handlers.
Event name | Javascript constant | When |
---|---|---|
ready | READY | Triggered when Checkout.js is registered on the global namespace and is safe to use. |
|
| After tokenizing a card; it returns a card token and a card object containing the For example, |
|
| After card tokenization fails. |
|
| After paymentToken expires. |
|
| After successful local payment charge (see sample code below). |
|
| After a local payment fails; this event object will contain the payment URL and response code. |
|
| Failure to receive a correct response from the Checkout's Gateway API will result in an |
Example: Using Configuration Options to Define lpCharged Options
Checkout.render({
publicKey: '...',
lpCharged: {
callback: function(event) {
console.log(event.data);
},
options: {
removeOverlayOnRedirect: false,
removeSpinnerOnRedirect: false,
onRedirectMessage: "your message here..."
}
}
});
Localization events
Event name | Javascript constant | When |
---|---|---|
|
| When a language other than English is loaded. |
|
| When failing to load a requested language. |
Widget and lightbox events
Event name | Javascript constant | When |
---|---|---|
widgetRendered | WIDGET_RENDERED | After the Checkout.js widget is rendered. |
|
| After the Checkout.js lightbox opens. |
|
| After the Checkout.js lightbox closes automatically following the completion of a payment, or after the user closes the lightbox manually. |
|
| If the user presses esc or cancel before the Checkout.js lightbox loads. |
|
| If the Checkout.js lightbox fails to load. |
|
| If configuration parameters required by the Checkout.js lightbox ( |
Adding an event handler
There are two ways to add an event handler:
- using the standard approach
- using configuration options
Checkout.addEventHandler(Checkout.Events.<EVENT_CONSTANT>, handler, options);
Checkout.render({
publicKey: '...',
<event name>: handler
});
Can we help?
Thanks for using Checkout.com. If you need any help or support, then message our support team at [email protected].
Updated 5 months ago