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 contextarrow-up-right, loading the Microform script dynamically, creating secure input fields, and submitting the form to generate an encrypted card token.

Steps

  • Generate Payment Contextarrow-up-right Use the endpoint to generate a payment context token with the desired transaction amount and currency. This token is required to initialize the Microform and process payments securely.

  • Load CyberSource Microform Script Once you have the payment context token, extract the required script metadata and dynamically load the Microform script. Extract Script Metadata Decode the payment context token to retrieve the following:

    • clientLibrary: The URL for the CyberSource Microform script.

    • clientLibraryIntegrity: The integrity hash for secure script loading.

    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);
  • Initialize CyberSource Microform Once the script is successfully loaded, initialize the Microform and create secure input fields. Create Input Fields

  • Submitting the Payment Form Once the fields are created and injected, the form can be submitted along with non-sensitive card expiration date data. The createToken method generates a secure token for the card details.

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.

Last updated