How to Do Online Refund Using REST API in Magento 2

magento2refundrest api

Accoring to Magento documentation, endpoint for online refund is:
POST /V1/invoice/<invoice_ID>/refund

So to my understanding, the following call should make an online refund:

    curl --location  -H "Authorization: bearer $TOKEN" -H "Content-Type:application/json" --request POST 'https://example.com/rest/default/V1/invoice/168/refund' \
--data-raw '{
    "items": [
        {
            "order_item_id": 241,
            "qty": 1
        }

    ],
    "notify": true,
    "arguments": {
        "shipping_amount": 6.90,
        "adjustment_positive": 0,
        "adjustment_negative": 1,
        "extension_attributes": {}
    }
}'

However, when I check the order, it says "We refunded 12,80 € offline."

offline refund

What is wrong here?

Best Answer

Just add "isOnline": true, before "notify": true,It will create online refund.