Fragments (Lite)
1
2
3
Generate a secure card token
// This is an asynchronous function, so you'll need to use async/await or .then()
async function processPayment(cardDetails) {
try {
// Assuming 'cardDetails' is an object with the required card fields
const response = await window.D24.generateToken({ card: cardDetails });
// The secure token
const token = response.token;
// Now, send this token to your backend server to make the API call
// to finalize the deposit.
console.log('Token created:', token);
// sendTokenToServer(token);
} catch (error) {
// Handle any validation or network errors
console.error('Error generating token:', error.message);
}
}
// Example usage:
const myCardInfo = {
number: '4509953566233704',
holder: 'Juan Perez',
cvv: '123',
expirationMonth: '11',
expirationYear: '25',
};
processPayment(myCardInfo);
Build the solution


Last updated
Was this helpful?

