Skip to main content

Implement payment flow

Overview

This guide provides a step-by-step overview of the payment process facilitated by the Fynd Platform for its payment extension integration. It outlines the interaction between the various components involved, including the customer, the Fynd Platform, the Payment Extension, and the Payment Gateway. Below is a flow diagram that illustrates the payment flow.

QG1

  1. Customer initiates payment on storefront's checkout page.
  2. Storefront sends initiate payment request to Fynd Platform.
  3. Fynd Platform calls initiatePaymentSession API of Payment Extension with following details
    1. gid: Transaction ID that uniquely identifies a payment request.
    2. Request body containing payment details, success_url (where the customer will be redirected after successful payment) and cancel_url (where the customer will be redirected if the payment fails or is canceled).
  4. Payment extension creates payment session with the Payment Gateway.
  5. Payment Gateway creates the payment/order and responds with a URL of its hosted payment page
  6. Payment Extension sends the response of initiatePaymentSession API to Fynd Platform with the redirect_url.
  7. Fynd Platform redirects the customer to redirect_url.

Payment Success

  1. After customer has completed payment, Payment Gateway sends success callback to the Payment Extension.
  2. Payment Extension updates complete status of payment transaction to Fynd Platform through updatePaymentSession API. Only following values of payment status are accepted
    1. started: State of payment transaction when it is created.
    2. pending: Payment Extension sends this status if the payment status is pending or not received from Payment Gateway.
    3. complete: Payment Extension sends this status when it receives successful payment status from Payment Gateway.
    4. failed: Payment Extension sends this status when it receives failed/cancelled payment status from Payment Gateway.
  3. Fynd Platform acknowledges complete status of payment transaction in response to updatePaymentSession API.
  4. Payment Extension redirects the customer to the success_url received in step step 3.
  5. Payment Gateway sends payment completion webhook to Payment Extension.
  6. Payment Extension updates complete status of payment transaction to Fynd Platform through updatePaymentSession API as shown in step 9.
  7. Fynd Platform acknowledges complete status of payment transaction in response to updatePaymentSession API.

Payment Failure

  1. Customer cancels the payment or there is some error in completing payment.
  2. Payment Gateway sends the payment failure callback to the Payment Extension.
  3. Payment Extension updates failed status of payment transaction to Fynd Platform through updatePaymentSession API. Only following values of payment status are accepted:
    1. started: State of payment transaction when it is created.
    2. pending: Payment Extension sends this status if the payment status is pending or not received from Payment Gateway.
    3. complete: Payment Extension sends this status when it receives successful payment status from Payment Gateway.
    4. failed: Payment Extension sends this status when it receives failed/cancelled payment status from Payment Gateway.
  4. Fynd Platform acknowledges failed status of payment transaction in response to updatePaymentSession API.
  5. Payment Extension redirects the customer to the cancel_url received in step 3.
  6. Payment Gateway sends payment failure webhook to Payment Extension.
  7. Payment Extension updates failed status of payment transaction to Fynd Platform through updatePaymentSession API as shown in step 17.
  8. Fynd Platform acknowledges failed status of payment transaction in response to updatePaymentSession API.

Payment Pending

  1. In case after customer completed the payment, payment transaction status is pending from Payment Gateway, Payment Extension should send pending status in updatePaymentSession API and then redirect the customer to success_url.
  2. As soon as Payment gateway sends either success or failed webhook, Payment Extension should update the same to Fynd Platform through updatePaymentSession API by sending complete or failed status respectively.

Crons Jobs

Fynd Platform runs regular cron jobs to check the status of payment transactions by sending a GET request to Payment Extension on getPaymentStatus API. Payment Extension is expected to respond with status of payment transaction corresponding to gid parameter. Accepted values of payment status are started ,pending, complete and failed.

  1. started: State of payment transaction when it is created.
  2. pending: Payment Extension sends this status if the payment status is pending or not received from Payment Gateway.
  3. complete: Payment Extension sends this status when it receives successful payment status from Payment Gateway.
  4. failed: Payment Extension sends this status when it receives failed/cancelled payment status from Payment Gateway.