Card Tokenization with EBANX.js
EBANX card tokenization is a process that securely replaces sensitive payment information, like credit card numbers, with a unique token. This token can be stored and reused for future payments without exposing sensitive card data, helping you comply with PCI DSS regulations. For you as a merchant, this means you can offer a faster checkout experience for returning customers and handle recurring payments securely, all while reducing your risk of handling sensitive information directly. Tokenization ensures that payment data is protected, simplifying your security requirements and improving the customer experience. This page explains how to create a credit card token.
Tokenization methods
There are two options to create a token.
Requirements
- Credentials
- If using EBANX.js
- You'll need your EBANX.js Public Integration Key, which can be found in your EBANX Dashboard.
- If you don't have it, complete the Merchant Signup Form.
- If using Direct API
- You'll need an EBANX Direct API integration key.
- If not, complete the Merchant Signup Form.
- If using EBANX.js
Instructions
Method 1 - Create a token using EBANX.js
Install EBANX.js
Insert script tag
Add the following to your HTML.
<script type="text/javascript" src="https://ebanx-js.ebanx.com/latest/dist/ebanx.min.js"></script>
Initialize
Include the following function in your JavaScript.
EBANX.init({
publicIntegrationKey: '{your_public_integration_key}',
country: '{country_code_here}',
mode: 'test',
});Initialization parameters
Field Description publicIntegrationKey
Merchant's public integration key country
Customer country code.
2-digit String
International standard - ISO 3166-1 alpha-2mode
test
orproduction
Create object with payment information
Include the following fields:
// Payment Information object
const tokenizeOptions = {
card: {
number: '4111111111111111',
dueDate: '12/2025',
holderName: 'JOAO DA SILVA',
},
paymentTypeCode: 'creditcard',
countryCode: 'br',
};Create token
Call the
EBANX.cardTokenizer.tokenize
function, passing the object created in the previous step.EBANX.cardTokenizer
.tokenize(tokenizeOptions)
.then((tokenizedCard) => {
// use tokenizedCard to fullfil payment
})
.catch((error) => {
// handle errors
});EBANX.cardTokenizer.tokenize
returns a Promise. Handle the asynchronous call with a callback function.// Example - tokenizedCard
{
payment_type_code: 'visa';
token: 'c7957fc8d0e92c8fa859120ccbf24ef03486dc2cbc9081447bf883a6c495c71fdcd85b77db23373ae3ab76910a8857eb7788540c190a7160195d51de016699f6';
}Add token to Direct API payment request
Use the EBANX Direct API to create a payment request.
Include the token from previous step to the
card
object in your API call.Examples
-Using Spread Operator:
// payment.card object in your EBANX Direct API request
"payment" : {
"card": {
...tokenizedCard // Spread Operator
}
}-Older Javascript:
// payment.card object in your EBANX Direct API request
"payment" : {
"card": {
'payment_type_code': 'visa';
'token': 'c7957fc8d0e92c8fa859120ccbf24ef03486dc2cbc9081447bf883a6c495c71fdcd85b77db23373ae3ab76910a8857eb7788540c190a7160195d51de016699f6';
}
}Congratulations!
You have succesfully created a token using EBANX.js.
Resources
Use the following resources when testing in Sandbox Mode. All transactions in sandbox mode simulate real transactions, but no actual funds are moved.
Sample Cards
Click here to view mock card data to validate your payment integration.
API Reference
Click here to access detailed API documentation to integrate efficiently.
Mock Customer Data
Click here to view mock customer data for testing and validating user flows.
Error Codes
Click here to review common error codes to troubleshoot and resolve issues quickly.
Importing Tokens
If you need to import existing tokens from another provider, you’ll need to export them securely using encryption. Use the following public key to encrypt the files from your current provider before sending them to EBANX:
Still need help?
We hope this article was helpful. If you still have questions, you can explore the following options:
- Merchant support: Contact our support team at sales.engineering@ebanx.com for assistance.
- Not a partner yet? Please complete the Merchant Signup Form, and our commercial team will reach out to you.