Skip to main content

Module stripe

Module stripe 

Source
Expand description

Stripe billing primitives.

This plugin is intentionally small. It does NOT make HTTP calls to Stripe — apps drive the API from TypeScript functions where they already have a networking story. What this module does provide is the security-critical and easy-to-mess-up bits:

  • Webhook signature verification (verify_signature) — Stripe rejects a webhook if you don’t validate the Stripe-Signature header against your endpoint secret. Getting the HMAC + timestamp comparison right is subtle (constant-time compare, replay window). This implementation matches Stripe’s published reference algorithm.
  • Event payload typing (StripeEvent) — a tiny shape over what arrives from a webhook, so app code can match on event.type without re-parsing raw JSON.
  • Customer lookup state (StripeCustomerStore) — an optional in-memory map from app user id → Stripe customer id, useful in dev. Production apps store this in their own user table.

See https://stripe.com/docs/webhooks/signatures for the algorithm spec.

Structs§

StripeCustomerStore
In-memory mapping from app user id → Stripe customer id.
StripeEvent
Minimal projection of a Stripe webhook event.
StripePlugin
Aggregate plugin so apps can register the whole Stripe surface at once.

Enums§

SignatureError

Functions§

current_unix_secs
verify_signature
Verify a Stripe webhook signature.