--- title: Build a credit card payments extension with a checkout UI extension description: Learn how to build a Shopify credit card payments extension with a checkout UI extension source_url: html: https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility md: https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility.md --- ExpandOn this page * [What you'll learn](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#what-youll-learn) * [Requirements](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#requirements) * [Step 1: Scaffold an app](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-1-scaffold-an-app) * [Step 2: Create a checkout UI extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-2-create-a-checkout-ui-extension) * [Step 3: Create a payments extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-3-create-a-payments-extension) * [Step 4: Configure your payments app extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-4-configure-your-payments-app-extension) * [Step 5: Deploy your extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-5-deploy-your-extension) * [Step 6: Preview payment extensions on a development store](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-6-preview-payment-extensions-on-a-development-store) * [Explore the payment processing flows](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#explore-the-payment-processing-flows) * [Sample Checkout UI Extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#sample-checkout-ui-extension) * [Known limitations](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#known-limitations) * [Restrictions](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#restrictions) * [Tutorial complete!](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#tutorial-complete) # Build a credit card payments extension with a checkout UI extension Outdated This tutorial uses an outdated API version for building Checkout UI extensions. We recommend using `2025-10` to make use of new [Polaris web components](https://shopify.dev/docs/beta/next-gen-dev-platform/polaris). Beta UI extensibility for payments extensions is currently in invite-only beta, and Shopify will need to enable the beta for your extension. Checkout UI extensions enable Partners to define additional fields required for processing credit cards with a payments extension. Partners can then collect all essential information upfront, such as an installments payment plan, directly on the checkout page before a payment is initiated. This improvement simplifies the checkout process and offers a smoother buyer experience. ![An image of example credit card payment method with a UI extension](https://cdn.shopify.com/shopifycloud/shopify-dev/production/assets/assets/images/apps/payments/extensible-credit-card/extensible-credit-card-payment-method-app-zE9EmyFG.png) *** ## What you'll learn Note This document builds upon the [credit card payments extension tutorial](https://shopify.dev/docs/apps/build/payments/credit-card/use-the-cli), which you may refer to as needed for additional guidance. In this tutorial, you'll learn how to do the following tasks: * Create a checkout UI extension * Create a credit card payments extension with extensibility * Explore the payment, refund, void, reject and capture session flows, and how to implement them yourself *** ## Requirements * Install [Shopify CLI](https://shopify.dev/docs/api/shopify-cli) * Create a [Shopify Partner account](https://www.shopify.com/partners) and apply to [become a payments partner](https://shopify.dev/docs/apps/build/payments/payments-extension-review#payments-partner-application-review) * Create a [development store](https://shopify.dev/docs/api/development-stores) * Create an [encryption certificate](https://shopify.dev/docs/apps/build/payments/credit-card/manage-encryption-certificates) *** ## Step 1: Scaffold an app To build an extensible credit card payments extension, you will need to create a new credit card app or use an existing credit card app with extensibility features turned on by Shopify. If you opt to create a new app, begin by using the [Shopify CLI](https://shopify.dev/docs/apps/build/scaffold-app) to set up your app. As a first step, we recommend deploying a skeleton app to establish a base for customization. *** ## Step 2: Create a checkout UI extension Caution Your checkout UI extension should not request scopes that enable network access. For more details on the restrictions applicable to access scopes, please refer to the [restrictions](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#restrictions) section. After creating your app, generate a checkout UI extension and deploy your app to Shopify. This extension will be used to collect additional information that's required to process a payment. 1. Use the Shopify CLI to [scaffold](https://shopify.dev/docs/api/checkout-ui-extensions#scaffolding-extension) a checkout UI extension for your app. 2. Name your extension and choose to work in TypeScript React. Note A sample extension, written in Typescript React, is shown below in the [Sample Checkout UI Extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#sample-checkout-ui-extension) section. Please make sure to use the extension target and APIs as shown in the example. 3. After you generate the extension, [deploy](https://shopify.dev/docs/api/shopify-cli/app/app-deploy) your app to [Shopify Partners](https://www.shopify.com/partners). This will allow you to link the checkout UI extension with your payments app extension in the next section. 4. Navigate to your app in Shopify Partners (Apps > Your App). *** ## Step 3: Create a payments extension Your Shopify app becomes a payments app after you've created and configured your payments extension. 1. Run the following command to start generating your payments extension: ## Terminal ```terminal npm shopify app generate extension ``` ```terminal yarn shopify app generate extension ``` ```terminal pnpm shopify app generate extension ``` 2. When prompted, choose your organization and create a new app. 3. When prompted for **Type of extension**, select **Payments App Extension > Credit Card** and name your extension. *** ## Step 4: Configure your payments app extension Configuration of an extensible credit card payments app extension is similar to a [Credit Card payments app extension](https://shopify.dev/docs/apps/build/payments/credit-card/use-the-cli). Your payments app extension configures the following fields: | Field | Description | | - | - | | `payment_session_url` required | The URL that receives payment and order details from the checkout. | | `refund_session_url` required | The URL that refund session requests are sent to. | | `capture_session_url` required | The URL that capture session requests are sent to. This is only used if your payments app supports merchant manual capture. | | `void_session_url` required | The URL that void session requests are sent to. This is only used if your payments app supports merchant manual capture or void payments. | | `confirmation_callback_url` optional | The URL that confirm session requests are sent to. This URL is required if your payments app supports 3-D Secure authentication. | | `supported_countries` required | The countries where your payments app is available. Includes list of [ISO 3166 (alpha-2) country codes](https://www.iso.org/iso-3166-country-codes.html) where your app is available for merchants to install. | | `supports_moto` required | Enables Mail Order/Telephone Order (MOTO), allowing merchants to manually process transactions using a customer's credit card information. The `moto` attribute in payment method data is only available in API version 2024-07 and later. | | `supports_3ds` required | 3-D Secure support is mandated in some instances. For example, you must enable the 3-D Secure field if you plan to support payments in countries which have mandated 3-D Secure. | | `supported_payment_methods` required | The [payment methods](https://github.com/activemerchant/payment_icons/blob/master/db/payment_icons.yml) (for example, Visa) that are available with your payments app. | | `supports_installments` required | Enables installments | | `supports_deferred_payments` required | Enables deferred payments | | `merchant_label` required | The name for your payment provider extension. This name is displayed to merchants in the Shopify admin when they search for payment methods to add to their store. Limited to 50 characters. | | `test_mode_available` required | Enables merchants using your payments app to test their setup by simulating transactions. To test your app on a development store, your payment provider in the Shopify admin must be set to test mode. | | `api_version` required | The Payments Apps GraphQL API version used by the payment provider app to receive requests from Shopify. You must use the same API version for sending GraphQL requests. You can't use the unstable version of the API in production. API versions are updated in accordance with Shopify's general API versioning timelines. | | `multiple_capture` optional, closed beta | Enables merchants using your payment provider app to partially capture an authorized payment multiple times up to the full authorization amount. This is used only if your payments app supports merchant manual capture. | | `encryption_certificate_fingerprint` required | The certificate that Shopify uses to generate the ephemeral key and encrypt the credit card information of the customer. Refer to [manage encryption certificates](https://shopify.dev/docs/apps/build/payments/credit-card/manage-encryption-certificates) section to learn more. | | `ui_extension_handle` required | The UI extension that will be used to render your payments app in checkout. This value can only be a UI extension linked to this specific payments app. | | `checkout_payment_method_fields` required | The fields your payments app will accept from buyers in checkout (for example, installment details, payment plan). Each field is composed of a key name, as well as the data type, that restricts the input the buyer can provider. | Note The `UI Extension` and `UI Extension Field Definitions` attributes are new app extension configurations. You'll want to select the UI extension you created in **Create a Checkout UI Extension** as the value for the UI Extension field. The UI extension generated in [Create a checkout UI extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-2-create-a-checkout-ui-extension) will determine what fields, validation, and form submission behavior is presented to buyers during checkout. ### UI Extension This is where you link the checkout extension you previously built with your new payment app extension to tie them together. | Property name | Description | | - | - | | `ui_extension_handle` required | The UI extension that will be used to render your payments app in checkout. This value can only be a UI extension linked to this specific payments app. | ### UI Extension Field Definitions Specify the fields your UI extensions should collect to ensure the payment method validates and receives the correct data from the front end. | Property name | Description | | - | - | | `checkout_payment_method_fields` required | The fields your payments app will accept from buyers in checkout (for example, installment details, payment plan). Each field is composed of a key name, as well as the data type, that restricts the input the buyer can provider. | ```text [[extensions.checkout_payment_method_fields]] key = "bank_name" type = "string" required = true [[extensions.checkout_payment_method_fields]] key = "account_number" type = "string" required = false ``` *** ## Step 5: Deploy your extension Create and release an app version with the `deploy` command. 1. Navigate to your app directory. 2. Run the following command: ## Terminal ```terminal shopify app deploy ``` An app version created using Shopify CLI contains the following: * The app configuration from the local [configuration file](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration). If the `include_config_on_deploy` [flag](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration#build) is not set or `false`, the configuration from the active app version will be used instead. * The local version of the app's CLI-managed extensions. If you have an extension in your deployed app, but the extension code doesn't exist locally, then the extension isn't included in your app version. Releasing an app version replaces the current active version that's served to stores with your app installed. It might take several minutes for app users to be upgraded to the new version. Tip If you want to create a version, but want to avoid releasing it to users, then run the `deploy` command with a `--no-release` flag. *** ## Step 6: Preview payment extensions on a development store Once this version has been released, follow these steps to install your app on your development store: 1. From the app splash page, enter an account name. 2. Select **Ready** > **Unstable** and click **Submit**. 3. In the banner, click **Return to Shopify**. 4. Enable test mode. 5. Click **Activate**. 6. You can select `Resolve` to complete the payment, or `Reject` to cancel and go back. *** ## Explore the payment processing flows The payments app functions similarly to the credit card payment method, allowing you to gather additional information from the buyer at the outset to facilitate payment processing. The primary distinction is that checkout UI extension data is included in the `start_payment_session` body. Outlined below is a comprehensive diagram depicting the potential flow for processing an extensible credit card payment. It's important to note that the pending state is optional; you can directly proceed to either resolve or reject the payment if there is no need to place it in a pending state. For further details on processing credit card payments, please refer to this [resource](https://shopify.dev/docs/apps/build/payments/credit-card/use-the-cli). ![An image of credit card payment flow](https://cdn.shopify.com/shopifycloud/shopify-dev/production/assets/assets/images/apps/payments/credit-card-payment-method-payment-flow-BZQzuiX3.png) Once we start the payment session with your payments app, that initiation will also contain the metadata in a shape similar to what was specified within the field definitions. A [sample payment session payload](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#payment-session) of what is to be expected can be seen below. ### Payment session Payments with payments apps are processed asynchronously. When the buyer completes their checkout, a request will be sent from Shopify to the *Payment session URL* defined in [Configure your payments app extension](https://shopify.dev/docs/apps/build/payments/credit-card/with-extensibility#step-4-configure-your-payments-app-extension), with the checkout and payment details. The Payments app should respond with HTTP 2xx to indicate that the payment session was started, and should begin processing the extensible credit card payment at this point. The new metadata we are passing through payment session would be contained within the `payment_method` request parameters under `attributes`: ## Example payment method request parameters ```json "payment_method":{ "type":"credit_card" "data":{ "attributes": [ { "key": "payment_plan", "value": "pay-in-full" } ], }, }, ``` ## Start session ## Request header ```http Shopify-Shop-Domain: my-test-shop.myshopify.com Shopify-Request-Id: 94169f7e-ac8d-4ef4-9fd2-90f0791daddf Shopify-Api-Version: 2025-10 ``` ## Request body ```json { "id": "u0nwmSrNntjIWozmNslK5Tlq", "gid": "gid://shopify/PaymentSession/u0nwmSrNntjIWozmNslK5Tlq", "group": "rZNvy+1jH6Z+BcPqA5U5BSIcnUavBha3C63xBalm+xE=", "session_id": "4B2dxmle3vGgimS4deUX3+2PgLF2+/0ZWnNsNSZcgdU=", "amount": "123.00", "currency": "CAD", "test": false, "merchant_locale": "en", "payment_method": { "type": "credit_card", "data": { "attributes": [ { "key": "payment_plan", "value": "pay-in-full" } ], "fingerprint": "65b1ae1fe49ff9d23d80e4967d9147e64b2357c0b2291f4a8bf719cbde331b4c", "encrypted_message": "", "ephemeral_public_key": "", "tag": "TAG", "moto": true } }, "proposed_at": "2020-07-13T00:00:00Z", "customer": { "billing_address": { "given_name": "Alice", "family_name": "Smith", "line1": "123 Street", "line2": "Suite B", "city": "Montreal", "postal_code": "H2Z 0B3", "province": "Quebec", "country_code": "CA", "phone_number": "5555555555", "company": "" }, "shipping_address": { "given_name": "Alice", "family_name": "Smith", "line1": "123 Street", "line2": "Suite B", "city": "Montreal", "postal_code": "H2Z 0B3", "province": "Quebec", "country_code": "CA", "phone_number": "5555555555", "company": "" }, "email": "buyer@example.com", "phone_number": "5555555555", "locale": "fr" }, "kind": "sale" } ``` ## Response body ```text Our API expects an empty response body. ``` ### Payment session with localized fields For certain countries that require additional fields on orders, `localized_fields` are included in the payload inside the `transaction_metadata` object. In the case of Brazil, `localized_fields` contains the CPF value. As a result of this, payment app developers won't need to manually add a CPF field to the payments app. Note Make sure you're using the `2024-07` version or higher in your payments app extension to access this feature. ## Example transaction metadata for localized fields ```json "transaction_metadata": { "localized_fields": [ { "key": "shipping_credential", "country_code": "BR", "value": "06305371008" } ] }, ``` ## Start session ## Request header ```http Shopify-Shop-Domain: my-test-shop.myshopify.com Shopify-Request-Id: 94169f7e-ac8d-4ef4-9fd2-90f0791daddf Shopify-Api-Version: 2025-10 ``` ## Request body ```json { "id": "u0nwmSrNntjIWozmNslK5Tlq", "gid": "gid://shopify/PaymentSession/u0nwmSrNntjIWozmNslK5Tlq", "group": "rZNvy+1jH6Z+BcPqA5U5BSIcnUavBha3C63xBalm+xE=", "session_id": "4B2dxmle3vGgimS4deUX3+2PgLF2+/0ZWnNsNSZcgdU=", "amount": "123.00", "currency": "CAD", "test": false, "merchant_locale": "en", "payment_method": { "type": "credit_card", "data": { "attributes": [ { "key": "payment_plan", "value": "pay-in-full" } ], "fingerprint": "65b1ae1fe49ff9d23d80e4967d9147e64b2357c0b2291f4a8bf719cbde331b4c", "encrypted_message": "", "ephemeral_public_key": "", "tag": "TAG", "moto": false } }, "proposed_at": "2023-06-23T17:03:36Z", "customer": { "billing_address": { "given_name": "Alice", "family_name": "Smith", "line1": "Praça Visconde de Mauá", "city": "Santos", "postal_code": "11010-000", "province": "São Paulo", "country_code": "BR", "phone_number": "5555555555", "company": "" }, "shipping_address": { "given_name": "Alice", "family_name": "Smith", "line1": "Praça Visconde de Mauá", "city": "Santos", "postal_code": "11010-000", "province": "São Paulo", "country_code": "BR", "phone_number": "5555555555", "company": "" }, "email": "buyer@example.com", "phone_number": "5555555555", "locale": "br" }, "transaction_metadata": { "localized_fields": [ { "key": "shipping_credential", "country_code": "BR", "value": "06305371008" } ] }, "kind": "sale" } ``` ## Response body ```text Our API expects an empty response body. ``` #### Resolve After the payments app has responded to the initial start payment session request, it should begin processing the payment. Since this is an asynchronous process, the payments app will be performing the next step independently, through the [`paymentSessionResolve`](https://shopify.dev/docs/api/payments-apps/latest/mutations/paymentSessionResolve) mutation on the [Payments Apps GraphQL API](https://shopify.dev/docs/api/payments-apps). This mutation will resolve the payment session, indicating that the payment was successful. ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation PaymentSessionResolve($id: ID!) { paymentSessionResolve(id: $id) { paymentSession { id state { ... on PaymentSessionStateResolved { code } } } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/PaymentSession/reItEndH7tKB4sGkjronhdEgv" } ``` ## JSON response ```json { "data": { "paymentSessionResolve": { "paymentSession": { "id": "gid://shopify/PaymentSession/reItEndH7tKB4sGkjronhdEgv", "state": { "code": "RESOLVED" } }, "userErrors": [] } } } ``` After this, the payment will be marked as resolved in Shopify. #### Reject If a payment was unsuccessful for any reason, then payments app must use the [`paymentSessionReject`](https://shopify.dev/docs/api/payments-apps/latest/mutations/paymentSessionReject) mutation. ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation PaymentSessionReject( $id: ID!, $reason: PaymentSessionRejectionReasonInput! ) { paymentSessionReject( id: $id, reason: $reason ) { paymentSession { id state { ... on PaymentSessionStateRejected { code reason merchantMessage } } } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/PaymentSession/reItEndH7tKB4sGkjronhdEgv", "reason": { "code": "PROCESSING_ERROR", "merchantMessage": "the payment didn't work" } } ``` ## JSON response ```json { "data": { "paymentSessionReject": { "paymentSession": { "id": "gid://shopify/PaymentSession/reItEndH7tKB4sGkjronhdEgv", "state": { "code": "REJECTED", "reason": "PROCESSING_ERROR", "merchantMessage": "the payment didn't work" } }, "userErrors": [] } } } ``` #### Error This section describes the [reasons](https://shopify.dev/docs/api/payments-apps/latest/enums/PaymentSessionStateRejectedReason) you can use to reject a payment session. ### Refund Session The refund flow begins with an HTTP `POST` request sent from Shopify to the payments app's refund session URL. Shopify must receive an HTTP `201` (Created) response for the refund session creation to be successful. For more information about refund sessions and how to reject or resolve refund sessions, refer to [Explore refund sessions](https://shopify.dev/docs/apps/payments/credit-card/build-credit-card-app?framework=remix#explore-refund-sessions). Example request body: ## Example request body ```json "request_params": { "id": "reItEndH7tKB4sGkjronhdEgv", "gid": "gid://shopify/RefundSession/reItEndH7tKB4sGkjronhdEgv", "payment_id": "reItEndH7tKB4sGkjronhdEgv", "amount": "39.90", "currency": "CAD", "merchant_locale": "en", "proposed_at": "2024-04-22T17:10:03Z", "test": true } ``` #### Resolve After the app has successfully processed the refund request, it's resolved by using the `refundSessionResolve` mutation. The `id` argument corresponds to the `gid` of the refund. Example GraphQL mutation: ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation refundSessionResolve($id: ID!) { refundSessionResolve(id: $id) { refundSession { # RefundSession fields } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/RefundSession/rh60PS44WpmEgki4D6IK1Mu63" } ``` ## JSON response ```json { "data": { "refundSessionResolve": { "refundSession": { "id": "gid://shopify/RefundSession/reItEndH7tKB4sGkjronhdEgv", "state": { "code": "RESOLVED" } }, "userErrors": [] } } } ``` After this, the refund will be marked as resolved in Shopify. #### Reject If the app can't process a refund, then it needs to reject it. You should only reject a refund in the case of final and irrecoverable errors. Otherwise, you can attempt to process the refund again. The refund is rejected using the [`refundSessionReject`](https://shopify.dev/docs/api/payments-apps/latest/mutations/refundSessionReject) mutation. As part of the rejection, a reason why the refund was rejected must be included as part of `RefundSessionRejectionReasonInput`. ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation refundSessionReject( $id: ID!, $reason: RefundSessionRejectionReasonInput! ) { refundSessionReject( id: $id, reason: $reason ) { refundSession { # RefundSession fields } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/RefundSession/reItEndH7tKB4sGkjronhdEgv", "reason": { "code": "PROCESSING_ERROR", "merchantMessage": "the payment didn't work" } } ``` ## JSON response ```json { "data": { "refundSessionReject": { "refundSession": { "id": "gid://shopify/RefundSession/reItEndH7tKB4sGkjronhdEgv", "state": { "code": "REJECTED", "reason": "PROCESSING_ERROR", "merchantMessage": "the refund didn't work" } }, "userErrors": [] } } } ``` ### Capture Session A capture can only be performed when the payment initiated by Shopify has a `kind` property with a value of `authorization`. With an `authorization`, the app places a hold on funds and then replies to Shopify's capture request. The capture flow begins with an HTTP POST request sent from Shopify to the payments app's capture session URL. You can read more about capture sessions and how to reject or resolve capture sessions [here](https://shopify.dev/docs/apps/payments/credit-card/build-credit-card-app?framework=remix#explore-capture-sessions). Example request body: ## Example request body ```json "request_params": { "id": "reItEndH7tKB4sGkjronhdEgv", "gid": "gid://shopify/CaptureSession/reItEndH7tKB4sGkjronhdEgv", "payment_id": "reItEndH7tKB4sGkjronhdEgv", "amount": "39.90", "currency": "CAD", "merchant_locale": "en", "proposed_at": "2024-04-22T17:10:03Z", "test": true } ``` #### Resolve After the app has successfully processed the capture request from Shopify, it's resolved using the [`captureSessionResolve`](https://shopify.dev/docs/api/payments-apps/latest/mutations/captureSessionResolve) mutation on the [Payments Apps GraphQL API](https://shopify.dev/docs/api/payments-apps). Example GraphQL mutation: ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation captureSessionResolve($id: ID!) { captureSessionResolve(id: $id) { captureSession { # CaptureSession fields } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/CaptureSession/rh60PS44WpmEgki4D6IK1Mu63" } ``` ## JSON response ```json { "data": { "captureSessionResolve": { "captureSession": { "id": "gid://shopify/CaptureSession/rh60PS44WpmEgki4D6IK1Mu63", "state": { "code": "RESOLVED" } }, "userErrors": [] } } } ``` After this, the capture will be marked as resolved in Shopify. #### Reject If you don't want to process a capture request, then you should reject it. You might want to reject a capture if authorization has expired or if you suspect that the request is fraudulent or high risk. You should only reject a capture in the case of final and irrecoverable errors. Otherwise, you should re-attempt to resolve the capture. The app rejects a capture using the [`captureSessionReject`](https://shopify.dev/docs/api/payments-apps/latest/mutations/captureSessionReject) mutation. As part of the rejection, you need to include a reason why the capture was rejected as part of `CaptureSessionRejectionReasonInput`. Example GraphQL mutation: ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation captureSessionReject( $id: ID!, $reason: CaptureSessionRejectionReasonInput! ) { captureSessionReject( id: $id, reason: $reason ) { captureSession { # CaptureSession fields } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/CaptureSession/reItEndH7tKB4sGkjronhdEgv", "reason": { "code": "AUTHORIZATION_EXPIRED", "merchantMessage": "the authorization didn't work" } } ``` ## JSON response ```json { "data": { "captureSessionReject": { "captureSession": { "id": "gid://shopify/CaptureSession/reItEndH7tKB4sGkjronhdEgv", "state": { "code": "REJECTED", "reason": "AUTHORIZATION_EXPIRED", "merchantMessage": "the authorization didn't work" } }, "userErrors": [] } } } ``` ### Void Session A void can only be performed when the payment initiated by Shopify has a `kind` property with a value of `authorization`. The void flow begins with an HTTP `POST` request sent from Shopify to the payments app's void session URL. You can read more about void sessions and how to reject or resolve void sessions [here](https://shopify.dev/docs/apps/payments/credit-card/build-credit-card-app?framework=remix#explore-void-sessions). Example request body: ## Example request body ```json "request_params": { "id": "reItEndH7tKB4sGkjronhdEgv", "gid": "gid://shopify/VoidSession/reItEndH7tKB4sGkjronhdEgv", "payment_id": "reItEndH7tKB4sGkjronhdEgv", "amount": "39.90", "currency": "CAD", "merchant_locale": "en", "proposed_at": "2024-04-22T17:10:03Z", "test": true } ``` #### Resolve After the app has successfully processed the void request, it is resolved using the [voidSessionResolve](https://shopify.dev/docs/api/payments-apps/2023-07/mutations/voidSessionResolve) mutation on the [Payments Apps GraphQL API](https://shopify.dev/docs/api/payments-apps). Example GraphQL mutation: ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation voidSessionResolve($id: ID!) { voidSessionResolve(id: $id) { voidSession { # VoidSession fields } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/VoidSession/rh60PS44WpmEgki4D6IK1Mu63" } ``` ## JSON response ```json { "data": { "voidSessionResolve": { "voidSession": { "id": "gid://shopify/VoidSession/rh60PS44WpmEgki4D6IK1Mu63", "state": { "code": "RESOLVED" } }, "userErrors": [] } } } ``` After this, the void will be marked as resolved in Shopify. #### Reject If your app can't process a void request, then you should reject it. You should only reject a void in the case of final and irrecoverable errors. Otherwise, you can attempt to resolve the void again. You can reject a void using the [voidSessionReject](https://shopify.dev/docs/api/payments-apps/2023-07/mutations/voidSessionReject) mutation. As part of the rejection, you need to include a reason why the void was rejected as part of `VoidSessionRejectionReasonInput`. Example GraphQL mutation: ## POST https\://{shop}.myshopify.com/payments\_apps/api/unstable/graphql.json ## Mutation ```graphql mutation voidSessionReject( $id: ID!, $reason: VoidSessionRejectionReasonInput! ) { voidSessionReject( id: $id, reason: $reason ) { voidSession { # VoidSession fields } userErrors { field message } } } ``` ## Input variables ```json { "id": "gid://shopify/VoidSession/reItEndH7tKB4sGkjronhdEgv", "reason": { "code": "PROCESSING_ERROR", "merchantMessage": "the void didn't work" } } ``` ## JSON response ```json { "data": { "voidSessionReject": { "voidSession": { "id": "gid://shopify/VoidSession/reItEndH7tKB4sGkjronhdEgv", "state": { "code": "REJECTED", "reason": "PROCESSING_ERROR", "merchantMessage": "the void didn't work" } }, "userErrors": [] } } } ``` *** ## Sample Checkout UI Extension Note Make sure you're using the `2024-04` version or higher of `checkout-ui-extensions-react` in your `package.json` that contains the `useApplyPaymentMethodAttributesChange` and `PaymentMethodAttributesUpdateChange` types. Regenerate your lockfile with these versions, or manually upgrade `@shopify/ui-extensions*` using yarn/npm. This sample code shows what checkout UI extension could look like for a credit card payments app. This code would go in the `Checkout.tsx` file of your checkout UI extension: ## Sample Checkout UI Extension ```ts import { reactExtension, Form, Select, useApplyPaymentMethodAttributesChange, usePaymentMethodAttributeValues, } from '@shopify/ui-extensions-react/checkout'; import {PaymentMethodAttributesUpdateChange} from '@shopify/ui-extensions/checkout'; export default reactExtension( 'purchase.checkout.payment-option-item.hosted-fields.render-after', () => ); const LOG_PREFIX = '[Checkout UI Extension]'; function Extension() { const [paymentPlanValue] = usePaymentMethodAttributeValues(['payment_plan']); const applyPaymentMethodAttributesChange = useApplyPaymentMethodAttributesChange(); function apply({paymentPlan = paymentPlanValue}) { const change = { type: 'updatePaymentMethodAttributes', attributes: [{key: 'payment_plan', value: paymentPlan}], } as PaymentMethodAttributesUpdateChange; applyPaymentMethodAttributesChange(change) .then((result) => { console.log(`${LOG_PREFIX} Applied change`, change, result); }) .catch((error) => { console.error(`${LOG_PREFIX} Failed to apply`, change, error); } ); } return (
{}}>