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.
RequirementsAnchor link to section titled "Requirements"
This tutorial assumes that you've already completed the preceding tutorial to migrate customer information.
What you'll learnAnchor link to section titled "What you'll learn"
In this tutorial, you'll learn how to do the following tasks:
- Import subscription contracts
- Create billing attempts
Step 1: Import subscription contractsAnchor link to section titled "Step 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.
Importing subscription contracts includes the following steps:
- Use the
SubscriptionContractCreatemutation to create a Subscription Draft.
- After the draft is created, you need to add
linesto the subscription that represent the variants that are included in the subscription.
- After you add
lines, perform a mutation to commit the draft, which turns the draft into a live contract.
The following example creates a subscription contract including the customer imported earlier and the payment method from the preceding step:
Now that the subscription draft has been created, you need add
lines to the draft, to tell the subscription which line items should be included in the contract:
To convert the subscription draft into a subscription contract that you can bill against, you need to commit the draft. The following mutation commits the draft, and returns a live subscription contract that accepts billing attempts:
Step 2: Create billing attemptsAnchor link to section titled "Step 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
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:
For more information on creating billing attempts, refer to Create a billing attempt.