BlogPricing

Stripe Checkout with webhook sequence

A sequence diagram for Stripe Checkout: create a session, redirect the user, handle the async webhook with idempotency, and update internal state on payment_intent.succeeded.

Start for free
Sequence diagram previewStripe Checkout with webhook sequence
Recreate this in Raltey

Copy this prompt

Paste this into Raltey's AI agent to generate the same diagram, then tweak it on the canvas.

Prompt
Create a sequence diagram for Stripe Checkout with the async webhook. Actors: User, App server, Stripe, Database. Show: POST /checkout to app, app creates a Stripe Checkout Session, user redirected to Stripe, pays, redirect to success_url. Then the async path: Stripe POSTs /webhook with the event, app checks the database for idempotency, marks the order paid, returns 200 OK to Stripe.

Context

  • - Checkout Sessions (hosted).
  • - Webhook is the source of truth, not the success redirect.
  • - Idempotent handler keyed on event id.

Patterns

  • - Webhook is the source of truth, not the redirect.
  • - Idempotency keyed on Stripe event id.
  • - Acknowledge the webhook within 5 seconds.
Diagram structure

Nodes and connections

User
App server
Stripe
Database
Connections
UserApp serverPOST /checkout
App serverStripeCreate Checkout Session
StripeApp serverSession URL
App serverUserRedirect to Stripe
UserStripePay
StripeUserRedirect success_url
StripeApp serverPOST /webhook (event)
App serverDatabaseAlready processed?
DatabaseApp serverNo
App serverDatabaseMark order paid
App serverStripe200 OK

Notes from the field

Frequently asked

What happens if the webhook arrives twice?

The idempotency check rejects the second one based on the stored Stripe event id. Stripe explicitly says to handle this.

Should I show success based on the redirect?

Use the redirect to show a "thanks" page, but treat the order as paid only after the webhook confirms it.

More templates

Open this template in Raltey

Edit it on the canvas, ask the AI agent to extend it, then share or export.

Start for free