--- title: Billing description: >- Contains function used to bill merchants for your app with the Billing API. This object is returned on authenticated Admin requests. > Note: [Managed App Pricing](/docs/apps/launch/billing/managed-pricing) is now available. Define your app’s pricing plans directly in the Shopify Partner Dashboard, without needing to use the Billing API. api_version: v1 latest api_name: shopify-app-react-router source_url: html: 'https://shopify.dev/docs/api/shopify-app-react-router/latest/apis/billing' md: 'https://shopify.dev/docs/api/shopify-app-react-router/latest/apis/billing.md' --- # Billingobject Contains function used to bill merchants for your app with the Billing API. This object is returned on authenticated Admin requests. Note [Managed App Pricing](https://shopify.dev/docs/apps/launch/billing/managed-pricing) is now available. Define your app’s pricing plans directly in the Shopify Partner Dashboard, without needing to use the Billing API. ## billing Provides utilities that apps can use to request billing for the app using the Admin API. * cancel (options: CancelBillingOptions) => Promise\ required Cancels an ongoing subscription, given its ID. * check \>(options?: Options) => Promise\ required Checks if the shop has an active payment for any plan defined in the `billing` config option. * createUsageRecord (options: CreateUsageRecordOptions) => Promise\ required Creates a usage record for an app subscription. * request (options: RequestBillingOptions\) => Promise\ required Requests payment for the plan. * require (options: RequireBillingOptions\) => Promise\ required Checks if the shop has an active payment for any plan defined in the `billing` config option. * updateUsageCappedAmount (options: UpdateUsageCappedAmountOptions) => Promise\ required Updates the capped amount for a usage billing plan. ### CancelBillingOptions * isTest Whether to use the test mode. This prevents the credit card from being charged. ```ts boolean ``` * prorate Whether to issue prorated credits for the unused portion of the app subscription. There will be a corresponding deduction (based on revenue share) to your Partner account. For example, if a $10.00 app subscription (with 0% revenue share) is cancelled and prorated half way through the billing cycle, then the merchant will be credited $5.00 and that amount will be deducted from your Partner account. ```ts boolean ``` * subscriptionId The ID of the subscription to cancel. ```ts string ``` ```ts export interface CancelBillingOptions { /** * The ID of the subscription to cancel. */ subscriptionId: string; /** * Whether to issue prorated credits for the unused portion of the app subscription. There will be a corresponding * deduction (based on revenue share) to your Partner account. For example, if a $10.00 app subscription * (with 0% revenue share) is cancelled and prorated half way through the billing cycle, then the merchant will be * credited $5.00 and that amount will be deducted from your Partner account. */ prorate?: boolean; /** * Whether to use the test mode. This prevents the credit card from being charged. */ isTest?: boolean; } ``` ### CheckBillingOptions * isTest Whether to include charges that were created on test mode. Test shops and demo shops cannot be charged. ```ts boolean ``` * plans The plans to check for. Must be one of the values defined in the \`billing\` config option. ```ts (keyof Config["billing"])[] ``` ```ts export interface CheckBillingOptions extends Omit { /** * The plans to check for. Must be one of the values defined in the `billing` config option. */ plans?: (keyof Config['billing'])[]; } ``` ### CreateUsageRecordOptions * description The description of the app usage record. ```ts string ``` * idempotencyKey ```ts string ``` * isTest Whether to use the test mode. This prevents the credit card from being charged. ```ts boolean ``` * price The price of the app usage record. ```ts { amount: number; currencyCode: string; } ``` * subscriptionLineItemId ```ts string ``` ```ts export interface CreateUsageRecordOptions { /** * The description of the app usage record. */ description: string; /** * The price of the app usage record. */ price: { /** * The amount to charge for this usage record. */ amount: number; /** * The currency code for this usage record. */ currencyCode: string; }; /** * Whether to use the test mode. This prevents the credit card from being charged. */ isTest: boolean; /* * Defines the usage pricing plan the merchant is subscribed to. */ subscriptionLineItemId?: string; /* * A unique key generated to avoid duplicate charges. */ idempotencyKey?: string; } ``` ### RequestBillingOptions * isTest Whether to use the test mode. This prevents the credit card from being charged. Test shops and demo shops cannot be charged. ```ts boolean ``` * plan The plan to request. Must be one of the values defined in the \`billing\` config option. ```ts keyof Config["billing"] ``` * returnUrl The URL to return to after the merchant approves the payment. ```ts string ``` ```ts export interface RequestBillingOptions extends Omit { /** * The plan to request. Must be one of the values defined in the `billing` config option. */ plan: keyof Config['billing']; /** * Whether to use the test mode. This prevents the credit card from being charged. Test shops and demo shops cannot be charged. */ isTest?: boolean; /** * The URL to return to after the merchant approves the payment. */ returnUrl?: string; } ``` ### RequireBillingOptions * isTest Whether to include charges that were created on test mode. Test shops and demo shops cannot be charged. ```ts boolean ``` * onFailure How to handle the request if the shop doesn't have an active payment for any plan. ```ts (error: any) => Promise ``` * plans The plans to check for. Must be one of the values defined in the \`billing\` config option. ```ts (keyof Config["billing"])[] ``` ```ts export interface RequireBillingOptions extends Omit { /** * The plans to check for. Must be one of the values defined in the `billing` config option. */ plans: (keyof Config['billing'])[]; /** * How to handle the request if the shop doesn't have an active payment for any plan. */ onFailure: (error: any) => Promise; } ``` ### UpdateUsageCappedAmountOptions * cappedAmount The maximum charge for the usage billing plan. ```ts { amount: number; currencyCode: string; } ``` * subscriptionLineItemId The subscription line item ID to update. ```ts string ``` ```ts export interface UpdateUsageCappedAmountOptions { /** * The subscription line item ID to update. */ subscriptionLineItemId: string; /** * The maximum charge for the usage billing plan. */ cappedAmount: { /** * The amount to update. */ amount: number; /** * The currency code to update. */ currencyCode: string; }; } ``` ## Examples ### cancel ### check ### createUsageRecord ### request ### require ### updateUsageCappedAmount ## Related [Authenticate requests from Shopify Admin. - Admin context](https://shopify.dev/docs/api/shopify-app-react-router/authenticate/admin)