Stripe Checkout and Billing Integration
Build Stripe Checkout, subscriptions, metering, and retry-safe webhooks with explicit billing policies and lifecycle tests.
Before & after
Same prompt, same agent — the only difference is the skill.
Stripe subscriptions are well-documented. You'll need to create a subscription, handle the trial period, and then track usage for metering. Do you have a specific framework you're using – Next.js, Express? What does your usage look like – per API call, per user seat? I can point you to the Stripe documentation, but implementing it involves several pieces and the details matter a lot for getting billing right. What are your specific requirements?
STRIPE INTEGRATION: Subscriptions + Trials + Usage-Based Billing
→ CORE COMPONENTS (build in this order)
1. Create customer (idempotent key: customer_id from your DB)
2. Create subscription (trial 14 days, plan ID from config)
3. Meter usage (track daily API calls via /v1/meter_events)
4. Invoice on usage (monthly, calculated from meter events)
5. Webhook handler (idempotent: check event ID before processing)
→ SUBSCRIPTION FLOW CODE SKELETON
const subscription = await stripe.subscriptions.create({
customer: customer_id,
items: [{ price: 'price_standard_monthly' }],
trial_period_days: 14,
trial_settings: { end_behavior: { missing_payment_method: 'cancel' } }
});
Trap: Always include trial_end_behavior (auto-cancel on failed payment, not force-bill)
Trap: Store subscription_id in your DB immediately (webhook may fire before create() returns)
→ USAGE METERING (per-customer API calls)
POST /v1/billing.meter_events
Payload: { event_name: 'api_calls', customer_id: cust_xxx, quantity: 47, timestamp: now }
Schedule: Aggregate daily, send once per day (avoid 1000s of small events)
Idempotence: Use idempotency_key = md5(customer_id + date) (prevents double-counting)
→ WEBHOOK HANDLER (production-critical)
Events to handle:
customer.subscription.trial_will_end (14 days in – remind to update payment method)
invoice.payment_failed (charge failed – mark account, 3-retry window)
charge.dispute.created (customer dispute – alert team immediately)
Trap: Process webhooks exactly once – check DB for event_id before acting
Retry logic: Webhook delivery retry window 24 hours; queue failed webhooks for manual review
→ CUSTOMER PORTAL (self-service)
Redirect from your app: stripe.billingPortal.sessions.create({ customer_id })
Users can: Update payment method, view invoices, download receipts, cancel subscription
Configure: Set cancellation reason categories (allows feedback)
→ DEPLOYMENT CHECKLIST
✓ Webhook signing key validated (stripe.webhooks.constructEvent with secret)
✓ Idempotent customer creation tested (same email on retry = same customer_id)
✓ Trial end edge case: Verify no charge if trial ends without payment method
✓ Usage metering: Backfill test customer with dummy events, verify invoice generated
✓ Live mode: Start with 5 test customers, verify end-to-end before launch
✓ Monitoring: Track webhook latency + failure rate per event type
Go-live: Start with 10% of signups for 1 week, then 100%About this skill
Checkout says payment succeeded, but access never arrives. A retried webhook grants credits twice, or a plan change charges someone before the upgrade works. This skill builds Stripe integrations around durable processing, explicit billing policies, and tests that expose those failures before launch.
What it does
- Selects Checkout, PaymentIntents, Subscriptions, Billing Meters, the customer portal, or invoicing for the actual payment flow.
- Designs signature verification, durable webhook intake, transactional deduplication, and recovery from delayed or reordered events.
- Defines trial, failed-payment, cancellation, and entitlement behavior separately from Stripe subscription status.
- Makes plan changes explicit about proration, collection timing, payment failure, and when upgraded access begins.
- Checks usage reporting for stable event identifiers, correct customer mapping, and invoice reconciliation.
- Plans provider migrations with renewal ownership and reconciliation to prevent duplicate billing.
What you get
Implementation code or a focused patch suited to your stack, with the required data constraints, billing decisions, and targeted lifecycle tests. Reviews return concrete failure paths and fixes; small debugging questions get a small answer.
Best for
Developers building or repairing Stripe billing in SaaS products, paid applications, marketplaces with straightforward payment flows, and usage-based services.
SKILL.md preview
---
name: stripe-checkout-and-billing-integration
description: Build and debug Stripe Checkout, subscriptions, usage billing, invoicing, and customer portal flows using explicit entitlement policies, durable webhook intake, transactional deduplication, and lifecycle tests. Use when the user says "add Stripe Checkout", "set up subscriptions with a trial", "my webhook keeps granting credits twice", "customers paid but still cannot access the app", "fix upgrade proration", "add usage-based billing", or "migrate our subscribers to Stripe".
---
# Stripe Checkout and Billing Integration
… (sign up to view the full skill)More development skills
View all Development skills →Production Go: Concurrency, Services & Profiling
Production Go code with leak-free goroutines, context-correct services, wrapped errors, and pprof-driven performance fixes.
Backend Feature Build Plan
Builds one backend feature through gates: confirmed requirements, one-screen design, small tested slices, and a deploy/rollback handoff.
Consistent, Safe Application Logging
Adds structured, correlated logs with useful severity, safe fields, bounded volume, and targeted verification.
Reliable WebSocket Messaging and Scaling
Build WebSocket and Socket.IO systems with authorized rooms, reconnect recovery, bounded queues, and multi-node presence.