Stripe Integration (internal)
This package implements the Stripe provider integration. For self-hosting setup instructions, see docs/stripe.md.
Data flow
Operator creates product/price in MC
→ Row inserted into billing schema
→ Outbox entry enqueued (integration.outbox)
→ Temporal outbox poller picks up entry
→ Stripe API call (creates Stripe object)
→ Mapping row written (stripe.*_mappings)
Stripe sends webhook
→ POST /webhooks/stripe
→ Inserted into integration.webhook_events
→ Temporal webhook processor picks up event
→ Mapping row created/updated/confirmed
→ Core billing tables updated (subscriptions, invoices, payments)
Mapping tables
Each billing entity has a corresponding mapping table in the stripe schema:
| MC table | Mapping table | Stripe ID column |
|---|---|---|
billing.products |
stripe.product_mappings |
stripe_product_id |
billing.prices |
stripe.price_mappings |
stripe_price_id |
billing.accounts |
stripe.customer_mappings |
stripe_customer_id |
billing.subscriptions |
stripe.subscription_mappings |
stripe_subscription_id |
billing.invoices |
stripe.invoice_mappings |
stripe_invoice_id |
billing.payments |
stripe.payment_mappings |
stripe_payment_intent_id |
Each mapping row has a sync_status: pending, synced, or deleted.
No Stripe IDs appear on core billing tables (Decision 113). The mapping tables are the only join point.
Provider config
stripe.provider_configs is a singleton row (enforced by CHECK (id = 1)) storing the account ID and mode (test/live). Credentials live in environment variables, never in the database.
Temporal workflows
Two long-running workflows in internal/workflows/stripe/:
stripe-outbox-poller(outbox.go) — Pollsintegration.outboxfor pending entries, executes them (Stripe API calls), writes mapping rows. UsesContinueAsNew.stripe-webhook-processor(webhook.go) — Pollsintegration.webhook_events, dispatches to per-event-type handlers.
Both start automatically on member-console start.
Outbox actions
| Action type | Trigger | Executor |
|---|---|---|
create_stripe_customer |
Billing account creation | executeCreateStripeCustomer |
create_stripe_product |
Migration seed / operator UI | executeCreateStripeProduct |
create_stripe_price |
Migration seed / operator UI | executeCreateStripePrice |
Key files
migrations/— Schema and mapping table DDL, seed outbox entriesqueries/— sqlc queries for mapping table CRUDensure_customer.go— Stripe Customer creation payloadinternal/workflows/stripe/outbox.go— Outbox poller and executorsinternal/workflows/stripe/webhook.go— Webhook event dispatcher and handlersinternal/server/stripe_webhook.go— HTTP handler forPOST /webhooks/stripe