Frames reference
Last updated: February 28, 2024
Our Frames reference outlines all possible configuration options so you can tailor your customers' experience.
Frames is a critical payment service, which requires up-to-date security. For this reason, we support all major browsers that are still officially maintained and receiving security updates.
We support:
- Chrome, Chrome Mobile, Firefox, and Microsoft Edge
- Safari on desktop and iOS
If you discover any issues with the supported browsers, or would like to report a bug, please get in touch.
Here's a complete list of Frames configuration options.
Information
You can only create charges in currencies that have been enabled for your account. Please contact your Account Manager if you need to process payments in additional currencies.
JavaScript key | Description |
---|---|
| Bearer public API key. |
JavaScript key | Description | Default |
---|---|---|
| Allows you to provide the card schemes you accept to perform validation against the card number provided by customers. Accepted properties include:
|
|
| Set to |
|
| The | none |
| Allows you to use one of the supported languages or a custom object. Refer to the Frames customization guide for more information. |
|
| Customize the default Frames namespace. |
|
| When set to |
|
| Allows you to customize the look and feel of Frames' controlled fields. Refer to the Frames customization guide for more information. |
|
When you initialize Frames, you can use the modes
array to customize the way Frames works and what is displayed.
Configure Frames to support right-to-left languages by specifying RIGHT_TO_LEFT
in the modes array in the Frames.init
object.
1Frames.init({2publicKey: 'pk_sbox_XXXXXX',3modes: [Frames.modes.RIGHT_TO_LEFT],4});
When paying out to a card, the CVV field is not mandatory, so you can initialize Frames with CVV_HIDDEN
or CVV_OPTIONAL
.
1Frames.init({2publicKey: 'pk_sbox_XXXXXX',3modes: [Frames.modes.CVV_HIDDEN],4});
Information
You can use either CVV_HIDDEN
or CVV_OPTIONAL
, but you cannot incorporate both.
To prevent copy pasting of card details within the iframe, you can use DISABLE_COPY_PASTE
.
1Frames.init({2publicKey: 'pk_sbox_XXXX',3modes: [Frames.modes.DISABLE_COPY_PASTE],4});
JavaScript key | Description | Default |
---|---|---|
| The customer's name. | none |
| Transaction billing address:
The country field only accepts two-letter ISO country codes. | none |
| The customer's phone number. | none |
Information
When you enable Arabic as a locale, then right-to-left mode is activated by default.
JavaScript key | Description | Default |
---|---|---|
| Sets the language of the text used. The available options are:
|
|
Event name | JavaScript constant | Description |
---|---|---|
|
| Triggered when the user inputs or changes the first 8 digits of a card. The event will contain data similar to the following example:
|
|
| Triggered when the card form has been submitted. |
|
| Triggered after a card is tokenized. The event will contain data following the example below. To view the full response schema:
|
|
| Triggered if the card tokenization fails. |
|
| Triggered when the state of the card validation changes. This will return: |
|
| Triggered when the form is rendered. |
|
| Triggered when an input field receives focus. Use it to check the validation status and apply the wanted UI changes. |
|
| Triggered after an input field loses focus. Use it to check the validation status and apply the wanted UI changes. |
|
| Triggered when a field's validation status has changed. Use it to show error messages or update the UI. |
|
| Triggered when a valid payment method is detected based on the card number being entered. Use this event to change the card icon or validate the input against accepted card schemes, similar to the following example:
|
|
| Triggered when Frames is registered on the global namespace and safe to use. |
There are two ways to add an event handler: using the standard approach or using configuration options.
1Frames.addEventHandler(Frames.Events.EVENT_NAME, handler);
Signature | Description | Returns |
---|---|---|
| Initializes (or re-initializes) Frames. Examples:
|
|
| Returns the state of the card form validation.
Example:
| boolean |
| Submits the card form if all form values are valid.
Example:
| Promise |
| Adds a handler that is called when the specified event is triggered. Call the |
|
| Removes a previously added handler from an event by providing the event name and handler as arguments in the method.
Example:
|
|
| Removes all handlers added to the event specified.
Example:
|
|
| Retains the entered card details and allows you to resubmit the payment form. |
|
Getter | Setter | Description |
---|---|---|
|
| Bearer public API key. |
| N/A | Returns |
| N/A | Returns |
| N/A | Returns the Frames version number. |
|
| The customer's name, billing details and phone number. |
| N/A | Returns the selected language or the path to the localization file. |
| N/A | Returns the configuration of Frames. |
This example uses a JavaScript Promise to tokenize a customer's payment details. The card token will be posted via the URL specified in the form's action
attribute.
1<body>2{"<!--"} add frames script -->3<script src="https://cdn.checkout.com/js/framesv2.min.js"></script>45<form id="payment-form" method="POST" action="https://merchant.com/charge-card">6<div class="card-frame">{"<!--"} form will be added here --></div>7{"<!--"} add submit button -->8<button id="pay-button" disabled>PAY GBP 24.99</button>9</form>1011<script>12var payButton = document.getElementById('pay-button');13var form = document.getElementById('payment-form');1415Frames.init('pk_sbox_6ff46046-30af-41d9-bf58-929022d2cd14');1617Frames.addEventHandler(Frames.Events.CARD_VALIDATION_CHANGED, function (event) {18console.log('CARD_VALIDATION_CHANGED: %o', event);1920payButton.disabled = !Frames.isCardValid();21});2223form.addEventListener('submit', function (event) {24event.preventDefault();25Frames.submitCard()26.then(function (data) {27Frames.addCardToken(form, data.token);28form.submit();29})30.catch(function (error) {31// handle error32});33});34</script>35</body>
This example uses cardTokenized
handler to gain a payment token for your customers' card details.
1<body>2{"<!--"} add frames script -->3<script src="https://cdn.checkout.com/js/framesv2.min.js"></script>45<form id="payment-form" method="POST" action="https://merchant.com/charge-card">6<div class="card-frame">{"<!--"} form will be added here --></div>7{"<!--"} add submit button -->8<button id="pay-button" disabled>PAY GBP 24.99</button>9</form>1011<script>12var payButton = document.getElementById('pay-button');13var form = document.getElementById('payment-form');1415Frames.init({16publicKey: 'pk_sbox_6ff46046-30af-41d9-bf58-929022d2cd14',17cardValidationChanged: function () {18// if all fields contain valid information, the Pay now19// button will be enabled and the form can be submitted20payButton.disabled = !Frames.isCardValid();21},22cardSubmitted: function () {23form.disabled = true;24// display loader25},26cardTokenized: function (data) {27Frames.addCardToken(form, data.token);28form.submit();29},30cardTokenizationFailed: function (event) {31// catch the error32},33});3435form.addEventListener('submit', function (event) {36event.preventDefault();37Frames.submitCard();38});39</script>40</body>
If you load Frames asynchronously, you can change the namespace to a name other than Frames
. The example below uses Checkout
as the namespace.
Information
Use window.CKOConfig
to change the namespace, or to load Frames asynchronously.
1<body>2{"<!--"} add frames script -->3<script async src="https://cdn.checkout.com/js/framesv2.min.js"></script>45<form id="payment-form" method="POST" action="https://merchant.com/charge-card">6<div class="card-frame">{"<!--"} form will be added here --></div>7{"<!--"} add submit button -->8<button id="pay-button" disabled>PAY GBP 24.99</button>9</form>1011<script>12var payButton = document.getElementById('pay-button');13var form = document.getElementById('payment-form');1415window.CKOConfig = {16publicKey: 'pk_sbox_6ff46046-30af-41d9-bf58-929022d2cd14',17namespace: 'Checkout',18ready: function () {19// Frames is registered on the global namespace and safe to use20form.addEventListener('submit', function (event) {21event.preventDefault();22Checkout.submitCard();23});24},25cardValidationChanged: function (event) {26console.log('CARD_VALIDATION_CHANGED: %o', event);27// if all fields contain valid information, the Pay now28// button will be enabled and the form can be submitted29payButton.disabled = !Checkout.isCardValid();30},31cardSubmitted: function () {32payButton.disabled = true;33// display loader34},35cardTokenized: function (data) {36console.log('CARD_TOKENIZED: %o', event);37// add card token to the form38Checkout.addCardToken(form, data.token);39// submit the form40form.submit();41},42};43</script>44</body>
Use cardholder and billingAddress
attributes to send the customer's details. In the example, we have added the customer's billing details to a Frames form.
1<body>2{"<!--"} add frames script -->3<script src="https://cdn.checkout.com/js/framesv2.min.js"></script>45<form id="payment-form" method="POST" action="https://merchant.com/charge-card">6<div class="card-frame">{"<!--"} form will be added here --></div>7{"<!--"} add submit button -->8<button id="pay-button" disabled>PAY GBP 24.99</button>9</form>1011<script>12var payButton = document.getElementById('pay-button');13var form = document.getElementById('payment-form');1415Frames.init('pk_sbox_6ff46046-30af-41d9-bf58-929022d2cd14');1617Frames.addEventHandler(Frames.Events.CARD_VALIDATION_CHANGED, function (event) {18console.log('CARD_VALIDATION_CHANGED: %o', event);1920payButton.disabled = !Frames.isCardValid();21});2223Frames.addEventHandler(Frames.Events.CARD_SUBMITTED, function () {24payButton.disabled = true;25// display loader26});2728Frames.addEventHandler(Frames.Events.CARD_TOKENIZED, function (data) {29Frames.addCardToken(form, data.token);30form.submit();31});3233Frames.addEventHandler(Frames.Events.CARD_TOKENIZATION_FAILED, function (error) {34// catch the error35});3637form.addEventListener('submit', function (event) {38event.preventDefault();3940Frames.cardholder = {41name: 'John Smith',42billingAddress: {43addressLine1: '123 Anywhere St.',44addressLine2: 'Apt. 456',45zip: '123456',46city: 'Anytown',47state: 'Alabama',48country: 'US',49},50phone: '5551234567',51};5253Frames.submitCard();54});55</script>56</body>