Migrating existing subscription contracts to Shopify
Migrating your existing subscriptions to Shopify will allow you to continue charging your existing subscribers without experiencing any disruption in service.
In this tutorial, you’ll learn how to migrate existing subscription contracts to Shopify.
Anchor to RequirementsRequirements
This tutorial assumes that you've already completed the preceding tutorial to migrate customer information.
Anchor to What you'll learnWhat you'll learn
In this tutorial, you'll learn how to do the following tasks:
- Import subscription contracts
- Create billing attempts
Anchor to Step 1: Import subscription contractsStep 1: Import subscription contracts
After you've created or updated Shopify's customer record, you can import the subscription contracts. Subscription contracts include information about the variant, the plan, the payment method, and the billing and shipping addresses.
To import subscription contracts you can use the subscriptionContractAtomicCreate mutation.
The following example creates a subscription contract including the customer that was previously imported, the payment method from the preceding step, and lines:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
Anchor to Step 2: Create billing attemptsStep 2: Create billing attempts
You need to create billing attempts to trigger the billing schedule of a contract. When billing attempts are successful, Shopify creates an order.
The following mutation makes a billing attempt by specifying the required fields subscriptionContractId
and idempotencyKey
(a unique key generated by the client to avoid duplicate payments). In response to a successful mutation, the subscription contract is billed against its current status:
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
For more information on creating billing attempts, refer to Create a billing attempt.
Anchor to Import and bill contracts in bulkImport and bill contracts in bulk
You can also leverage the Bulk Operations API
to perform these operations on large numbers of contracts without incurring any API limit costs.