Skip to Content
Business logicFees & paymentsPayment processing flow

Payment Processing Flow

This sequence diagram illustrates the payment processing flow using Stripe integration for various transactions in the TunnelFlight platform.

Standard Payment Flow

Subscription Payment Flow

Refund Processing Flow

Webhook Processing Flow

Stripe posts events to POST /api/stripe-webhook. The checkout page posts to the same route after confirmPayment succeeds (fromApp: true plus paymentIntentId) so the member is activated without waiting for Stripe’s event.

  • Signature: every Stripe event must carry a valid stripe-signature checked against STRIPE_WEBHOOK_SECRET. The checkout page’s call is unsigned. It is trusted only because the payment intent is re-read from Stripe, not taken from the request. An id Stripe doesn’t recognise gets a 400, not a 500, so unauthenticated callers can’t trigger the 5xx alerts.
  • Claim: the checkout page and Stripe usually report the same payment within seconds. The conditional UPDATE means only one of them sends the email and counts the coupon redemption.
  • Order: activation runs before the claim because it is safe to repeat. If the claim then fails, Stripe’s retry still activates the member.
  • After the claim: the email, GA4 and Stripe description steps are best-effort. Each failure logs stripe_webhook.step_failed and does not fail the request, because a retry would skip them.
  • Refunds: any refund.created is treated as a full refund, whatever its amount, and sets the member Inactive.

Security Measures

  • PCI Compliance: Card details never touch our servers (handled by Stripe.js)
  • Webhook Verification: All webhooks verified using Stripe signatures
  • Idempotency: a payment is applied once; succeeded and refunded fee rows are never re-applied
  • SSL/TLS: All payment communications use HTTPS
  • Tokenization: Card details replaced with secure tokens
  • Rate Limiting: Payment endpoints are rate-limited
  • Audit Trail: All payment events logged for compliance
Last updated on