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

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

2 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

2 days ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

3 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

5 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We have brought exciting news for Magento store owners. Hyvä Themes recently released 1.3.6 and…

5 days ago

How Modern E-Commerce Platforms Leverage Docker & Kubernetes for Scalability

Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…

6 days ago