Migrating from Stripe v2 to Stripe v3 + adding Klarna as alternative payment method.
INTERACTIVE Select text or right-click any element to leave feedback. Export as JSON and paste into Claude Code.
stripe-legacy package/webhooks/stripe for payment confirmations| Metric | Value |
|---|---|
| Transactions/month | ~12,000 |
| GMV | ~$840,000 |
| Avg. ticket size | $70 |
| Refund rate | 3.2% |
stripe-legacy is unmaintained, last update 18 months ago
flowchart TD
CHECKOUT["Checkout Page"]
CHECKOUT --> INTENT["Create PaymentIntent
(server-side)"]
INTENT --> CHOOSE{"Payment
Method?"}
CHOOSE -->|Credit Card| STRIPE_EL["Stripe Elements
(3DS v2 built-in)"]
CHOOSE -->|Klarna| KLARNA_SDK["Klarna Widget
(Pay Later / Installments)"]
STRIPE_EL --> CONFIRM["confirmPayment()"]
KLARNA_SDK --> REDIRECT["Klarna Redirect
+ Return URL"]
CONFIRM --> WH_STRIPE["Webhook:
payment_intent.succeeded"]
REDIRECT --> WH_KLARNA["Webhook:
klarna.order.approved"]
WH_STRIPE --> VERIFY["Verify Signature
(stripe-signature header)"]
WH_KLARNA --> VERIFY
VERIFY --> FULFILL["Fulfill Order
+ Send Confirmation"]
FULFILL --> LEDGER["Record in
Payment Ledger"]
style STRIPE_EL fill:#dbeafe,stroke:#1d4ed8
style KLARNA_SDK fill:#fce7f3,stroke:#db2777
style VERIFY fill:#dcfce7,stroke:#16a34a
style FULFILL fill:#dcfce7,stroke:#16a34a
| Phase | Scope | Risk | Done when |
|---|---|---|---|
| Phase 1 DONE Stripe SDK Upgrade |
Replace stripe-legacy with stripe@14.Migrate from Charges API to Payment Intents API. Add idempotency keys to all payment operations. Verify webhook signatures with stripe.webhooks.constructEvent().
|
MEDIUM | All existing credit card flows work with new SDK. Zero duplicate charges for 7 days. |
| Phase 2 DONE 3DS v2 Migration |
Replace custom 3DS v1 iframe with Stripe Elements. Payment Sheet handles SCA challenges automatically. Test with 4000 0025 0000 3155 (requires auth) and 4000 0000 0000 3220 (3DS2 required).
|
LOW | 3DS v2 challenges complete in-page without redirect. Auth success rate >95%. |
| Phase 3 IN PROGRESS Klarna Integration |
Add Klarna as payment method on PaymentIntent creation. "Pay in 30 days" + "Pay in 3 installments" options. Klarna widget in checkout with amount breakdown. Handle async Klarna webhooks (authorized → captured). |
MEDIUM | Klarna option visible in checkout. E2E test: create order → Klarna auth → webhook → fulfillment. |
| Phase 4 Monitoring + Rollout |
Payment success rate dashboard (Grafana). Alert on >5% failure rate or webhook delivery delay >5min. A/B test: Klarna vs. card-only checkout conversion. Gradual rollout: 10% → 50% → 100%. |
LOW | Dashboard live. Conversion lift from Klarna measured. Full rollout complete. |
sequenceDiagram
participant U as Customer
participant FE as Frontend
participant BE as Backend API
participant S as Stripe API
participant K as Klarna
U->>FE: Select "Pay with Klarna"
FE->>BE: POST /api/payments/create-intent
BE->>S: stripe.paymentIntents.create({
payment_method_types: ['klarna']})
S-->>BE: { client_secret, id }
BE-->>FE: { clientSecret }
FE->>S: stripe.confirmKlarnaPayment(clientSecret)
S->>K: Redirect to Klarna authorization
K->>U: Show "Pay in 30 days" offer
U->>K: Approve payment
K->>S: Authorization confirmed
S->>FE: Redirect to return_url
Note over S,BE: Async webhook (1-30s later)
S->>BE: POST /webhooks/stripe
payment_intent.succeeded
BE->>BE: Verify signature + fulfill order
BE->>U: Order confirmation email
automatic_payment_methods instead of hard-coding method types — future-proof for Apple Pay, Google Paypayment_events table for audit trail, or rely on Stripe Dashboard?| File | Purpose |
|---|---|
src/services/payment/stripe-client.ts |
Stripe SDK initialization, PaymentIntent creation, idempotency key generation |
src/routes/api/payments/create-intent.ts |
POST endpoint: creates PaymentIntent with card + klarna methods |
src/routes/webhooks/stripe.ts |
Webhook handler with signature verification + event routing |
src/components/checkout/PaymentStep.tsx |
Stripe Elements + Klarna widget in checkout flow |
src/services/payment/fulfillment.ts |
Order fulfillment triggered by successful payment events |