Build a Stripe Checkout Flow
Hand Devin a checkout spec with your Stripe sandbox keys and get a working payment flow — pricing page, checkout session, webhook handler, and confirmation page — verified in the browser.(Optional) Scope the codebase with Ask Devin
If you’re not sure how your app handles payments today — or which files and patterns to reference in your spec — use Ask Devin to investigate first:Use the answers to fill in your spec — reference specific files, table names, and patterns so Devin builds something that fits naturally into your codebase. You can also start a Devin session directly from Ask Devin, and it will carry over everything it learned as context.
Add Stripe sandbox keys
Devin needs Stripe test-mode keys to create checkout sessions and verify the webhook handler. Always use sandbox credentials — never give Devin production Stripe keys.The simplest approach is to store them as organization secrets before starting the session:
- Go to Settings > Secrets and add:
STRIPE_SECRET_KEY— your test-mode secret key from the Stripe DashboardSTRIPE_WEBHOOK_SECRET— the signing secret from your webhook endpoint settings
- Devin accesses these as environment variables, so they never end up hardcoded in your source code.
Organization secrets must be added before starting the session — they’re injected at session start. Alternatively, you can provide secrets during the session using the chat, and Devin will also proactively ask you for any credentials it needs when it encounters missing environment variables.
Hand off your checkout spec
Paste your spec — from a PRD, a Linear ticket, or a detailed Slack message — directly into Devin. A good checkout spec covers the pricing tiers, the payment flow, and what happens after a successful payment. The more structured, the better.A good spec for Devin includes three things: what to build (pricing tiers, checkout flow, webhook handler), where it lives (routes, tables, files), and how it fits in (existing patterns to follow). You don’t need to specify every implementation detail — Devin investigates your codebase to fill in the gaps.
Devin builds and verifies in the browser
Devin reads your spec, explores the codebase for matching patterns, then implements across the full stack. Before opening a PR, it runs your app locally and opens its built-in browser to verify the checkout flow works end-to-end.Here’s what that looks like for the Stripe checkout example:
- Creates the migration — Adds the
subscriptionstable with columns foruser_id,stripe_subscription_id,plan,status, andcurrent_period_end - Builds the pricing page — Creates the three-tier pricing cards at
/pricing, each with a “Subscribe” button that posts to the checkout API - Implements checkout session creation — Builds
POST /api/checkout/sessionsthat creates a Stripe Checkout session with the correct price ID, customer email, and redirect URLs - Adds the webhook handler — Implements
POST /api/webhooks/stripewith signature verification,checkout.session.completedevent handling, and database updates - Builds the success page — Creates
/checkout/successthat fetches the Stripe session, displays the plan name, amount charged, and a “Go to Dashboard” link - Writes tests — Tests for webhook signature verification (valid, invalid, missing), checkout session creation, and the plan-update database logic
- Opens the browser — Starts the dev server, navigates to
/pricing, clicks “Subscribe” on the Pro tier, verifies the Stripe Checkout redirect works, and checks that the success page renders correctly after a test payment - Opens a PR — Delivers all changes with a summary of what was implemented and how it was verified
Iterate from the PR
Once the PR is open, send follow-up prompts in the same session to extend or adjust the checkout flow.
Review the PR with Devin Review
Once Devin opens the PR, use Devin Review to review the changes. Devin Review has full context of your codebase and can catch bugs, security issues, and style inconsistencies across the diff. You can ask follow-up questions in the review chat — for instance, “Does the webhook handler validate the event type before processing?” — and Devin will answer grounded in the actual code.
