How to transfer fund to route linked account in Razor pay through orders

Viewed 406

In Razorpay I have created an order with some amount, and also completed the payment transaction for the order, but now I need to transfer the amount to the linked account using the route, but the issue is when I use their transfer with order API from postman(which they provided in the docs). It's giving an error. What do I need to do in order to link it to the transfer and then complete the payment?

{ "error": { "code": "BAD_REQUEST_ERROR", "description": "The amount field is required.", "source": "business", "step": "payment_initiation", "reason": "input_validation_failed", "metadata": {}, "field": "amount" } }

But I have provided the amount field in the body of the request, here is what the body looks like

{
    "amount": 10000, // this is the smallest unit(also tried with the larger unit)
    "currency":"INR",
    "transfers": [
        {
            "account": "acc_hhsk",
            "amount": 10000,
            "currency": "INR",
            "notes": {
                "branch": "Chess Program",
                "name": "Nilesh Kumar"
            },
            "linked_account_notes": [
                "branch"
            ],
            "on_hold": false,
            "on_hold_until": null
        }
    ]
}

Before this, I have successfully generated the order_id. Please help me find how to link order_id with the transfer.

1 Answers

Pass like below it will work.

use Razorpay\Api\Api;

$transfer['transfers'][0]['account'] = "acc_IGd0hn6ZZ6khPr";
$transfer['transfers'][0]['amount'] = "800000";
$transfer['transfers'][0]['currency'] = "INR";
$notes['name'] = "sshhss";
$notes['roll_no'] = "IEC2011025";
$transfer['transfers'][0]['notes'] = $notes;
$transfer['transfers'][0]['linked_account_notes'] = ['roll_no'];
$transfer['transfers'][0]['on_hold'] = "1";
// $transfer['transfers'][0]['on_hold_until'] = "1671222870";
$paymentId = "Pay_heeu7333gg";

$api = new Api('API_KEY', 'API_SECRET');
$payment = $api->payment->fetch($paymentId)->transfer($transfer);
Related