Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Calculate Refund API : Refund line items cannot remove more than the fulfillable quantity

Calculate Refund API : Refund line items cannot remove more than the fulfillable quantity

soulchild37
Shopify Partner
203 9 61

Yes I am aware there's a previous post : https://community.shopify.com/c/shopify-apis-and-sdks/refund-line-items-cannot-remove-more-than-the-...

This was happening on my live Shopify app, the Calculate Refund API returns a HTTP status 422 Error with message "cannot remove more than the fulfillable quantity." , if I set the "restock_type" of the refund_line_items to "cancel".

But if I set it to "return" , then it returns back a proper response, and the "restock_type" returned in the response is "cancel" ! 

This workaround works but I am afraid it might mess up inventory of other orders if the response returned back somehow is not "cancel" if I put in "return" as input.

I would be really thankful if any Shopify Staff can look into this issue as this has caused issues to merchants using my app.

The Request ID is 24f742a0-0e64-48ae-9f94-d86fb5d836f8




Spent too much support time dealing with order cancellation request from customer? Wouldn't it be good if customer can cancel order on their own without bugging your support? Try out Cancellable app! https://apps.shopify.com/cancellable . I also write articles about store customization that can improve your customer shopping experience here : Yagi Software Blog
Reply 1 (1)

mahendra_2890
Visitor
1 0 0

I ran into this issue today - and was not able to find a solution on the internet. Here is how I solved it

Steps to recreate this issue:
1. Create an order with more than one items.
2. Go to your admin, fulfil one of the items.
3. Attempt the request - it will throw this error that you are seeing.

Why does it happen?
In refund_line_items: You could be sending quantity for both the items (but since you had already fulfilled some of the items, the quantity needs to be decreased) When you chooserestock_type to cancel, you must only send the quantity which is unfulfilled for the variant.

  • quantity: The refunded quantity of the associated line item.
  • restock_type: How this refund line item affects inventory levels. Valid values:
    • cancel: The items have not yet been fulfilled. The canceled quantity will be added back to the available count. The number of fulfillable units for this line item will decrease.