Subscription Contracts
Subscription contracts represent the ongoing agreement between a customer and a merchant for recurring purchases. Each contract contains all the details needed to fulfill recurring orders, including product lines, billing schedules, delivery information, and payment methods.What is a Subscription Contract?
A subscription contract is created when a customer purchases a product with a selling plan. It tracks the entire subscription lifecycle from creation through cancellation, including:- Product line items and quantities
- Billing and delivery schedules
- Customer information and payment method
- Pricing and discount policies
- Current contract status
Contracts are created automatically by Shopify when a customer completes a purchase with a subscription product.
Contract Lifecycle
Subscription contracts move through different states during their lifetime:Status Types
Status Definitions
Status Definitions
- ACTIVE: Contract is currently active and will generate billing attempts
- PAUSED: Customer has paused their subscription temporarily
- CANCELLED: Contract has been cancelled and will no longer generate orders
- FAILED: Payment failures have caused the contract to fail
- EXPIRED: Contract reached its natural end date
- STALE: Contract hasn’t been billed in an unusually long time
Contract Data Structure
The app uses TypeScript interfaces to represent subscription contract data:Line Items
Each contract contains one or more line items representing the products being subscribed to:Querying Contract Details
The app uses GraphQL to fetch subscription contract information:The
showRevoked: true parameter ensures you can see if a payment method has been revoked, which is important for handling payment failures.Managing Contracts in the App
The reference app provides several ways to manage subscription contracts:Viewing Contract Details
Contract details are accessible through the admin interface at/app/contracts/$id, which displays:
- Current status and next billing date
- Customer information
- Line items with pricing
- Billing and delivery schedules
- Payment method status
- Billing attempt history
Contract Operations
- Pause Contract
- Cancel Contract
- Edit Contract
Customers can pause their subscription temporarily. The contract status changes to
PAUSED and no billing attempts are made until the contract is resumed.Payment Methods
Contracts track the customer’s payment method for automatic billing:Delivery Methods
Contracts support multiple delivery methods:Best Practices
- Monitor Contract Status: Regularly check contract status to identify issues like failed payments or expired payment methods
- Handle Terminal States: Contracts in
CANCELLEDorEXPIREDstatus are in terminal states and should be handled appropriately - Track Billing Attempts: Monitor the
billingAttemptsarray to understand payment history and identify problematic contracts - Validate Payment Methods: Check for expiring cards using the
expiresSoonflag to proactively reach out to customers
Related Resources
- Billing Cycles - Learn how billing attempts are scheduled
- Dunning Management - Understand how failed payments are handled
- Selling Plans - Learn about the plans that create contracts