Magento Tutorials

How to Issue Refund (Credit Memo) using API in Magento 2

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.

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:

POST domain.com/rest/<store_code>/V1/order/1/refund

Here, 1 is order id.

Headers:

Content-Type: application/json
Authorization: Bearer <administrator token>

Payload:

{
  "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!

Click to rate this post!
[Total: 4 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate ?️ Certified Magento Developer?‍?. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.?

Recent Posts

Magento Open Source 2.4.8-Beta Release Notes

Magento Open Source 2.4.8 beta version released on October  8, 2024. The latest release of…

2 days ago

How to Create Catalog Price Rule in Magento 2 Programmatically?

Hello Magento Friends, Creating catalog price rules programmatically in Magento 2 can be a valuable…

2 days ago

Top 10 Tips to Hire Shopify Developers

As the world of eCommerce continues to thrive, Shopify has become one of the most…

5 days ago

Managing Browser Events and Navigation in Shopify Remix: useBeforeUnload, useHref, and useLocation Hooks

Shopify Remix is an innovative framework that provides a streamlined experience for building fast, dynamic,…

5 days ago

Ultimate Guide to Hiring a Top Shopify Development Agency

Building a successful eCommerce store requires expertise, and for many businesses, Shopify has become the…

6 days ago

How to Choose the Best Shopify Development Company?

In today’s digital landscape, e-commerce has become a cornerstone for businesses looking to thrive. Among…

6 days ago