Cursor prompt
Add Stripe Payment Integration
Complete Stripe checkout, webhooks, subscription management, and billing portal with idempotent webhook handling.
Integrate Stripe payments into {{project_name}}. ## Billing Model: {{billing_model}} ## Price IDs: {{price_ids}} ### Checkout Flow 1. Create Stripe customer on user signup → store stripeCustomerId in DB 2. POST /api/stripe/checkout → create Checkout Session with metadata: { userId, planId } 3. Set success_url and cancel_url with session_id for verification 4. Success handler: verify session, activate subscription in DB ### Webhook Handler: POST /api/stripe/webhook Verify HMAC signature with stripe.webhooks.constructEvent() first. Handle these events idempotently (check processed event ID before handling): - checkout.session.completed → activate subscription, store subscriptionId - customer.subscription.updated → sync plan tier and period end - customer.subscription.deleted → downgrade user to free tier - invoice.payment_failed → mark past_due, trigger dunning email sequence - invoice.payment_succeeded → extend access period, clear past_due flag Return 200 for ALL events including unhandled ones. ### Billing Portal POST /api/stripe/portal → create portal session → redirect to Stripe-hosted portal. Users can manage their own plan changes and cancellations. ### Database Fields to Add stripeCustomerId, subscriptionId, subscriptionStatus, currentPeriodEnd, planId ### Security - Webhook signature verification is mandatory — reject unsigned requests - Never log full card data — Stripe handles PCI compliance - Store only Stripe IDs, never raw payment method data ### Output All API routes, webhook handler, DB migration, and environment variable list.
Fill in: {{project_name}}, {{billing_model}}, {{price_ids}}. In Loopy you fill these in a form and copy the finished prompt in one click.
More coding prompts
- CursorAdd File Upload with Cloud StorageMulti-file upload with type checking, size limits, virus scanning, cloud storage, and progress tracking.
- CursorAdd Redis Caching LayerCache-aside Redis caching with typed get/set helpers, TTL management, pattern-based invalidation, and monitoring.
- LovableBooking and Scheduling SystemCalendar-based booking with availability management, confirmations, reminders, and payment collection.
- CursorBuild Admin Dashboard with CRUDData table with server-side CRUD, column sorting and filtering, bulk actions, and role-protected admin panel.
- CursorBuild Data Export FeatureExport large datasets to CSV or Excel with streaming for memory efficiency, background jobs, and signed download links.
- CursorBuild Feature from SpecComprehensive prompt for your coding agent to build a complete feature from a technical specification. Handles file creation, imports, and testing.

