Generate card payment token
Integrating CyberSource Microform for Secure Card Payments
Overview
This guide outlines the steps to integrate CyberSource's Microform to securely collect and tokenize payment card details. The process involves generating a payment context, loading the Microform script dynamically, creating secure input fields, and submitting the form to generate an encrypted card token.
Steps
Dynamically Load the Microform Script
const clientLibrary = capture_context?.clientLibrary;
const clientLibraryIntegrity = capture_context?.clientLibraryIntegrity;
const script = document.createElement("script");
script.type = "text/javascript";
script.async = true;
script.src = clientLibrary;
script.integrity = clientLibraryIntegrity;
script.crossOrigin = "anonymous";
document.body.appendChild(script);script.onload = () => {
const flex = new Flex(token); // Initialize Flex with the context token
const form = flex.microform("card");
// Create a secure card number input field
const cardNumberInput = form.createField("number", {
placeholder: "4444 4444 4444 4444",
});
// Create a secure CVV input field
const cardSecurityInput = form.createField("securityCode", {
placeholder: "123",
});
// Inject fields into pre-defined containers in your payment form
cardNumberInput.load("#number-container");
cardSecurityInput.load("#securityCode-container");
};
// token: The token generated from the card payment contextform.createToken(
{ expirationMonth: "01", expirationYear: "2028" },
(err, token) => {
if (err) {
console.error(err);
return;
}
makePaymentWithCardToken(token); // Send the token for processing
}
);Conclusion
By following these steps, you can securely integrate CyberSource's Microform into your payment flow, ensuring that sensitive card details are handled securely and tokenized before being sent for processing.
POST: v1/payment/get-capture-context
Params
payment_reference
string
The payment reference that was generated when initializing payment
Headers
secret-key
string
Your Vesicash secret key
public-key
string
Your Vesicash public key
Request body
currency (string): The currency for the payment.
country (string): The country for the payment.
narration (string): Description or reason for the payment.
method (string): The payment method to be used.
amount (number): The amount of the payment.
customer_first_name (string): The first name of the customer.
customer_last_name (string): The last name of the customer.
account_number (string): The customer's account number.
Request
For example, you can make a post request to the endpoint above and pass in the raw json data below to create a one-off transaction.
{
"email":"",
"customer_first_name":"segun",
"customer_last_name":"ige",
"customer_city":"ikorodu",
"account_number":"",
"phone_number":"",
}Response
{
"status": "success",
"code": 200,
"message": "success",
"data": {
"payment_link": "",
"reference": "",
"payment_id": "",
"status": "pending"
}
}Last updated