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.
- Customer initiates payment on storefront's checkout page.
- Storefront sends initiate payment request to Fynd Platform.
- Fynd Platform calls initiatePaymentSession API of Payment Extension with following details
gid
: Transaction ID that uniquely identifies a payment request.- Request body containing payment details,
success_url
(where the customer will be redirected after successful payment) andcancel_url
(where the customer will be redirected if the payment fails or is canceled).
- Payment extension creates payment session with the Payment Gateway.
- Payment Gateway creates the payment/order and responds with a URL of its hosted payment page
- Payment Extension sends the response of initiatePaymentSession API to Fynd Platform with the
redirect_url
. - Fynd Platform redirects the customer to
redirect_url
.
Payment Success
- After customer has completed payment, Payment Gateway sends success callback to the Payment Extension.
- Payment Extension updates
complete
status of payment transaction to Fynd Platform through updatePaymentSession API. Only following values of payment status are accepted- started: State of payment transaction when it is created.
- pending: Payment Extension sends this status if the payment status is pending or not received from Payment Gateway.
- complete: Payment Extension sends this status when it receives successful payment status from Payment Gateway.
- failed: Payment Extension sends this status when it receives failed/cancelled payment status from Payment Gateway.
- Fynd Platform acknowledges
complete
status of payment transaction in response to updatePaymentSession API. - Payment Extension redirects the customer to the
success_url
received in step step 3. - Payment Gateway sends payment completion webhook to Payment Extension.
- Payment Extension updates
complete
status of payment transaction to Fynd Platform through updatePaymentSession API as shown in step 9. - Fynd Platform acknowledges
complete
status of payment transaction in response to updatePaymentSession API.
Payment Failure
- Customer cancels the payment or there is some error in completing payment.
- Payment Gateway sends the payment failure callback to the Payment Extension.
- Payment Extension updates
failed
status of payment transaction to Fynd Platform through updatePaymentSession API. Only following values of payment status are accepted:- started: State of payment transaction when it is created.
- pending: Payment Extension sends this status if the payment status is pending or not received from Payment Gateway.
- complete: Payment Extension sends this status when it receives successful payment status from Payment Gateway.
- failed: Payment Extension sends this status when it receives failed/cancelled payment status from Payment Gateway.
- Fynd Platform acknowledges
failed
status of payment transaction in response to updatePaymentSession API. - Payment Extension redirects the customer to the
cancel_url
received in step 3. - Payment Gateway sends payment failure webhook to Payment Extension.
- Payment Extension updates
failed
status of payment transaction to Fynd Platform through updatePaymentSession API as shown in step 17. - Fynd Platform acknowledges
failed
status of payment transaction in response to updatePaymentSession API.
Payment Pending
- 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 tosuccess_url
. - 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
orfailed
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
.
- started: State of payment transaction when it is created.
- pending: Payment Extension sends this status if the payment status is pending or not received from Payment Gateway.
- complete: Payment Extension sends this status when it receives successful payment status from Payment Gateway.
- failed: Payment Extension sends this status when it receives failed/cancelled payment status from Payment Gateway.