How to Use secureToken for Secure Card Saving
This guide explains how to securely save customer card details using Tonder’s secureToken
. To obtain the token, you need to call the /api/secure-token/
endpoint from your the backend, ensuring secure and authenticated token generation. Once the token is retrieved, it can be implemented in your project from either the frontend or backend, depending on your setup and requirements.
You can generate the secureToken in either Stage and Production environments.
Initialize Tonder's SDK with Save Cards Customization
To allow your customers to save cards, you can customize card-saving options within the customization
object. Control whether customers can save cards, auto-save options, and the visibility of saved cards when starting the SDK.
showSaveCardOption
: Allows users to choose to save their card.autoSave
: Enables automatic card saving without user confirmation.showSaved
: Displays previously saved cards to the customer.
The Save Card functionality is specific to each business and should be configured accordingly.
Retrieve your Secret API Key
You’ll need your API Key to generate a secureToken
. You can find your Secret API key by accessing the Developers section in your Tonder Dashboard.
Generate a secureToken
With your API Key in hand, you need to make a POST request to the Create a Secure Token endpoint:
Within the JSON response, you can find an access
property. This is the generated secureToken
you need for the next steps. Below is an example format of the response:
The generated secureToken
is valid for 1 hour. Ensure that it is used within this time frame to avoid authentication errors.
Configure the Checkout with your secureToken
After obtaining the secureToken
, configure the Tonder SDK checkout on the frontend to authenticate and secure transactions. Use the configureCheckout
method, which accepts the secureToken
along with customer data:
Where:
checkoutData.customer
: Contains customer information.secureToken
: The token generated by the backend.
After completing these steps, your SDK implementation should look like the following example: