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.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Error calculate full shipping refund via REST API

Error calculate full shipping refund via REST API

steven-ic
Shopify Partner
4 0 0

Request:

Calculate refund

 

{
  refund: {
    shipping: {
      full_refund: true
    }
  }
}

Response: 

 

 

 

{"errors":{"refund_shipping_lines":["is invalid"]},"error_reference":"If you report this error, please include this id: 674bf623-9044-4efc-b7eb-6074d122acd7-1721085465."}

 

 

 

We've been doing shipping refunds like these without issue. This appears to be a new error. Based on the API documentation, there is no `refund_shipping_lines` field in this API endpoint. It is unclear what the issue is.

Replies 4 (4)

Liam
Community Manager
3108 344 910

Hi Steven,

 

From checking the ID on our side, I'm not seeing a lot of info other than the call to `/refunds/calculate.json` failed - the reference to `refund_shipping_lines` implies that you tried to use `refund_shipping_lines` in the request, but it doesn't seem like you did. If you try the same request with the `2023-10` version instead, do you see the same error? 

 

Alternatively could you try testing if you can query an orders SuggestedRefund object to return a suggested refund amount based on the items being reimbursed. It could look something like:

query CalculateSuggestedRefund {
  order(id: "gid://shopify/Order/1234567890") {
    suggestedRefund(
      refundLineItems: [
        {
          lineItemId: "gid://shopify/LineItem/0987654321",
          quantity: 1
        }
      ],
      refundShipping: true,
      shippingAmount: {
        amount: "5.00",
        currencyCode: USD
      }
    ) {
      totalRefundedSet {
        presentmentMoney {
          amount
          currencyCode
        }
      }
    }
  }
}

And you can test this out with the GraphiQL tool

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

steven-ic
Shopify Partner
4 0 0

Hi Liam,

 

I was able to get the original request to work by first unarchiving/opening the order.

 

This seems like a new bug/requirement as we've done thousands of successful refund calculation requests like these before and I'm sure at least some of those involved orders that were archived.

 

Maybe this additional piece of information helps?

 

Thanks for looking into this!

muhammadsalmank
Shopify Partner
26 1 4

Hi,

Did you try this one for calculate the refund:

POST "https://********.myshopify.com/admin/api/2024-01/orders/6215*****336/refunds/calculate.json"

{"refund":{"currency":"EUR","shipping":{"amount":4.95},"refund_line_items":[{"line_item_id":"15********","quantity":"1"}]}}

 

for me its always works fine.

 

steven-ic
Shopify Partner
4 0 0

Thanks. However, that is a different request entirely as it specifies a shipping `amount` as well as `refund_line_items`.