Wallstreet: Billing and Subscriptions

Overview

Wallstreet is responsible for all payments, billing, Stripe integration, and Pivot SaaS subscriptions. This means that other services depend on Wallstreet if authorization for some operation is dependent on the presence of a SubscribableFeature, because it is Wallstreet that can verify if such a feature exists in scope for a given user or organization.

API

NATS

Publication

Whenever an entity owned by Wallstreet is mutated, it publishes a message to wallstreet.change_feed. For example, wallstreet.change_feed.subscription.{customerType}_{customerId}.createdV1.

Consumption

  • Wallstreet is responsible for handling Stripe events, so it is presumably the only consumer of tunnel.incoming-webhook-events.stripe.

Databases

Wallstreet uses Postgres to persist information about customers, subscriptions and features.

  1. Customer – A customer is a user or an organization. Some entity that has a credit card on file in their Stripe customer record. A customer may also have a Stripe connected account to receive payouts if they are an organization.

  2. Subscription - A subscription maps one-to-one with a Stripe subscription, if the subscription has a cost. A subscription relates a customer to a product.

  3. SubscriptionProduct – Generally we expect one product per subscription, but it is designed as a many-to-many for future-proofing.

  4. Product – A product is anything that can be subscribed to – a Pivot organization tier, a Pivot per-user subscription individual users can get, a paid space membership; these are all examples of subscribable things.

  5. Price – A product can have one or more prices, each corresponds to a Stripe price and defines the actual amount of a frequency of payment for a product.

  6. Feature – A feature represents a capability in the Pivot product that is restricted to only those users/organizations who have subscribed to a product that includes said feature.

  7. ProductFeature – Relates products to features. For example, a product that represents the 'Starter' tier of the Pivot Cloud Platform organization could have a ProductFeature representing the feature of audio/video message transcription. A feature may be limited in quantity for a specific product.

Temporal Workflows

// TODO: Figure out billing related workflows, like renewal reminders, payment failure handling, stripe usage reporting, payouts to Stripe connected accounts, etc.

Deployment

Observability

Security