Hello, Magento folks!
The term refund is something that most E-commerce store admins refuse to think about. But, regardless of how many times you think of preventing it, there comes a time when things go awry and you have to refund the money for the purchase made by them. This can be due to their dissatisfaction regarding the service or product you have provided.
So, when this appropriate moment arrives, what can you do? Issue a refund or a credit memo, right? That is what this blog conveys.
So, I have compiled this blog on how you can Issue Refunds using API in Magento 2.
Contents
Steps to Issue Refund (Credit Memo) using REST API in Magento 2
Step 1: Issue the refund
Magento 2.1.3 started two endpoints that rationalize the method to issue a refund by producing a creditmemo and modernizing the order in one call.
ENDPOINT | DESCRIPTION |
POST /V1/order/<order_ID>/refund | Issues an offline refund |
POST /V1/invoice/<invoice_ID>/refund | Issue a refund with an online payment system |
Endpoint:
1 |
POST domain.com/rest/<store_code>/V1/order/1/refund |
Here, 1 is order id.
Headers:
1 2 |
Content-Type: application/json Authorization: Bearer <administrator token> |
Payload:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ "items": [ { "order_item_id": 1, "qty": 1 } ], "notify": true, "arguments": { "shipping_amount": 0, "adjustment_positive": 0, "adjustment_negative": 0, "extension_attributes": { "return_to_stock_items": [ 1 ] } } } |
Response:
A credit memo id, such as 1.
Step 2: Check The Results from Backend
Log in to Magento backend and navigate to Sales → Credit Memos. Find the credit memo in the grid.
Bottom Line
It is worthwhile to pay heed to the fact that customer service does not get concluded after the purchase gets over. The customer might come back with his problems related to that product or service you provide. So, it is imperative to issue a refund using Magento 2 API.
Happy Coding!