Skip to content

About

Stripe payment provider controller for billing.miloapis.com PaymentMethods

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

stripe-provider

Stripe reference implementation of the payment provider pattern for the milo-os/billing PaymentMethod and PaymentMethodClass CRDs.

The billing service intentionally knows nothing about Stripe; it only owns the generic PaymentMethod resource and the cluster-scoped PaymentMethodClass registry. This service watches PaymentMethod resources that name a PaymentMethodClass belonging to it, drives the Stripe SetupIntent lifecycle through a provider-owned StripePaymentMethod CRD, and projects normalized outcome state back onto PaymentMethod status once the instrument is confirmed.

See docs/enhancements/payment-methods.md in the billing repo for the full design.

CRDs

Resource Scope Purpose
StripeProviderConfig Cluster Operator-configured Stripe SDK settings (publishable key) referenced by a PaymentMethodClass.spec.parametersRef.
StripePaymentMethod Namespace Provider-owned state for a single PaymentMethod. Child of the parent PaymentMethod via ownerReference.
StripeCustomer Namespace The Stripe Customer for a BillingAccount, named after it and owned by it. status.stripeCustomerId is what invoicing providers bill, so an account with payment terms can be invoiced without a card.
StripeProduct Namespace The Stripe Product for one SKU of the catalog (or one list ServicePricing without a SKU), named and taxed as its newest list pricing. Invoice lines name it. See docs/architecture/invoicing.md.
StripeInvoice Namespace An invoice for Stripe to work out, as lines with a Product, quantity, unit price, service period and tax. It previews (Stripe's preview with nothing created, or a draft for staff to open in the dashboard, deleted after a day) or writes a real invoice: a draft kept in step with its lines, finalized on request, its payment state read from Stripe. See docs/architecture/invoicing.md.

Invoicing

stripe-provider is taking over writing invoices to Stripe from OpenMeter's Stripe app, with a Product, quantity, unit price, service period and tax settings on every line. See docs/architecture/invoicing.md.

Components

  • PaymentMethod watcher — watches billing PaymentMethod resources; creates a StripePaymentMethod child when the resource's class points at a Stripe PaymentMethodClass.
  • StripePaymentMethod controller — ensures a Stripe Customer for the billing account, creates a SetupIntent, writes clientSecret onto StripePaymentMethod.status.setupIntent, then projects normalized details onto PaymentMethod.status once confirmation arrives.
  • BillingAccount controller — keeps the account's Stripe Customer in sync with the BillingAccount, and creates it, with its StripeCustomer, once the account has a payment method or billing reports it is billed by invoice (status.paymentArrangement). Both controllers create customers through one shared, per-account lock, so an account never gets two. While the account is on payment terms, the terms' PO number and agreement reference are printed on every invoice (invoice_settings.custom_fields).
  • Product controllers — give every ServicePricing a StripeProduct, one per SKU, and keep its Stripe Product's name, tax code and active flag in step with the newest list pricing.
  • StripeInvoice controller — has Stripe preview a StripeInvoice, or make it a draft for the dashboard, and deletes it, with its draft, once it expires. For a real invoice (purpose: Invoice) it keeps a Stripe draft in step with the lines, finalizes it when spec.finalize is set, and reads its state from Stripe until it's paid or void.
  • Webhook server — receives Stripe setup_intent.* and invoice.sent events on POST /webhooks/stripe. Signature-verified via the per-class webhook secret stored in the Secret referenced by StripeProviderConfig. invoice.sent records an InvoiceSent Event on the billing account's activity timeline each time Stripe emails an invoice. invoice.finalized, invoice.paid, invoice.payment_failed, invoice.payment_succeeded, invoice.voided, invoice.marked_uncollectible, invoice.deleted and invoice.updated have a real invoice's StripeInvoice read again. The endpoint has to be subscribed to each of them in Stripe.

Develop

task install-tools
task generate
task manifests
task build
task test
task lint

About

Stripe payment provider controller for billing.miloapis.com PaymentMethods

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages