---
title: Use store credit with subscriptions
description: >-
  Learn how to allow store credit on selling plans and subscription contracts,
  and how subscription renewals use a customer's store credit.
source_url:
  html: >-
    https://shopify.dev/docs/apps/build/purchase-options/subscriptions/store-credit
  md: >-
    https://shopify.dev/docs/apps/build/purchase-options/subscriptions/store-credit.md
api_name: admin
---

# Use store credit with subscriptions

Store credit is a balance that a customer holds with a merchant's store and can spend on orders. When a subscription contract allows store credit, a renewal can use the customer's store credit first, and the customer's saved payment method pays the rest. Whether a renewal uses store credit depends on [other conditions](#how-a-renewal-uses-store-credit), such as the customer's balance. Your app can read the setting and turn it on or off with the GraphQL Admin API, and a customer portal can read the setting with the Customer Account API.

This guide shows you how to allow store credit on a selling plan, how to set, verify, and turn off store credit on a contract, and how to read the setting in a customer portal.

**Availability:**

The store credit fields in this guide are available in GraphQL Admin API version `2027-01` and later. The Customer Account API field in [Step 4](#step-4-read-store-credit-in-a-customer-portal) is available in Customer Account API version `2027-01` and later.

***

## How store credit works with subscriptions

Store credit uses two settings. Both settings use the field name `allowStoreCredit`, and both default to `false`.

* The selling plan setting is [`SellingPlanRecurringBillingPolicy.paymentConfiguration.allowStoreCredit`](https://shopify.dev/docs/api/admin-graphql/2027-01/objects/SellingPlanRecurringBillingPolicy). It controls whether subscriptions on the plan can use store credit.
* The contract setting is [`SubscriptionContract.paymentConfiguration.allowStoreCredit`](https://shopify.dev/docs/api/admin-graphql/2027-01/objects/SubscriptionContract). It controls whether renewals of the contract can use store credit. Your app can change it on an existing contract.

Each contract keeps its own setting. If you change a selling plan, then the contracts that already exist keep their setting.

### Selling plan rule

Shopify checks the selling plan of each line only when a request sends `allowStoreCredit: true`:

* The request fails when the contract has no lines.
* The request fails when the selling plan of any line has store credit off. A selling plan with no recurring billing policy, such as a fixed plan, counts as off. Shopify reads the current setting of the plan.
* A line with no selling plan passes. So does a line whose selling plan was deleted after the line was added to the contract.
* A request that sends `false`, or that doesn't send `allowStoreCredit`, never fails the rule, even if a selling plan stopped allowing store credit after you created the contract.

### How a renewal uses store credit

When your app creates a billing attempt for a contract that allows store credit, Shopify applies the customer's store credit to the order first. The contract's saved payment method, which is the backup payment method, pays the remaining amount. You don't need to change how your app creates billing attempts.

The backup payment method must be one of the following:

* A card that's vaulted in Shopify, including cards that customers use through Apple Pay and Google Pay.
* PayPal.
* Shop Pay.

For any other payment method, the renewal doesn't use store credit.

A renewal also doesn't use store credit in any of the following cases:

* The contract has `allowStoreCredit: false`.
* The contract has a gift card line.
* The contract has a line on a fixed selling plan, such as a deferred purchase option.
* The customer has no store credit account in the contract's currency.
* The customer's store credit balance is zero.
* The merchant has turned off store credit for the store.

In these cases, the renewal continues as usual, and the backup payment method pays the full amount.

Shop Pay Commerce Component creates contracts with `allowStoreCredit: false`, so those contracts don't use store credit.

### Billing cycle edits

A billing cycle that has a contract edit has its own store credit setting, on the cycle's edited contract. A renewal of that cycle uses store credit only when both the edited contract and the contract allow it. A cycle that has only a schedule edit, such as a skip, has no edited contract, and its renewal uses the contract's setting. To learn how each kind of edit sets the value, refer to [Store credit on edited cycles](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/billing-cycles#store-credit-on-edited-cycles).

***

## Requirements

**Note:**

* Most subscriptions, pre-order and try before you buy apps need to request API access in the [Dev Dashboard](https://dev.shopify.com/dashboard/), under your app's **Settings** > **Access requests**. We give API access to apps that are designed according to our [principles for subscriptions, pre-order and TBYB apps](https://shopify.dev/docs/apps/build/purchase-options#shopifys-principles).
* Public apps that use subscriptions, pre-order or TBYB need to meet [specific requirements](https://shopify.dev/docs/apps/launch/shopify-app-store/app-store-requirements#purchase-option) to be published on the Shopify App Store.
* Custom apps [created in the Shopify admin](https://shopify.dev/docs/apps/build/authentication-authorization/legacy/admin-custom-apps) can't use subscriptions, pre-order or TBYB because these apps can't use extensions or request access to protected scopes. If you're building a solution for a single store, then [create your custom app in the Dev Dashboard](https://shopify.dev/docs/apps/build/dev-dashboard/create-apps-using-dev-dashboard).

- Your app can make [authenticated requests](https://shopify.dev/docs/api/admin-graphql#authentication) to the GraphQL Admin API.
- Your app has the `write_products`, `read_customer_payment_methods`, `read_own_subscription_contracts`, and `write_own_subscription_contracts` [access scopes](https://shopify.dev/docs/api/usage/access-scopes#authenticated-access-scopes). Learn how to [configure your access scopes using Shopify CLI](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration).
- You've created [products](https://shopify.dev/docs/api/admin-graphql/latest/mutations/productcreate) and [product variants](https://shopify.dev/docs/api/admin-graphql/latest/mutations/productVariantsBulkCreate) in your development store.
- To be eligible to use Shopify subscriptions, users need to meet the [qualifying criteria](https://help.shopify.com/en/manual/products/subscriptions/setup#eligibility-requirements).

* Use GraphQL Admin API version `2027-01` or later.
* Familiarize yourself with [selling plans](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) and [subscription contracts](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts).
* Create a [selling plan group](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans/build-a-selling-plan) that has at least one recurring selling plan.

***

## Step 1: Allow store credit on a selling plan

Set `paymentConfiguration.allowStoreCredit` to `true` on the recurring billing policy of a selling plan, so that contracts on the plan can allow store credit. A selling plan doesn't allow store credit until you set this field. You can set it when you create a plan in `sellingPlansToCreate`, or when you change a plan in `sellingPlansToUpdate`.

The following example allows store credit on an existing selling plan with [`sellingPlanGroupUpdate`](https://shopify.dev/docs/api/admin-graphql/2027-01/mutations/sellingPlanGroupUpdate), and then reads the value back:

## POST https://{shop}.myshopify.com/admin/api/2027-01/graphql.json

## GraphQL mutation

```graphql
mutation AllowStoreCreditOnSellingPlan {
  sellingPlanGroupUpdate(
    id: "gid://shopify/SellingPlanGroup/294969"
    input: {
      sellingPlansToUpdate: [
        {
          id: "gid://shopify/SellingPlan/1001"
          billingPolicy: {
            recurring: {
              paymentConfiguration: { allowStoreCredit: true }
            }
          }
        }
      ]
    }
  ) {
    sellingPlanGroup {
      id
      sellingPlans(first: 10) {
        nodes {
          id
          billingPolicy {
            ... on SellingPlanRecurringBillingPolicy {
              paymentConfiguration {
                allowStoreCredit
              }
            }
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "sellingPlanGroupUpdate": {
      "sellingPlanGroup": {
        "id": "gid://shopify/SellingPlanGroup/294969",
        "sellingPlans": {
          "nodes": [
            {
              "id": "gid://shopify/SellingPlan/1001",
              "billingPolicy": {
                "paymentConfiguration": {
                  "allowStoreCredit": true
                }
              }
            }
          ]
        }
      },
      "userErrors": []
    }
  }
}
```

If you omit `paymentConfiguration` or `allowStoreCredit` in an update, then the plan keeps its current value. Only recurring billing policies have a payment configuration.

***

## Step 2: Set store credit on a contract

Use the `paymentConfiguration` input on the contract calculation mutations to set store credit when you create a contract or update it. To learn how the calculate, poll, and commit flow works, refer to [Build a subscription contract](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/build-a-subscription-contract) and [Update a subscription contract](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/update-a-subscription-contract).

Set `allowStoreCredit` to `true` only after the customer explicitly chooses to apply store credit to future subscription renewals. Keep it `false` by default, [show the current choice in the customer portal](#step-4-read-store-credit-in-a-customer-portal), and [set it to `false`](#turn-store-credit-off) when the customer withdraws permission.

### Create a contract that allows store credit

Add `paymentConfiguration` to the `contractCreateInput` of [`subscriptionContractCreateCalculate`](https://shopify.dev/docs/api/admin-graphql/2027-01/mutations/subscriptionContractCreateCalculate). Store credit is off unless you set `allowStoreCredit` to `true`. If a line has a selling plan, then the line must pass the [selling plan rule](#selling-plan-rule). The following example sets `originSellingPlanId` on the line to a plan that allows store credit:

## POST https://{shop}.myshopify.com/admin/api/2027-01/graphql.json

## GraphQL mutation

```graphql
mutation CreateContractWithStoreCredit {
  subscriptionContractCreateCalculate(
    contractCreateInput: {
      withMerchandiseCustomizations: true
      customerId: "gid://shopify/Customer/123"
      currencyCode: CAD
      lines: [
        {
          productVariantLine: {
            productVariantId: "gid://shopify/ProductVariant/111"
            originSellingPlanId: "gid://shopify/SellingPlan/1001"
            quantity: 1
            customAttributes: []
            discounts: []
          }
        }
      ]
      billingPolicy: {
        anchors: []
        cadence: { unit: MONTH, count: 1 }
      }
      deliveryPolicy: { anchors: [] }
      deliveryMethod: {
        shipping: {
          address: {
            firstName: "Quinn"
            lastName: "Ishida"
            address1: "123 Main St"
            city: "Toronto"
            provinceCode: "ON"
            countryCode: CA
            zip: "M5V 1A1"
          }
          deliveryPrice: {
            amount: "14.99"
            currencyCode: CAD
          }
        }
      }
      paymentMethod: {
        customerPaymentMethod: {
          id: "gid://shopify/CustomerPaymentMethod/456"
        }
      }
      paymentConfiguration: { allowStoreCredit: true }
      discountCodes: []
      manualDiscounts: []
      customAttributes: []
    }
  ) {
    subscriptionContractCalculation {
      ... on SubscriptionContractCalculationPending {
        id
      }
    }
    userErrors {
      field
      message
      code
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "subscriptionContractCreateCalculate": {
      "subscriptionContractCalculation": {
        "id": "gid://shopify/SubscriptionContractCalculation/789"
      },
      "userErrors": []
    }
  }
}
```

### Update store credit on an existing contract

Add `paymentConfiguration` to the `contractUpdateInput` of [`subscriptionContractUpdateCalculate`](https://shopify.dev/docs/api/admin-graphql/2027-01/mutations/subscriptionContractUpdateCalculate). To turn store credit on, set `allowStoreCredit` to `true`. To turn it off, set `allowStoreCredit` to `false`.

The following example turns store credit on and leaves the rest of the contract unchanged:

## POST https://{shop}.myshopify.com/admin/api/2027-01/graphql.json

## GraphQL mutation

```graphql
mutation SetStoreCreditOnContract {
  subscriptionContractUpdateCalculate(
    contractId: "gid://shopify/SubscriptionContract/123"
    contractUpdateInput: {
      withMerchandiseCustomizations: false
      paymentConfiguration: { allowStoreCredit: true }
    }
  ) {
    subscriptionContractCalculation {
      ... on SubscriptionContractCalculationPending {
        id
      }
    }
    userErrors {
      field
      message
      code
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "subscriptionContractUpdateCalculate": {
      "subscriptionContractCalculation": {
        "id": "gid://shopify/SubscriptionContractCalculation/790"
      },
      "userErrors": []
    }
  }
}
```

If you omit `allowStoreCredit`, then the contract keeps its current setting. If you restate `lines` in the same update, then set `originSellingPlanId` on each line that has a selling plan. A line that you restate without it has no selling plan, and the selling plan rule doesn't check that line.

### Turn store credit off

When a customer asks the merchant to stop using their store credit for renewals, update the contract with `allowStoreCredit: false` and commit the calculation. The [selling plan rule](#selling-plan-rule) never rejects `false`. After the commit, renewals charge the backup payment method for the full amount, including renewals of edited cycles. The exception is a cycle that's [combined into another contract](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/combine-subscription-contracts): its renewal follows the store credit setting of the anchor contract.

If the contract has a current or upcoming billing cycle contract edit, then the update fails with the `CONTRACT_HAS_FUTURE_EDITS` error code. Delete the edits first. The deletion also removes the customer's skips and billing date changes: a cycle that the customer skipped is no longer skipped, and a cycle with a new billing date goes back to its original date. Record those edits before you delete them, and reapply them after the update. To learn how, refer to [Update a contract that has billing cycle edits](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/update-a-subscription-contract#update-a-contract-that-has-billing-cycle-edits).

### Use the SubscriptionDraft API

If your app uses the legacy `SubscriptionDraft` API, then set `paymentConfiguration` on `SubscriptionDraftInput`. You can pass this input to [`subscriptionDraftUpdate`](https://shopify.dev/docs/api/admin-graphql/2027-01/mutations/subscriptionDraftUpdate), [`subscriptionContractCreate`](https://shopify.dev/docs/api/admin-graphql/2027-01/mutations/subscriptionContractCreate), and [`subscriptionContractAtomicCreate`](https://shopify.dev/docs/api/admin-graphql/2027-01/mutations/subscriptionContractAtomicCreate). The following example turns store credit on in a draft:

## POST https://{shop}.myshopify.com/admin/api/2027-01/graphql.json

## GraphQL mutation

```graphql
mutation SetStoreCreditOnDraft {
  subscriptionDraftUpdate(
    draftId: "gid://shopify/SubscriptionDraft/456"
    input: { paymentConfiguration: { allowStoreCredit: true } }
  ) {
    draft {
      id
    }
    userErrors {
      field
      message
    }
  }
}
```

Shopify applies the [selling plan rule](#selling-plan-rule) when you commit the draft, not when you stage the setting. If a line fails the rule, then the commit returns an `INVALID` user error, and Shopify doesn't commit the draft. To learn how the draft API differs from the calculation API, including the field of that error for each mutation, refer to [Migrate to the Subscription Contract Calculation API](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/migrate-to-subscription-calculation-api#payment-configuration).

***

## Step 3: Verify the setting

Before you commit a calculation, read `calculatedContract.paymentConfiguration.allowStoreCredit`. It shows the setting that the commit applies: the value that you sent, or the setting that the contract keeps when an update omits `allowStoreCredit`. If a request fails the [selling plan rule](#selling-plan-rule), then the calculation has the type `SubscriptionContractCalculationFailure`, with an `INVALID` error on `calculatedContract.paymentConfiguration.allowStoreCredit`, and you can't commit it. The following query returns the setting, or the error of a failed calculation:

## POST https://{shop}.myshopify.com/admin/api/2027-01/graphql.json

## GraphQL query

```graphql
query ReviewStoreCredit($id: ID!) {
  subscriptionContractCalculation(id: $id) {
    __typename
    ... on SubscriptionContractCalculationSuccess {
      calculatedContract {
        paymentConfiguration {
          allowStoreCredit
        }
      }
    }
    ... on SubscriptionContractCalculationFailure {
      errors {
        code
        message
        field
      }
    }
  }
}
```

## Variables

```json
{
  "id": "gid://shopify/SubscriptionContractCalculation/789"
}
```

## Success response

```json
{
  "data": {
    "subscriptionContractCalculation": {
      "__typename": "SubscriptionContractCalculationSuccess",
      "calculatedContract": {
        "paymentConfiguration": {
          "allowStoreCredit": true
        }
      }
    }
  }
}
```

## Failure response

```json
{
  "data": {
    "subscriptionContractCalculation": {
      "__typename": "SubscriptionContractCalculationFailure",
      "errors": [
        {
          "code": "INVALID",
          "message": "Allow store credit can't be true when the selling plan of a line doesn't allow store credit",
          "field": [
            "calculatedContract",
            "paymentConfiguration",
            "allowStoreCredit"
          ]
        }
      ]
    }
  }
}
```

After the calculation succeeds, [commit the calculation](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/update-a-subscription-contract#step-4-commit-the-calculation). To read the setting of a contract after the commit, query `paymentConfiguration` on the [`SubscriptionContract`](https://shopify.dev/docs/api/admin-graphql/2027-01/objects/SubscriptionContract) object:

```graphql
query GetContractStoreCredit($id: ID!) {
  subscriptionContract(id: $id) {
    id
    paymentConfiguration {
      allowStoreCredit
    }
  }
}
```

***

## Step 4: Read store credit in a customer portal

If your customer portal uses the [Customer Account API](https://shopify.dev/docs/api/customer), then read the setting with `paymentConfiguration` on the [`SubscriptionContract`](https://shopify.dev/docs/api/customer/2027-01/objects/SubscriptionContract) object. The field is available in Customer Account API version `2027-01` and later. The query reads two types, and each type requires its own access scope. Your app needs both of the following [access scopes](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration#access_scopes):

* [`customer_read_customers`](https://shopify.dev/docs/api/usage/access-scopes#customer_read_customers), which the [`SubscriptionContractPaymentConfiguration`](https://shopify.dev/docs/api/customer/2027-01/objects/SubscriptionContractPaymentConfiguration) object requires.
* [`customer_read_own_subscription_contracts`](https://shopify.dev/docs/api/usage/access-scopes#customer_read_own_subscription_contracts) or [`customer_write_own_subscription_contracts`](https://shopify.dev/docs/api/usage/access-scopes#customer_write_own_subscription_contracts), which the `SubscriptionContract` object requires.

## POST https://shopify.com/{shop\_id}/account/customer/api/2027-01/graphql

## GraphQL query

```graphql
query GetSubscriptionStoreCredit($id: ID!) {
  customer {
    subscriptionContract(id: $id) {
      id
      paymentConfiguration {
        allowStoreCredit
      }
    }
  }
}
```

## Variables

```json
{
  "id": "gid://shopify/SubscriptionContract/123"
}
```

## JSON response

```json
{
  "data": {
    "customer": {
      "subscriptionContract": {
        "id": "gid://shopify/SubscriptionContract/123",
        "paymentConfiguration": {
          "allowStoreCredit": true
        }
      }
    }
  }
}
```

A value of `true` means that the contract allows store credit. It doesn't mean that the next renewal uses store credit. For example, if the customer's store credit balance is zero, then the backup payment method pays the full amount. In your portal, show the value as a setting, and not as the payment method of the next renewal. To learn what else a renewal needs, refer to [How a renewal uses store credit](#how-a-renewal-uses-store-credit).

The Customer Account API field is read-only. It returns the stored value of the contract. To change the setting, use the GraphQL Admin API. For example, when a customer asks to stop using store credit, [turn store credit off](#turn-store-credit-off).

***

## Next steps

* Learn how to [build a selling plan](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans/build-a-selling-plan).
* Learn how to [build a subscription contract](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/build-a-subscription-contract) and [update a subscription contract](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/contracts/update-a-subscription-contract).
* Learn how to [create a customer-facing purchase option portal](https://shopify.dev/docs/apps/build/purchase-options/customer-portal/create-customer-portal).
* Refer to the [`SubscriptionContract`](https://shopify.dev/docs/api/admin-graphql/2027-01/objects/SubscriptionContract) object.

***
