Get started with Frames
Last updated: April 29, 2022
This page explains what you need to get up and running with Frames, and the different ways you can customize it.
- Make sure you have your Bearer public API key to practice API calls, and use the sandbox version of the endpoint.
- You can set up webhooks so that, after you securely collect the card details with Frames and make a payment request, you are notified when the payment is captured (completed). You then continue the sales fulfillment flow.
Note
Use your public key on the client side. You should never include your secret key on the client side for security reasons. Only use the secret key on the server side.
To get started using Frames, you first need to get access to its built-in features. On this page, we will reference tags suitable for HTML webpages. See our Frames React wrapper for an alternative option.
Include the CDN package in a script tag on your relevant HTML page:
1<script src="https://cdn.checkout.com/js/framesv2.min.js"></script>
Frames can be rendered either as a single iframe (displayed as one input field) or as multiple iframes (displayed as multiple input fields).
We insert an iframe between each placeholder div
you put in your payment form.
We will insert a single iframe in:
1<div class="card-frame">2<!-- form will be added here -->3</div>
Before the input fields appear on your website and app, you need to initialize Frames.
In your JavaScript file, call the init (short for initialize) action on the Frames object and include your public API key within the brackets.
1Frames.init('pk_sbox_XXXX');
Frames has a collection of events that are triggered when certain actions happen. This is how your application will know when a form has been submitted, or card details tokenized. They also help you tailor the experience you want to provide to your customers.
We have listed all configuration options.
Frames can be rendered either as a single iframe (displayed as one input field) or as multiple iframes (displayed as multiple input fields).
In the single iframe case, the JavaScript library will dynamically apply an --invalid
modifier to the container element class; in the multiple iframes case, the library will dynamically apply an --invalid
modifier to each container element class.
Your checkout page can contain CSS declarations for styling the containers, such as to change the border color. For example, you can use the invalid modifier to render a red border if an invalid
card number is entered.
The default approach is to hide the borders of input fields within the iframe input fields and style them within the checkout page as explained above, however, custom styling can be passed into Frames at initialization as shown below. This includes base
, invalid
, and placeholder
styling options.
Make your customers feel at home by using our localization settings to change the language of your payment form. Use one of our pre-defined languages or create your own.
If the language you would like to use appears in our pre-defined list, then just set the localization parameter, for example localization: 'FR-FR'
.
The pre-defined languages are:
- Arabic = AR
- Chinese Simplified = ZH-CH
- Chinese Traditional (Hong Kong) = ZH-HK
- Chinese Traditional (Taiwan) = ZH-TW
- Danish = DA-DK
- Dutch = NL-NL
- English = EN-GB
- Filipino = FIL-PH
- Finnish - FI-FI
- French = FR-FR
- German = DE-DE
- Hindi = HI-IN
- Indonesian = ID-ID
- Italian = IT-IT
- Japanese = JA-JP
- Korean = KO-KR
- Malay = MS-MY
- Norwegian Bokmål = NB-NO
- Spanish = ES-ES
- Swedish = SV-SE
- Thai = TH-TH
- Vietnamese = VI-VN
Placeholders are defined by the selected localization. For further customization, you can pass an object to localization
.
1Frames.init({2publicKey: 'pk_sbox_6ff46046-30af-41d9-bf58-929022d2cd14',3localization: {4cardNumberPlaceholder: 'Card number',5expiryMonthPlaceholder: 'MM',6expiryYearPlaceholder: 'YY',7cvvPlaceholder: 'CVV',8},9});
If you want to override the default style of Frames and customize the input element's CSS, pass a style object to the init method.
Information
Each specified rule name must be in camel case. For example, fontSize
not font-size
.
The table below lists all the available options.
Property name | Description |
---|---|
| The default style. |
| Rules applied when the element is hovered over. |
| Rules applied when the element is focused. |
| Rules applied when the element is valid. |
| Rules applied when the element is invalid. |
| Accepts an object with |
We accept the majority of CSS rules (in camel case format), and the generated class names follow the BEM naming convention.
For example, an instance of Frames initialized with these values:
1Frames.init({2publicKey: 'YOUR-API-KEY',3style: {4base: {5color: 'black',6fontSize: '18px',7},8autofill: {9backgroundColor: 'yellow',10},11hover: {12color: 'blue',13},14focus: {15color: 'blue',16},17valid: {18color: 'green',19},20invalid: {21color: 'red',22},23placeholder: {24base: {25color: 'gray',26},27focus: {28border: 'solid 1px blue',29},30},31},32});
Produces the following CSS rules:
1.card-number {2color: black;3font-size: 18px;4}5.card-number:-webkit-autofill {6background-color: yellow;7}8.card-number--autofilled {9background-color: yellow;10}11.card-number--hover {12color: blue;13}14.card-number--focus {15color: blue;16}17.card-number--valid {18color: green;19}20.card-number--invalid {21color: red;22}23input.card-number::-webkit-input-placeholder {24color: gray;25}26input.card-number::-moz-placeholder {27color: gray;28}29input.card-number:-ms-input-placeholder {30color: gray;31}32input.card-number--focus::-webkit-input-placeholder {33border: solid 1px blue;34}35input.card-number--focus::-moz-placeholder {36border: solid 1px blue;37}38input.card-number--focus:-ms-input-placeholder {39border: solid 1px blue;40}4142.expiry-date {43color: black;44font-size: 18px;45}46.expiry-date:-webkit-autofill {47background-color: yellow;48}49.expiry-date--autofilled {50background-color: yellow;51}52.expiry-date--hover {53color: blue;54}55.expiry-date--focus {56color: blue;57}58.expiry-date--valid {59color: green;60}61.expiry-date--invalid {62color: red;63}64input.expiry-date::-webkit-input-placeholder {65color: gray;66}67input.expiry-date::-moz-placeholder {68color: gray;69}70input.expiry-date:-ms-input-placeholder {71color: gray;72}73input.expiry-date--focus::-webkit-input-placeholder {74border: solid 1px blue;75}76input.expiry-date--focus::-moz-placeholder {77border: solid 1px blue;78}79input.expiry-date--focus:-ms-input-placeholder {80border: solid 1px blue;81}8283.cvv {84color: black;85font-size: 18px;86}87.cvv:-webkit-autofill {88background-color: yellow;89}90.cvv--autofilled {91background-color: yellow;92}93.cvv--hover {94color: blue;95}96.cvv--focus {97color: blue;98}99.cvv--valid {100color: green;101}102.cvv--invalid {103color: red;104}105input.cvv::-webkit-input-placeholder {106color: gray;107}108input.cvv::-moz-placeholder {109color: gray;110}111input.cvv:-ms-input-placeholder {112color: gray;113}114input.cvv--focus::-webkit-input-placeholder {115border: solid 1px blue;116}117input.cvv--focus::-moz-placeholder {118border: solid 1px blue;119}120input.cvv--focus:-ms-input-placeholder {121border: solid 1px blue;122}
You can customize customer experiences further using the configuration options in Frames reference.