Magento 2 API – Create Credit Memo
Magento Integration Made Easy!
Integrate any third-party tool or service with your store using our Magento API Integration Services.
Hello, Magento peeps!
I’m back with another blog post on the Magento 2 API series. Earlier, I posted about Magento 2 API to create a shipment. In this blog post, I will show you how to create credit memo in Magento 2 using REST API.
Product returns are common for eCommerce businesses. Customers return the products for a variety of reasons — size mismatch, an order placed by mistake, and wrong product received are a few to name. If you are a Magento developer creating a custom admin panel, you can use the REST API to create a credit memo and issue a refund in Magento 2.
How to Create a Credit Memo Using Magento 2 REST API?
Magento 2, being one of the most flexible eCommerce platforms, allows businesses to create and manage eCommerce stores as per the business requirements through APIs. The Magento 2 API to create a credit memo requires an admin-level access, and therefore the client needs to submit an authorization token along with the request.
In order to create a memo and issue a refund using Magento 2 REST API, the client needs to make a POST request to the order/<order_id>/refund endpoint. It can be better understood by the following:
Method: POST
URL: store_url/V1/order/<order_id>/refund
Headers:
- Content-Type: application/json
- Authorization: Bearer <admin token>
Body:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
{ "items": [ { "order_item_id": 5, "qty": 2 } ], "notify": false, "arguments": { "shipping_amount": 0, "adjustment_positive": 0, "adjustment_negative": 0, "extension_attributes": { "return_to_stock_items": [ 8 ] } } } |
Response:
On successful authorization of the API request, Magento will return the credit memo id.
Conclusion
You can use the about solution to issue refund in Magento 2 API by creating a credit memo. The admin can also tweak the payload and adjust the request as per the requirements. I hope you will find this blog helpful to create a credit memo and issue a refund in Magento 2 through API. In case you still have any queries or doubts regarding the solution, feel free to comment. I will be happy to help! 😊
Also, do not forget to share this Magento 2 API tutorial with your developer friends. 😃
Thanks for reading. 🍀
◄ Magento 2 API – Create A Shipment
Connect your Magento store with any third-party tool or service & improve your business efficiency.
Jignesh Parmar
An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.
Prev
Magento 2 API – Create a Shipment
How to Reload Current Page Without Losing Any Form Data in JavaScript?
Next