New payment gateway integration flow
1. Change API version
Change x-api-version in header to 2023-08-012. Create order from backend
You’ll get payment_session_id in the response of create order (instead of order_token and payment_link) Below is the request and response you get when you create an order. Request3. Use new JS SDK to redirect to pre-built checkout
Once you receive payment_session_id from create order response, you need to use Cashfree’s JS SDK.Step 1: Include our SDK in your client code
Including the Script Tag. Import the URL in the snippet below to your HTML file.HTML
Shell
Step 2: Initialize the SDK
You need to initialise the variable using theCashfree() function. There are two modes applicable for this - “sandbox” or “production”. Sandbox is used for test environment, whereas production is used for production mode.
Step 3: Redirect to checkout
To open the checkout, you can usecashfree.checkout()method.
4. Handle redirection and confirm status
- Check status of the order.
- Redirection to return_url happens the same way as before. However, format of return_url doesn’t contain order-token now.
New formathttps://test.cashfree.com/pgappsdemos/return.php?order_id={order_id}
5. Whitelist domain
New integration will require whitelisting of the domain which is used to open the checkout page. You can request for a domain whitelisting via developers>whitelisting in your merchant dashboard or submit a Support Form.You can check the step-by-step process of making a whitelisting request.
New integration only supports opening of the checkout page via the whitelisted domain. Any other domain used to open the checkout page will be blocked by Cashfree and checkout page will not open.