Processing a refund
To process a refund, Shopify makes an HTTP call to your app, and your app completes the refund by replying with a GraphQL mutation. This interaction is illustrated in the following diagram:
- Merchant requests refund.
- Shopify sends a backend request to the payments app, specifying the refund.
- The app replies with a 201 and an empty response body.
- The app finalizes the refund using either RefundSessionResolve or RefundSessionReject mutations.
- Shopify updates the refund status.
- You've completed the Getting started building payments apps.
- You've familiarized yourself with the general transaction requirements.
- You've made sure your payment apps meet the payments apps requirements.
To use the GraphQL mutations, your app must be aware of access scopes for payments apps.
Initiate the refund flow
The refund flow begins with an HTTP request sent from Shopify to the provider's refund session URL as provided during payments app extension configuration:
||Unique identifier for the refund attempt. Used as the idempotency key. It can be assumed that requests with a given ID are identical to any previously-received requests with the same ID.||
||Identifies the refund when communicating with Shopify (in GraphQL mutations, for example).||
||ID of the original payment that is to be refunded. For captured payments, this ID corresponds to the original authorization ID rather than the capture ID.||
||The amount to be refunded. The amount is always sent using a decimal point as a separator, regardless of locale.||
||Three-letter ISO 4217 currency code.||
||IETF BCP 47 language tag representing the language used by the merchant.||
||Timestamp representing when the refund request was proposed.||
||The permanent domain of the merchant's shop. Can be used to identify which shop is initiating the refund.|
||The unique request ID used to track specific requests for troubleshooting purposes.|
||The API version selected in the payments app configuration. The version selected defines the response expected by the payments app.|
Shopify must receive a HTTP 201 response for the refund session creation to be successful.
If the request fails, then it's retried several times. If the request still fails, then the merchant needs to manually retry the refund in the Shopify admin.
Resolve a Refund
After you've successfully processed the refund request, you can resolve it by using the refundSessionResolve mutation:
id argument corresponds to the
gid of the refund.
Reject a refund
If you cannot process a refund, then you should reject it. You should only reject a refund in the case of final and irrecoverable errors. Otherwise, you can re-attempt to process the refund.
You can reject a refund using the refundSessionReject mutation:
As part of the rejection, you need to include a reason why the refund was rejected as part of RefundSessionRejectionReasonInput.
RefundSessionRejectionReasonInput.code is a
RefundSessionStatusReasonRejectionCode, which is an enum of standardized error codes.
RefundSessionRejectionReasonInput.merchantMessage argument is a localized error message presented to the merchant explaining why the refund was rejected.
If there's a Shopify service disruption, or if a
5xx (Server error responses) HTTP status is being returned, then requests must be retried. Follow the guidelines in the retry policy section.