Processing a payment

Payment processing begins when Shopify makes an HTTP call to your payments app. Your app responds with a redirect URL that Shopify uses to redirect the customer to your app's payment page. After the payment is finalized, you need to communicate the result to Shopify using either PaymentSessionResolve or PaymentSessionReject.

How the payments app flow works

The following diagram illustrates how a payment flow works between the payments app and Shopify:

payment processing steps

  1. The customer completes checkout, triggering a request for payment.
  2. Shopify sends a backend request to the payments app, specifying the amount and currency to be charged.
  3. The app responds with a redirect URL for a payment page hosted by the partner's app. (200 OK)
  4. Shopify redirects the customer to the redirect URL.
  5. The payments app collects the buyer’s payment credentials and processes the payment as described in the backend request.
  6. The payments app communicates the payment processing result to Shopify, implementing a retry policy as needed.
  7. Shopify replies with the redirect URL. (200 OK)
  8. The app redirects the customer to Shopify. (301 Redirect)
  9. Customer continues checkout.

For payment processing, both upstream and downstream requests must be idempotent with the payment ID used as the idempotency key.

Asynchronous communications

Payment processing relies on asynchronous communications over HTTP between Shopify and the payments app. In an asynchronous system, retry policies are crucial to ensure a robust communication strategy.



To use the GraphQL mutations, your app needs to be aware of access scopes for payments apps.

Initiate the payment flow

The payment flow begins with an HTTP request sent from Shopify to the provider's payment session URL provided during app extension configuration. This request contains information about the customer and the order.

Request Body

Attribute Description Type
idRequired Unique identifier for the payment 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. This ID must be surfaced to the merchant so that they can correlate Shopify orders with payments managed by the partner app. String
gidRequired Identifies the payment when communicating with Shopify (in GraphQL mutations, for example). String
groupRequired A customer might open multiple tabs in their browser for a given order. All of those tabs will be associated with the same group. As a result, Shopify can initiate multiple payment flows for the same id and group, redirecting to your app each time. Your app must only call the PaymentSessionResolve once per id and group. String
amountRequired The amount to be charged. The value is always sent using a decimal point as a separator, regardless of locale. Numeric
cancel_urlRequired The URL to redirect the customer to when the customer quits the payment flow and returns to the merchant's website. The `cancel_url` attribute should only be used when a customer is on the provider page and decides to cancel their payment and return to Shopify. String
proposed_atRequired Can be used to order payment attempts that are a part of the same group. String (ISO-8601)
testRequired Indicates whether the payment is in test or live mode. Refer to Test mode for more information. Boolean
customer If customer is included, then one of or must be present, but not both. The shipping_address and billing_address have line2, province, postal_code and company fields that are optional, depending on the customer's locality. Hash
kindRequired Either sale or authorization. If you support payment authorization, then this value is set based on the merchant's configuration. If you don't support separate authorization and capture, then the value is always `sale`. For sale transactions, you need to capture the funds instantly with this request. For authorization transactions, you must place a hold on the funds and capture them later when Shopify sends a capture request. String

Request headers

Header Description
Shopify-Shop-DomainRequired The permanent domain of the merchant. Can be used to identify which merchant is initiating the payment.
Shopify-Request-IdRequired Unique per request. Can be used to track specific requests for troubleshooting.
Shopify-Api-VersionRequired The API version selected in the payments app configuration. The version selected defines the response payload's format expected by the payments app.


Shopify must receive a HTTP 2xx response for the payment session creation to be successful. If the request fails, then it will be retried a number of times and will eventually transition to an "aborted" state, at which point the buyer will have to retry their payment through Shopify checkout. The response must contain the URL for the partner page where Shopify will redirect the buyer.

If there's an error on the payment apps side, don't respond with a 2xx. Use an appropriate error status code instead.

Example payload:

Resolve a Payment

You must invoke the PaymentSessionResolve mutation after the buyer has successfully gone through the process of paying:

The id argument corresponds to the gid of the payment.


View response

JSON response:

The redirectUrl field is the URL to which the buyer is to be redirected by the partner.

Reject a Payment

A payment should be rejected when the buyer is unable to complete payment with the provider. This signals to Shopify that the checkout process is to be halted.

You can reject a payment using the PaymentSessionReject mutation:


View response

JSON response:

The rejection requires information on why the payment was rejected. This information is encapsulated in the PaymentSessionRejectionReasonInput.

The PaymentSessionRejectionReasonInput.code is a PaymentSessionStatusReasonRejectionCode, which is an enum of of standardized error codes.

The PaymentSessionRejectionReasonInput.merchantMessage argument is a localized error message presented to the merchant explaining why the payment was rejected.

Retry policy

If there's a Shopify service disruption (or if 5xx status codes are being returned), then requests must be retried. It's suggested to follow the guidelines in the retry policy section.

If a GraphQL request acknowledgment is not received, then you need to implement a retry policy. During this time, you can inform the customer that the payment is processed, but Shopify is unreachable. You can let the customer know that they will receive a notification from Shopify when the order is processed. Furthermore, the customer should contact the merchant directly if the maximum number of recommended retries elapses without acknowledgment.

Next action

Upon receiving the response from either the PaymentSessionResolve or PaymentSessionReject mutations, the next action that must be performed by the payments app is specified under nextAction.

The nextAction will either be nil or contain two fields. In the case where it is nil, no next action is expected of the payments app.

Otherwise, the fields are as follows:

  • action: An enum that specifies the type of the action the app must perform.
  • context: Union type requiring inline fragments to access data on the underlying type. Takes a type of PaymentSessionActionsRedirect

Next steps

Additional information