Skip to main content

Create API to Initiate Payment Session

When a customer initiates a payment on the storefront’s checkout page, the storefront sends a payment request to Fynd Commerce. Upon receiving this request, Fynd Commerce generates a gid (a unique transaction identifier) and a fynd_platform_id (a unique order identifier associated with the payment). To process the payment, Fynd Commerce calls the initiatePaymentSession API of the Payment Extension, providing essential payment details such as customer information, transaction amount, currency, and supported payment methods.

  • Endpoint: POST/credentials/:app_id

Request

The below-given example request shows that before proceeding with the request, the Payment Extension validates the checksum_auth in the headers to ensure the authenticity of the transaction. Once the initiatePaymentSession API is called, the Payment extension processes the request and interacts with the PG to create a payment session. It ensures that each payment transaction is uniquely identified, securely processed, and properly recorded within the Fynd Commerce.

{
"customer_name": "Ram Kumar",
"customer_email": "abc@gmail.com",
"app_id": "662a5f123456789abcde",
"company_id": "2345",
"customer_contact": "1234567890",
"gid": "TR662637B30D570001",
"fynd_platform_id": "FY662A607D0EC6524BEA",
"g_user_id": "65fc3a26b7e85bd44752641a",
"amount": 100000,
"currency": "INR",
"merchant_locale": "en",
"locale": "en",
"mode": "live",
"journey_type": "forward",
"payment_methods": [
{
"code": "TABBY",
"name": "TABBY",
"sub_payment_mode": []
}
],
"success_url": "https://fynd.com/cart/order-status?success=true&status=complete&order_id=FY662A607D0EC6524BEA&aggregator_name=Tabby&cart_id=662a5d614d4cd74ae13afe36",
"cancel_url": "https://fynd.com/cart/order-status?success=false&status=failed&order_id=FY662A607D0EC6524BEA&aggregator_name=JioOnePay&cart_id=662a5d614d4cd74ae13afe36",
"billing_address": {
"area": "Whitefield",
"city": "Bangalore",
"name": "Ram Kumar",
"email": "abc@gmail.com",
"phone": "1234567890",
"state": "Karnataka",
"address": "123, ABC Street, Whitefield",
"country": "India",
"pincode": "560066",
"landmark": "Near ITPB",
"area_code": "560066",
"pos_state": "Karnataka",
"address_id": 3535,
"address_type": "home",
"area_code_slug": "560066",
"country_iso_code": "IN",
"country_phone_code": "+91",
"g_address_id": "A1B2C3D4E5"
},
"shipping_address": {
"area": "Whitefield",
"city": "Bangalore",
"name": "Ram Kumar",
"email": "abc@gmail.com",
"phone": "1234567890",
"state": "Karnataka",
"address": "123, ABC Street, Whitefield",
"country": "India",
"pincode": "560066",
"landmark": "Near ITPB",
"area_code": "560066",
"pos_state": "Karnataka",
"address_id": 3535,
"address_type": "home",
"area_code_slug": "560066",
"country_iso_code": "IN",
"country_phone_code": "+91",
"g_address_id": "A1B2C3D4E5"
},
"kind": "sale",
"initiated_at": 1714053246,
"cod_eligibility": true,
"meta": {}
}

Response

In the below given example response, the response received from the Payment extension indicates that the payment session request was processed, but the payment initiation was unsuccessful. The response contains the gid, uniquely identifying the transaction, and the redirect_url, pointing to the PG’s hosted payment page. Despite the unsuccessful status, the redirect_url suggests that the customer might still be able to attempt the payment.

{
"gid": "TR64D4E4250DB0CBEF1D",
"redirect_url": "https://pg-url.com/payments/payment_id_001",
"success": false
}

Was this section helpful?