Test Stripe Subscription Billing
Run this test after changing recurring products, Checkout, webhooks, the customer portal or subscription access.
Give your agent this prompt
Test Stripe subscription billing in the test environment.
Follow https://coremvp.com/en/docs/billing/stripe/subscription/test.md. Complete https://coremvp.com/en/docs/billing/stripe/subscription/configure.md first. Ask me before changing provider settings or secrets; do not use live payments or print secrets.
Remove any conflicting BILLING_DEMO_PROVIDER override from the runner. Finish when ./coremvp e2e billing:subscription passes and both monthly and yearly cases complete in Stripe test Checkout with Stripe subscription state saved.
Report what changed, the check result, and anything you could not run.What the test does
The local test runs monthly and yearly cases; the hosted test runs monthly only. Each case:
- signs up a new buyer;
- subscribes through Stripe-hosted Checkout with Stripe's test card;
- waits for the signed webhook and checks the stored Price through
/api/user/statusand/api/user/subscription, then checks the Active label and Manage Billing button on/dashboard/billing; - opens a real Stripe test-mode customer portal session;
- opens paid content, then checks access is gone after signing out.
Run it locally
Complete Connect Stripe, including the customer portal step. Keep the app and the filtered listener running, with the listener's signing secret in ignored , and map both Pro Prices from the same test account:
PAYMENT_PROVIDER=stripe
NEXT_PUBLIC_STRIPE_MODE=test
NEXT_PUBLIC_STRIPE_PRO_PRICE_ID_MONTHLY=price_replace_me
NEXT_PUBLIC_STRIPE_PRO_PRICE_ID_YEARLY=price_replace_meRemove any conflicting BILLING_DEMO_PROVIDER from the runner environment.
It takes precedence over PAYMENT_PROVIDER in the checkout tests.
From the repository root, run:
./coremvp e2e billing:subscriptionA passing run exits with code 0 after both Stripe monthly and yearly cases.
Check that both used Stripe test Checkout and saved a Stripe subscription. To sell
only one billing period, leave the other Price unmapped; that offer stays
unavailable. Local signup skips the confirmation email; see
Auth testing for that.
Run it against your deployment
The deployed app stays in Stripe test mode; no real charge is made.
-
In your ignored , add the deployment's
NEXT_PUBLIC_SUPABASE_URL, its matchingSUPABASE_SECRET_KEYand its monthly test Price as the following variable. Never print them, and stop if they belong to another Supabase project.NEXT_PUBLIC_STRIPE_PRO_PRICE_ID_MONTHLYPrepare the local runner lists every value.
-
Load and run the test against the exact deployed URL:
set -a; source .env; set +a
export TEST_BASE_URL=https://<app-domain>
export PROD_E2E_AUTH_MODE=signup
./coremvp prod e2e billing:subscriptionThe clip is one passing hosted run on Vercel, at 2.5× speed, with the test account's email hidden.
A passing run prints result production E2E passed and your target URL. For the
required deployment state, see
Deploy and Test Your App.
If the test fails
| Symptom | Check |
|---|---|
| Checkout cannot start | Confirm NEXT_PUBLIC_STRIPE_MODE=test and the recurring Price inputs, then restart the app. |
| Checkout asks for sign-in | Sign in first; recurring Checkout is not a guest checkout path. |
| Webhook requests return 400 | Copy the active listener signing secret into ignored , then restart bun run dev. |
| Local catalog is empty | Confirm the filtered listener was running before the fixture created products and prices. |
| Portal cannot open | Confirm authentication and an owned Stripe management target in account status. |
| Success page appears but access is missing | Check webhook delivery for the actual purchase first. |
For Stripe products or catalog sync, return to Configure Stripe Subscription Billing.
Check later subscription states
The test covers the first active subscription. Check renewals, failed payments and cancellations by hand in Stripe test mode, with the app and listener running. Find the test buyer's customer and subscription first:
stripe customers list --email <buyer-email> --limit 1
stripe subscriptions list --customer <customer-id> --limit 1Run the commands for one state, then reload /dashboard/billing.
| State | Expect on /dashboard/billing |
|---|---|
| Renewal succeeds | The period moves forward and access stays. |
| Payment enters retries | Check the status after the webhook arrives; access follows the stored status. |
| Customer schedules cancellation | The period end shows, and access stays until then. |
| Subscription ends | The status is final and access is removed if the buyer has no other eligible subscription or lifetime purchase. |
| Plan changes | The new Price and period show after the webhook arrives. |
Renewal succeeds:
stripe subscriptions update <subscription-id> -d billing_cycle_anchor=now -d proration_behavior=nonePayment enters retries: attach Stripe's failing test card, set the returned payment method on the subscription, then run the renewal command again.
stripe payment_methods attach pm_card_chargeCustomerFail --customer <customer-id>
stripe subscriptions update <subscription-id> -d default_payment_method=<payment-method-id>Customer schedules cancellation: choose Cancel in the customer portal, or run:
stripe subscriptions update <subscription-id> -d cancel_at_period_end=trueSubscription ends:
stripe subscriptions cancel <subscription-id>Plan changes: switch plans in the customer portal, if you turned on plan switching.
For how invoice.paid and invoice.payment_failed affect access, see
Stripe Subscription Lifecycle and Access.
What's next
Stripe Subscription Lifecycle and Access
Configure Stripe Webhooks
Was this page helpful?