Payments

ProDepends: workflows

Enable payment processing with Stripe.

Syntax

$ vela enable payments

Options

  • --provider <provider> - Payment provider, defaults to stripe

The payments module creates the necessary database tables and code for payment processing, webhook events, receipts, sweeps and more.

Database tables

The payments module creates the following database tables:

stripe_products
stripe_prices

Webhooks

Stripe webhooks are scaffolded in src/routes/webhooks/stripe, with the payment intent succeeded event included by default.

Customers

If authentication is enabled with the vela enable auth command, a Stripe customer is created for each user on sign up and a user’s payment methods can be saved and managed in the user’s billing settings page. The customer is linked by the link-stripe-customer workflow, started by the signup action with the user’s id as its idempotency key, so signing up never waits on Stripe and a retry never makes a second customer. The billing page shows a settling-up state for the moment it takes.

Database tables

These additional tables are created if authentication is enabled:

stripe_customers
stripe_payment_methods
transactions

Webhooks

In addition to the payment intent succeeded event, the payment method attached event is included by default for the authenticated user.

Workflows

The Stripe work that does not belong on the request path runs as workflows in src/lib/workflows:

  • stripe-event - The webhook route verifies each event’s signature and queues one run per event id. The run calls the handler in src/routes/webhooks/stripe/handlers/dispatch.ts; a handler that throws is retried with backoff, and a redelivery of the same event lands on the run that already exists.
  • sync-stripe-products and sync-stripe-prices - Recurring every ten minutes in sync-stripe-catalog.ts, adding products and prices new in Stripe and updating the rest.
  • sync-stripe-customers - Recurring every ten minutes when authentication is enabled, linking any user that did not come through signup.

Every run, with its steps and any error, is listed under Workflows in the PocketBase dashboard.