Post-purchase: shipping refund leads to incorrect thankyou page and totalRefundedShippingSet amount

I’m making custom app with post-purchase extension.

TLDR: If I refund shipping while the customer is still on the post-purchase - thankyou page doesn’t show the post-purchase items. Also graphQL order query returns 0 on totalRefundedShippingSet.

Long version:

We have a thing in our shop: when the customer has a subscription in the order, or the order amount is above a certain threshold - the shipping is free. I think that’s a common thing. That’s a promise we give to our customers, and we want to fulfill it. And by “order” I mean checkout items AND items in post-purchase. That means, if the customer was not originally eligible for free shipping (order amount is below threshold and has no subs) when completing the checkout, and after accepting the post-purchase items they became eligible (they accepted sub, or overall amount hits the threshold), we need to refund the shipping amount we charged at checkout. And for that, I’m doing 2 operations:

  1. Refund. Technically do a graphQL mutation refundCreate, example input:
    {
    orderId: ‘gid://shopify/Order/6444864962863’,
    notify: true,
    refundLineItems:[],
    transactions: [
    {
    orderId: ‘gid://shopify/Order/6444864962863’,
    parentId: ‘gid://shopify/OrderTransaction/7898163511599’,
    amount: 6.9,
    gateway: ‘bogus’,
    kind: ‘REFUND’
    }
    ],
    shipping: { amount: 6.9, fullRefund: true },
    note: ‘Refund shipping cost’
    }
  2. Remove the shipping line. For some reason the shipping line is not removed/nullified automatically on refund, so I have to do it manually. Technically I edit the order with graphQL mutations orderEditBegin, orderEditRemoveShippingLine, orderEditCommit.

And I do these 2 things on the event of accepting an post-purchase offer, and (that’s important) I make sure these 2 operations are done BEFORE displaying the next offer or redirecting to thank you page. So that we expect the thank you page to have an updated info.

That was the introduction. Now the issues, as we have 2.

  1. Thank you page doesn’t reflect any changes. No accepted post-purchase items, shipping is still there. Basically a plain checkout order. That’s a big issue, we’re deceiving our customers by showing a wrong order info.
    Surprisingly, if the customer refreshes the thankyou page and gets to the order status page, it shows the correct info (free shipping, all accepted post-purchase offers, correct refund amount). Emails are also fine.
    My experiments show that just one of these 2 operations is enough for this issue to reveal itself. Also, if we don’t remove the shipping line (skip operation 2) AND omit the “shipping” parameter in the refund input, thank you page will display the post-purchase items (but shipping amount will still be there, so the page shows incorrect total amount, as it includes shipping).
  2. When I fetch the order with graphQL order query (after refunding the shipping), the totalRefundedShippingSet is 0. Even after we’re done with thankyou page. That’s just not true, isn’t it?.

So, is it me doing something wrong here, or is the issue on the shopify side?
If the issue on the shopify side, when can we expect the fix?

Hi @Maksim_Vorobev

I believe what you’re experiencing is simply a limitation of the post-purchase/ thank you page. There are timing and processing considerations that can affect what the customer sees on the thank you page Our docs note:

The post-purchase page shouldn’t be used as a replacement for the Order status page.

The Thank You page often displays a cached or pre-generated version of the order summary, which may not include very recent changes. When the customer refreshes or visits the order status page later, the backend has had time to process the changes, so the correct information is shown.

There is no way to force the Thank You page to immediately reflect the latest order state after a refund or edit. This is a platform limitation. What you could explore is using a banner or message on the Thank You page to inform customers that their order is being updated and that the final details will be available shortly or in their order confirmation email.

If you want to show the most up-to-date information, you could build a custom Thank You/Order Status page using the Order Status Page API, but this is only available to Shopify Plus merchants.

Hope this helps,