Skip to content

Add Stripe payments submodule - #5906

Open
bradleyshep wants to merge 90 commits into
masterfrom
bradley/submodules-payments
Open

bradleyshep wants to merge 90 commits into
masterfrom
bradley/submodules-payments

Conversation

@bradleyshep

@bradleyshep bradleyshep commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Description of Changes

Adds a Stripe submodule that mirrors customers, subscriptions, Checkout sessions, invoices, and payments into private SpacetimeDB tables.

  • Admin procedures and per-user helpers for Stripe billing and queries
  • Webhook ingestion with signature checks, dedupe, and replay, shared by the relay reducer and the host HTTP handler
  • Out-of-order events can't overwrite newer state or move a status backward
  • When two subscription events tie on the same second, the HTTP handler re-reads the subscription from Stripe
  • Refunds are mirrored into stripe_refund, and payments track amountRefunded
  • Store example, docs, tests, smoke scripts, and generated client bindings

Example screenshots

Stripe

Stripe example

API and ABI breaking changes

None. Adds new TypeScript package APIs.

Rollback safety impact

n/a. Adds opt-in TypeScript packages and examples.

Expected complexity level and risk

2/5

Testing

Removed the unit tests for the deleted webhook-metadata.ts and validateWebhookRequestBody; the shared ingest path covers both.

  • Typecheck, lint, unit tests, and example typechecks
  • test:smoke and test:example on a local SpacetimeDB
  • test:billing:live and test:stripe:e2e with Stripe test credentials
  • test:ui
  • Same-second subscription tie over the HTTP route against a real test-mode subscription

@bradleyshep bradleyshep mentioned this pull request Sep 9, 2026
5 of 7 tasks
@bradleyshep
bradleyshep requested a review from aasoni September 10, 2026 17:43
bradleyshep and others added 20 commits September 17, 2026 08:52
Merge reviewed core updates. Use camelCase TypeScript exports, Apache-2.0 licensing, and direct SDK updates. Search full organization subscription history and cover the former 5000-row cutoff with a regression test.
Configure fixed policies once, expose stable errors, keep installers idempotent, and support admin revocation. Remove internal sweep exports and align init naming. Verify packed consumers with the default TypeScript template.
Merge reviewed core changes and standardize install. Keep failed HTTP events retryable and reject failed relay payloads. Add signed HTTP redelivery and recovery cases to the existing smoke test, with explicit public exports and updated documentation.
An email match could hand one user another user's customer and saved payment methods.
Drop the install options, the standalone install and sweep exports, and helpers exported only for tests. runSweep and resetBuckets share one maxRows validation.
Store the event created time on customer, subscription, Checkout session,
and invoice rows, and ignore events that are older or would move a status
backward, including replays. Record Checkout payment_status and handle the
async payment events. Read invoice subscriptions from both invoice shapes
and link invoice PaymentIntents through invoice_payment.paid on API
versions from 2025-03-31.basil.
client({ handlers }) imports the SDK directly and returns the tables,
install, submit, views, and reducers. Contexts are typed against the
retry tables instead of unknown, and thrown codes come from an exported
errors object.

retryHandler no longer defines a property on the caller's type builder,
so one builder can back several handlers. The custom auth policy is
replaced by submit(), which host reducers call after their own checks.

History is written once per attempt with its final status, pruned by
removing the oldest row through the ranAt index, and served newest first
without sorting. The unused taskName and status indexes are removed,
admin rows store addedAt as a timestamp, and the task view returns the
newest tasks.
@bradleyshep
bradleyshep requested a review from bfops as a code owner October 9, 2026 15:34
@bradleyshep
bradleyshep changed the base branch from bradley/submodules-core to master October 11, 2026 16:23
The SDK peer dependency was `workspace:^`, which packs as the
unpublished 2.13.0. It is now `^2.12.0`.

Declarations failed to build against 2.12 because inferred table,
schema, reducer, procedure, and view types referenced SDK types 2.12
does not export. Exports now carry explicit types from public SDK names,
with each table's options and columns and each operation's arguments
and results defined once.

The README installs a matching SDK, states the 2.12 minimum, links the
example on GitHub, and links the license text.
`npm install <pkg> spacetimedb@^2.12.0` rewrote the `2.12.*` pin that
`spacetime init` sets, which would pull a newer SDK into a project with
a 2.12 CLI and server once one is published. The README install line
now adds only the package; npm still checks the peer range.

Comments that described a table, enum, or operation sat between its
hoisted declarations and the export. They again precede everything they
describe.

bradleyshep commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Updates:

  • Added helpers for customer billing, subscriptions, and more Checkout options.
  • Record purchases after Stripe confirms payment. Reuse the same request when retrying checkout.
  • Moved Billing to the header and fixed product cards changing height when adding items.
stripe-demo.mp4

@aasoni
aasoni requested a review from clockwork-tien November 5, 2026 15:47
@bradleyshep

Copy link
Copy Markdown
Contributor Author

@clockwork-tien
Thanks for reviewing this! Some changes since your review:

  • Stripe checkout no longer copies session metadata onto the Stripe customer
  • setStripeConfig rejects an empty secret key or webhook secret
  • Cancel, reactivate and quantity changes no longer stamp the server clock on the subscription row, so a later webhook from Stripe is never ignored as "older"
  • A Stripe API response can no longer move a canceled subscription back to active
  • When two subscription webhooks have the same created second, the HTTP route fetches the subscription from Stripe and stores that
  • Price and session IDs are URL-encoded, and paths containing .. are rejected, so an ID like ../customers can't call a different Stripe endpoint
  • prune_webhook_events can only be called by the scheduler, not by clients
  • Removed create_checkout_session (it skipped quantity and mode validation) and the subscriptionItemId option on quantity updates

@bradleyshep

Copy link
Copy Markdown
Contributor Author

@cloutiertyler need code owner review on this for the license

@cloutiertyler cloutiertyler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the license.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants