Tokenize credentials
Last updated: May 20, 2026
You can use Flow and Flow for mobile to securely collect and tokenize card details without going through the complete payment flow.
You receive a single-use token that you can use to:
- Forward to a third-party payment service provider (PSP).
- Request 3D Secure (3DS) authentication in a standalone session.
Make sure you have a Checkout.com test account.
Create a public key and a secret key in the Dashboard, with the following key scopes:
- Public key –
payment-sessions:payandvault-tokenization - Secret key –
payment-sessions
- Create a Payment Session.
- Initialize and mount Flow.
- Tokenize the card details.
Send a server-side request to securely create a PaymentSession object. The PaymentSession contains the information required to handle the card tokenization.
Call the Request a Payment Session endpoint with your secret key:
Information
Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see API endpoints.
post
https://{prefix}.api.checkout.com/payment-sessions
1{2"amount": 1000,3"currency": "GBP",4"reference": "ORD-123A",5"display_name": "Online shop",6"billing": {7"address": {8"country": "GB"9}10},11"customer": {12"name": "Jia Tsang",13"email": "jia.tsang@example.com"14},15"success_url": "https://example.com/payments/success",16"failure_url": "https://example.com/payments/failure"17}
1{2"id": "ps_2Un6I6lRpIAiIEwQIyxWVnV9CqQ",3"payment_session_secret": "pss_9823241e-2cec-4c98-b23d-7b29ow4e2e34",4"payment_session_token": "YmFzZTY0:eyJpZCI6InBzXzJVbjZJNmxScElBaUlFd1FJeXhXVm5WOUNxUSIsImFtb3VudCI6MTAwMCwibG9jYWxlIjoiZW4tR0IiLCJjdXJyZW5jeSI6IkdCUCIsInBheW1lbnRfbWV0aG9kcyI6W3sidHlwZSI6ImNhcmQiLCJjYXJkX3NjaGVtZXMiOlsiVmlzYSIsIk1hc3RlcmNhcmQiLCJBbWV4Il19XSwicmlzayI6eyJlbmFibGVkIjp0cnVlfSwiX2xpbmtzIjp7InNlbGYiOnsiaHJlZiI6Imh0dHBzOi8vYXBpLnNhbmRib3guY2hlY2tvdXQuY29tL3BheW1lbnQtc2Vzc2lvbnMvcHNfMlVuNkk2bFJwSUFpSUV3UUl5eFdWblY5Q3FRIn19fQ==",5"_links": {6"self": {7"href": "https://{prefix}.api.sandbox.checkout.com/payment-sessions/ps_2Un6I6lRpIAiIEwQIyxWVnV9CqQ"8}9}10}
Install the @checkout.com/checkout-web-components package via npm:
1npm install @checkout.com/checkout-web-components --save
Alternatively, load the package directly using a script:
1<script src="https://checkout-web-components.checkout.com/index.js" />
Note
To remain PCI compliant, only ever load the script directly from https://checkout-web-components.checkout.com. Do not download or host the script yourself, or include it in a bundle.
Use CheckoutWebComponents to create a card object:
1const cardComponent = checkout.create('card', {2showPayButton: false,3});
Check that the card component is available and mount it:
1if (await cardComponent.isAvailable()) {2cardComponent.mount('#card-container');3}
Note
Embedding Flow within an iframe or onto a Shadow DOM is not supported.
Display a submit button that initiates the card tokenization:
1<div id="card-container"></div>2<button id="card-pay-button" type="button">Pay</button>
Use the tokenize() method to initiate card tokenization.
The tokenization response is returned as the data object. You can access the generated card token within the data.token property.
1const cardPayButton = document.getElementById('card-pay-button');23cardPayButton.addEventListener('click', async () => {4const { data } = await cardComponent.tokenize();56await utilizeToken(data.token);7});
You can retrieve the details of an active token without consuming it. The token remains usable after retrieving its' metadata.
Call the Get token metadata endpoint, and provide the token ID as the {tokenId} path parameter.
Information
Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see API endpoints.
get
https://{prefix}.api.checkout.com/tokens/{tokenId}/metadata
1{2"token": "tok_4gzeau5o2uqubbk6fudbloo47a",3"type": "card",4"expires_on": "2026-05-14T10:11:12Z",5"expiry_month": 12,6"expiry_year": 2030,7"scheme": "Visa",8"last4": "4242",9"bin": "424242",10"card_type": "CREDIT",11"card_category": "CONSUMER",12"issuer": "Test Bank",13"issuer_country": "US",14"product_id": "A",15"product_type": "Visa Traditional",16"billing_address": {17"city": "Anytown",18"country": "US"19}20}