Skip to content

Checkout Controller

Checkout Controller Documentation

Overview

The Checkout Controller manages the financial transactions by tokenizing card data, initiating sales, and processing final sale confirmations.

Functions

  1. tokenizeCard: Isolates the card tokenization process. It sends card data to the tokenization endpoint and returns a token representing the card (facToken).

  2. checkout: Manages the checkout process. It tokenizes user’s card data, updates the user’s facToken, then sends a sale request to the PowerTrans endpoint, extracts RedirectData from the response and sends it to the frontend, which is then rendered in an iframe to trigger the 3D Secure process and then the process Sale endpoint.

  3. processSale: Completes the transaction. It extracts the SpiToken from the request body and sends it to the process sale endpoint. Depending on the response, it sends back a success or error message to the client.

Process Flow

  • Tokenization: User’s card data is securely tokenized and stored as facToken in the user’s record.
  • Sale Request: A sale request is made using the facToken, and the response’s RedirectData is passed to the frontend.
  • Finalizing Sale: The processSale function uses the SpiToken to finalize the transaction, sending back a transaction status to the frontend.

Importance

This controller is critical for securely handling sensitive payment information and ensuring that transactions are processed accurately and efficiently, providing a secure and user-friendly payment experience.