Magento 2 API Issue A Partial Refund

Magento 2 API (Updated 2024): Create a Partial Refund

In our previous post, we had created an invoice and a shipment, and with the order item id obtained, we can create a partial refund using Magento 2 API.

If the partial refund is called successfully, the status of the order will change to Complete.

Step 1: Generate Admin Access Token

POST <host>/rest/V1/integration/admin/token

Enter your admin username and password in the Body sections, then click Send.

{
  "username": "string",
  "password": "string"
}Code language: JSON / JSON with Comments (json)

Response: access token

Step 2: Issue A Partial Refund

Create a new request and enter the admin access token.

Authorization: Bearer token

POST <host>/rest/<store_code>/V1/order/6/refund

6 is the order id.

Payload:

{
  "items": [
    {
      "order_item_id": 9,
      "qty": 1
    }
  ],
  "arguments": {
    "shipping_amount": 0,
    "adjustment_positive": 0,
    "adjustment_negative": 0
  }
}
Code language: JSON / JSON with Comments (json)

Response:

A credit memo id, such as 3.

The response of Issue A Partial Refund call
The response of Issue A Partial Refund call

Step 3: Verify The Credit Memos

Log in to Admin. Click Sales > Credit Memos. The credit memo is displayed in the grid.

view partial refund in magento admin
The result of the credit memos after issue a partial refund
Magento 2 API: Issue A Partial Refund

Above, I have just provided you with three steps on how to create partial refunds. I hope it would be helpful for you, when creating partial refunds using Magento API. For more information, you can refer to Magento DevDocs. If you have any questions or new ideas, feel free to leave a comment below.