Assistance Needed: Dynamic Suggested Refund Calculation Using GraphQL

Hello everyone,

We have a GraphQL query to fetch the suggested refund for an order without applying any taxes and duties. However, the SuggestedRefund endpoint doesn’t accept the argument refundImportTaxes. Our goal is to dynamically obtain the suggested refund value based on the selection of items, shipping, duties, and taxes.

Is there a workaround to achieve this?

GraphQL (API Version: 2024-07)
endpoint: query SuggestedRefund.
Parameter used:

{
    "id": "gid://shopify/Order/12345678",
    "refundLineItems": [
        {
            "lineItemId": "gid://shopify/LineItem/13579876",
            "quantity": 1,
            "restockType": "CANCEL",
            "removal": true
        }
    ],
    "refundDuties": [],
    "refundImportTaxes": false,
    "refundAdditionalFees": [],
    "shippingAmount": {
        "amount": "0.0",
        "currencyCode": "USD"
    }
}

You can try this

  • Start by fetching the order details—you need to get the prices, taxes, and duties from the Shopify API.

  • Next, calculate the refund—take the total amount for the selected items and subtract the duties and taxes. This gives you the exact amount to refund without any extra charges.

  • Finally, create the refund—use your calculated amount to process the refund through Shopify’s API, ensuring that only the correct amount is refunded, excluding any duties and taxes.

This is not what we intend to do. This is what we have already done. However we would like to utilize SuggestedRefund GraphQL endpoint to achieve those which is explained above in the query.

Thanks for this. We have figured out with the SuggestedRefund API. The process is similar to what you have shared.

@Sudhir can you elaborate on this for the rest of us with the same problem?

This is elaborated by @conversionist . That is the same process that we did using suggested refund api.