/
HLD - Razorpay Route Integration

HLD - Razorpay Route Integration

Details needed to make this integration work:

 

Step 1. The following keys are required to generate a basic auth token to validate the requests:

  • [YOUR_KEY_ID]

  • [YOUR_KEY_SECRET]

Step 2. Once we have these two credentials, the app will be installed and connected.

Step 3. Now, to perform the settlement of Prepaid Orders, we can use two below-mentioned approaches:

Approach 1: We listen to the shipment delivered event and check if the particular is fulfilled by the Distributor or Eshopbox, based on which razor_pay_account_id will be fetched and can be used to perform the transfer.

Step-wise flow for this approach:

  1. Check the configuration set by the client for settling the payment, which could be order delivered date+ N days configured by the client in the settings.

  2. If No return is initiated on this order, we need to check for the shipments.warehouse_id or externalWarehouseID given in the particular event.

  3. Using externalWarehouseID, and account_id combination, pick the razor_pay_account_id from eshopbox_wms_production.account_warehouse_mapping

  4. Using this razor_pay_account_id, we need to prepare the request given as below to do the settlement of the payment.

POST API:

https://api.razorpay.com/v1/payments/{pay_id}/transfers

Request Body:

{ "transfers": [ { "account": "razor_pay_account_id",//Please replace with appropriate ID. "amount": 100, "currency": "INR", "on_hold": true, "on_hold_until": 1671222870 } ] }

Mapping of Keys:

Keys

Values

Keys

Values

pay_id

order_additional_details.receipt.payment_id

account

account_warehouse_mapping.razor_pay_account_id

amount

To be calculated on condition explained below

currency

order_additional_details.currency

on_hold

true or false(Depends upon the settings)

on_hold_until

Epoch Time (Depends upon the settings)

Conditions to decide for Amount:

Step 1. Fetch all the order_items(status !=cancelled) using the following conditions:

  • externalChannelID

  • customerOrderNumber

  • externalShipmentID

Step 2. Once the items are retrieved, then we need to make the sum of order_items.invoiceTotal, and it will become our transfers[].amount

Step 4. Once the settlement is scheduled for the N Days configured by the Client on Razorpay, we need to save the status as order_settled in shipment_status_logs

Approach 2: Cron-based approach

Step-wise flow for this approach:

  1. Fetch all the active connections of Razor Pay

  2. Out of active connections, check for the channel configured for the settlements of payments via Razorpay Route Integration.

  3. Now, pick one connection and fetch all the Prepaid Orders and shipment_status_logs.status !='order_settled ' of that particular channel delivered + N days which the client configures in the settings.

  4. If No return is initiated on this order, we need to check for the shipments.warehouse_id or externalWarehouseID

  5. Using externalWarehouseID, and account_id combination, pick the razor_pay_account_id from eshopbox_wms_production.account_warehouse_mapping

  6. Using this razor_pay_account_id, we need to prepare the request explained as above.

  7. Once we have successfully made the settlement on Razorypay, then we need to save the status as order_settled in shipment_status_logs

 

Related content