Cancelling orders via the REST API is unexpectedly refunding the order

This appears to be new (and unexpected) behavior.

When cancelling an order via the REST API, the order is automatically being refunded. This happens when no amount or refund params are included in the request.

This is new behavior that started after April 1st. In the past, cancelling an order in this way would not automatically issue a refund.

1 Like

One of the issues with this unexpected change in behavior is that when cancelling the order via the REST API, and the refund being automatically created, is that the customer gets the “order cancelled” email, but they do not get a refund email. The cancel email may actually state something like “your order has been cancelled but has not been refunded yet.”

At this point the main question is: how do you cancel the order without it automatically processing the refund?

Hey @danatbonify

I just tested this on my end with the REST 2025-04 API and couldn’t replicate the behavior you’re describing. When cancelling both paid orders and orders that were authorized but not captured, no automatic refunds were processed.

Can you share more details about the orders you’re working with? Specifically, what’s the payment state of these orders when you’re attempting to cancel them? Are you using any specific parameters in your API request, even if they’re not refund-related? Also, which API version are you using? I’d like to try and replicate more closer to what you are seeing.

Hi @KyleG-Shopify thanks for taking a look. I am using API version 2024-07.

And after further review, the issue is actually not with the order cancel endpoint.

In our system, we also make a POST request to orders/$order_id/transactions if:

  • The transaction kind is authorization
  • The status is pending or success

The void request data looks like:

{
  "transaction": {
    "kind": "void",
    "parent_id": "$transaction_id"
  }
}

When we make that void API call, that is what actually refunds the order. However, we assumed that voiding the transaction would not issue a refund.

We have had this assumption since 2020-07 when we built this capability in our app. It’s totally possible our assumption was wrong five years ago. :slight_smile: I do not recall exactly why we thought at the time that a voided transaction would not issue refunds (I hope to imagine that we tested and confirmed this at the time).

Still, I cannot find any definitive documentation on “what happens when you void a pending or success transaction on a cancelled order.”

Thanks again for the help!

Thanks for that clarity. Since the VOID kind is specific to transactions that have not been captured, I wouldn’t expect any actual money to be refunded.

I did a quick test in the admin on an un-captured order and cancelled (which also voided) and there is a refund recorded, but it does note that it is a $0 refund with the balance being reduced.

Is this what you are seeing as well? Do you have examples of orders before April 1 that were different? When I look back in my test store, I have a voided order from last July that is showing the same as I see here:

For me, I am only testing this on my dev store with the bogus gateway. I am using “Credit Card” and “capturing” the payment.

First, my app cancels the order, then voids the authorization transaction. Here it appears to issue the refund in the full amount (a “refund” transaction is created automatically).

The reason this issue came up at all was one of our app customers complained about “refunds being issued automatically” all of the sudden.

In our app, we have a setting the user can toggle to optionally void the transaction when cancelling an order. Five years ago when we implemented the feature we added this help text to the Void setting:

Voids any pending credit card authorizations on the order. If payment has already been captured or collected, this setting will not refund any money already collected...

I cannot say with confidence that this issue is brand new. This issue came up from a customer who was using the functionality and ran into an issue.

From reviewing the code, comments, and other info, it seems like it’s possible that in the past, when trying to void an authorization transaction, and if the order also had a capture transaction, that maybe the API call would error? Like you’re not supposed to be able to void an authorization transaction when it’s been captured :man_shrugging:

Thanks for that. I’m seeing what you are seeing now.

Based on our docs I would assume as well that void would only work on orders not yet fully captured, but testing here I see the refunds are being issued.

I’ll bring this to our orders team and report back once I know more.

Hey @danatbonify

I just wanted to give you an update here that our developers are looking in to this. I did test the transactionVoid - GraphQL Admin mutation and that does return an error as we would expect. Are you able to switch to using Graphql?

Can you also clarify if you made any changes to the API version you were using, or have you been using 2024-07 for a while now, and the response you’re getting has just changed from what it was doing previously. Just to help us narrow down any version specific causes.

Only recently made the switch to 2024-07. Previously had been using 2024-04 until about mid-March.

When we update API versions we do a thorough audit of the API Release Notes to find any places that might break. I couldn’t find anything in the notes about it, so not 100% sure if it was related to the API version change.

We can update our app’s API call to use the Graph API.

Thanks!

That’s great, thanks! I have shared that with our dev team here as well. They have asked to create a support ticket so they can look in to your app specifically to see where this is occurring. You can create the ticket here: https://help.shopify.com/en/support/partners

Cool, I submitted ticket #56527930.

1 Like

Great! I’ve made sure it’s in the correct queue. Our team will follow up there once they have reviewed further.