BackendSubscriptions
Management Commands
Django commands for syncing Stripe data.
Management commands provide a way to bulk-sync data from Stripe into the local database. Useful for initial setup, disaster recovery, or periodic reconciliation.
pull_stripe
Orchestrates a full sync of all Stripe data:
python manage.py pull_stripeRuns these commands in sequence:
update_stripe_products— Syncs products and pricesupdate_stripe_customers— Syncs customer recordsupdate_stripe_subscriptions— Syncs subscription data
update_stripe_products
Fetches all products and prices from Stripe and updates local records:
python manage.py update_stripe_productsWhat it does:
- Creates/updates
Productrecords (id, name, description, active) - Creates/updates
Pricerecords (id, product, amount, frequency, currency) - Syncs feature mappings from product metadata
update_stripe_customers
Fetches Stripe customers and links them to Django users:
python manage.py update_stripe_customers
python manage.py update_stripe_customers --limit 50
python manage.py update_stripe_customers --starting_after cus_abc123| Option | Default | Description |
|---|---|---|
-l, --limit | 100 | Max customers to fetch (max 100) |
-s, --starting_after | — | Pagination cursor (Stripe customer ID) |
What it does:
- Fetches customers from Stripe
- Creates/links
StripeUserrecords to Django users by email - Optionally creates Django users if
USER_CREATE_DEFAULTS_ATTRIBUTE_MAPis configured
update_stripe_subscriptions
Fetches subscriptions and updates local records:
python manage.py update_stripe_subscriptions
python manage.py update_stripe_subscriptions --limit 50
python manage.py update_stripe_subscriptions --starting_after sub_abc123| Option | Default | Description |
|---|---|---|
-l, --limit | 100 | Max subscriptions to fetch (max 100) |
-s, --starting_after | — | Pagination cursor (Stripe subscription ID) |
What it does:
- Fetches subscriptions from Stripe
- Creates/updates
Subscriptionrecords with all fields - Recreates
SubscriptionItemrecords from subscription line items - Links subscriptions to
StripeUserrecords
When to Use
| Scenario | Command |
|---|---|
| Initial deployment | pull_stripe |
| After restoring database | pull_stripe |
| Verify webhook data integrity | pull_stripe |
| Paginate through large customer lists | update_stripe_customers --limit 100 --starting_after cus_... |
| Debug subscription issues | update_stripe_subscriptions |
Docker Usage
# Local
docker compose -f docker-compose.local.yml run --rm django python manage.py pull_stripe
# Production
docker compose -f docker-compose.production.yml run --rm django python manage.py pull_stripe