Overview
The billing schedule system allows merchants to:- Configure billing to run at specific times
- Set timezone-aware billing windows
- Process billing attempts in batches
- Optimize for payment success rates
Billing schedules are managed per shop and stored in the
BillingSchedule database model.How Billing Schedules Work
Schedule Activation
A billing schedule is created when the app is installed and activated for the shop
BillingSchedule Model
TheBillingSchedule model manages scheduling configuration in app/models/BillingSchedule/BillingSchedule.server.ts:1-42:
Model Fields
The shop domain identifier
Whether billing processing is active for this shop
IANA timezone identifier (e.g.,
America/New_York, Europe/London)Optional hour of day (0-23) for billing processing
Timezone Handling
The app uses IANA timezone identifiers to ensure accurate billing times:Automatic Detection
Shop timezone is queried from Shopify during setup
Daylight Saving Support
IANA timezones automatically handle DST transitions
Global Support
Works with all Shopify-supported timezones worldwide
Consistent Billing
Ensures billing occurs at predictable local times
Batch Processing
Billing schedules are processed in batches to handle large numbers of subscriptions efficiently:app/models/BillingSchedule/paginate.ts processes active schedules in manageable chunks:
- Queries active billing schedules
- Processes in configurable batch sizes
- Executes callback function for each batch
- Handles errors gracefully without stopping the entire process
Billing Policy Configuration
Each subscription contract has a billing policy that defines:Interval Types
The billing frequency unit
DAY- Daily billingWEEK- Weekly billingMONTH- Monthly billingYEAR- Yearly billing
How many intervals between billing attempts (e.g., every 2 weeks)
Example Billing Policies
Billing Cycle Management
The app calculates upcoming billing cycles based on:- Contract billing policy (interval and interval count)
- Current billing schedule status
- Timezone configuration
- Previous billing attempt history
app/routes/app.contracts.$id._index/route.tsx:74-92:
Schedule Activation Flow
Optimizing Billing Times
Consider these factors when configuring billing schedules:Payment Success Rates
Schedule billing during times when customers have sufficient funds
Time Zone Awareness
Align billing with customer’s local time to improve success rates
Processing Capacity
Distribute billing across hours to avoid overwhelming payment processors
Customer Experience
Avoid billing during inconvenient hours (e.g., late night)
Database Schema
TheBillingSchedule table structure:
Managing Schedule Status
Billing schedules can be activated or deactivated:Activating a Schedule
Activating a Schedule
When activated, the shop’s subscriptions will be processed according to the configured timezone and hour.
Deactivating a Schedule
Deactivating a Schedule
Deactivating prevents automatic billing processing without deleting the schedule configuration.
Best Practices
Related Features
- Payment Retries - Handle failed billing attempts
- Contract Management - Manage subscription lifecycles
- Background Jobs - Process billing schedules asynchronously