Skip to main content

New Payment Flow (Forward Flow)

Sellers can easily install and activate payment extensions on their Fynd Commerce store. During checkout, customers can access various payment options the selected extension offers, ensuring a smooth and flexible transaction process. Currently, Fynd Commerce supports a standard checkout flow, where customers are securely redirected to the PG’s hosted page to complete their transactions, ensuring reliability and compliance with payment processing standards. In Fynd Commerce, the payment process begins when a customer initiates a payment on the storefront’s checkout page. Once the payment is initiated, the storefront requests Fynd Commerce to process the payment.

Fynd Commerce then calls the initiatePaymentSession API of the Payment Extension, providing essential details such as:

  • gid: a unique transaction ID that identifies the payment request
  • Request body: containing payment details and redirection URLs
    • success_url: URL for the storefront’s order success page where the customer will be redirected after a successful payment
    • cancel_url: URL for the storefront’s order failure page where the customer will be redirected if the payment fails or is canceled

Upon receiving this request, the Payment Extension creates a session with the respective PG. The PG then processes the request by generating a payment order and responding with a URL to its hosted payment page. Following this, the Payment Extension sends the response of the initiatePaymentSession API back to Fynd Commerce, including the redirect_url. Finally, the Fynd Commerce redirects the customer to the provided redirect_url, allowing them to complete the payment on the PG’s hosted page.

Payment Flow

Payment Success

Once the customer has completed the payment, the PG sends a success callback to the Payment Extension. The Payment Extension then updates the payment transaction status to complete on the Fynd Commerce using the updatePaymentSession API. Upon receiving the status as complete, Fynd Commerce acknowledges it in response to the updatePaymentSession API. Following this, the Payment Extension redirects the customer to the success_url. Additionally, most PGs usually send payment completion webhooks to the Payment Extension, which further updates the payment transaction status to complete on the Fynd Commerce through the updatePaymentSession API, as described in the previous step. Finally, the Fynd Commerce once again acknowledges the status complete through updatePaymentSession API request, ensuring the payment process is fully recorded and finalized. The accepted payment status for updatePaymentSession API are:

  • started: State of the payment transaction when it is created.
  • pending: Payment Extension sends this status if the payment status is not received from PG.
  • complete: Payment Extension sends this status when it receives successful payment status from PG.
  • failed: Payment Extension sends this status when it receives failed/cancelled payment status from PG.

Payment Failure

If the customer cancels the payment or an error occurs during the transaction, the PG sends a payment failure callback to the Payment Extension. The Payment Extension then updates the payment transaction status to failed on Fynd Commerce using the updatePaymentSession API. Upon receiving the failed status, Fynd Commerce acknowledges it in response to the updatePaymentSession API. Following this, the Payment Extension redirects the customer to the cancel_url. Additionally, the PG sends a payment failure webhook to the Payment Extension, which further updates the payment transaction status to failed on Fynd Commerce through the updatePaymentSession API, as described in the previous step. Finally, Fynd Commerce acknowledges the failed status through updatePaymentSession API, ensuring the unsuccessful payment process is fully recorded and finalized. The accepted payment status for updatePaymentSession API are:

  • started: State of the payment transaction when it is created.
  • pending: Payment Extension sends this status if the payment status is not received from PG.
  • complete: Payment Extension sends this status when it receives successful payment status from PG.
  • failed: Payment Extension sends this status when it receives failed/cancelled payment status from PG.

Payment Pending

If the payment transaction status remains pending after the customer completes the payment, the Payment extension updates the Fynd Commerce by sending a pending status through the updatePaymentSession API. Despite the pending status, the Payment Extension redirects the customer to the success_url. Once the PG sends a webhook indicating the final payment outcome, whether success or failure, the Payment extension updates the Fynd Commerce using the updatePaymentSession API.

If the payment is successful, the status will be updated to complete; if the payment fails, the status will be updated to failed.

Crons Jobs

Fynd Commerce runs regular cron jobs to check the status of payment transactions by sending a get request to Payment Extension on the getPaymentStatus API. Payment Extension is expected to respond with the status of the payment transaction corresponding to the gid parameter.

Cron Jobs

Accepted values of payment status for updatePaymentSessionare:

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

To implement the payment processing flow, the following APIs are developed in the Payment extension:

  1. initiatePaymentSession
  2. getPaymentStatus

Was this section helpful?