Using Refunds API to issue Partial Refunds to Gift Cards instead of back to CC

Solved
Highlighted
Shopify Partner
20 0 0

Hello,

 

1. Let's say a order has two line items.  When a customer requests a refund for one of the items we first make a call to calculate refund endpoint.

 

https://${shop}/admin/api/2019-10/orders/${orderId}/refunds/calculate.json

As you already know, this returns a bunch of transactions.

 

2. I capture the relevant transaction from the call above.

I then prepare data to be sent to the refunds API.

For each transaction (that is to be returned) I alter the kind property to "refund"  and I also add another attribute called gateway.

 

Below is the body of the POST call:

 

EndPoint: POST method

 

https://${shop}/admin/api/2019-10/orders/${orderId}/refunds.json

Message body:

refund: {      notify: false,      note: "Special item",
      "refund_line_items": [
        {
          "line_item_id": refundLineItem,
          "quantity": 1,
          "restock_type": "no_restock"
        }
      ],
      [  // transactions
{
kind: "refund",
gateway: "gift_card",
... // other attributes
}
] },

 

I am not seeing any new Gift card being created with the refund amount. What am I missing here ?

 

 

 

 

0 Likes
Highlighted
Shopify Partner
20 0 0

Shopify staff.. any help will be appreciated.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
491 97 88

This is an accepted solution.

Hi @runTimeZero 

 

Right now with the online store, we only support refunds to the original method of payment of the order. If the order had been paid for using a gift card, then we would refund the money to that gift card. However, the API will not support “store credit refunds” (or “gift card refunds”) for orders that have been paid for using a credit card and then need to be refunded on a gift card.

 

The way to achieve this will be to utilize two API calls, one making a $0 refund using the refund API to set the order status to refunded and restock items, and then the second using the Gift Card API (For Shopify Plus) to create a new gift card with the amount to refund and send that to the buyer. Alternatively, the gift card would need to be created in the admin. 

 

You can see this in the documentation here: https://help.shopify.com/en/api/reference/orders/transaction where it states the gateway has to be the gateway the transaction was issued through. 

 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes
Highlighted
Shopify Partner
20 0 0

Thank you @vix for looking into this.

0 Likes