MPP.Methods.Stripe.Subscription (mpp v0.16.2)

Copy Markdown View Source

Stripe Billing activation, renewal accounting, and cancellation for the shared subscription intent.

Implements the constrained fixed-price profile from draft-stripe-subscription-00: one Customer, one recurring Price, one quantity-one Subscription, and synchronously paid invoices mapped onto locally persisted canonical periods.

Summary

Functions

Schedule cancellation at the end of the last durably paid billing period.

Return the public Stripe subscription challenge fields.

Process a Stripe subscription event after its webhook signature has been verified.

Validate and durably record a paid Stripe renewal invoice.

Validate Stripe subscription configuration at Plug initialization.

Activate a Stripe subscription and verify its synchronously paid first invoice.

Stop Stripe collection for an unpaid invoice after its canonical period closes.

Functions

cancel(subscription_id, config)

@spec cancel(String.t(), map()) ::
  {:ok, MPP.Subscription.Record.t()} | {:error, MPP.Errors.t()}

Schedule cancellation at the end of the last durably paid billing period.

challenge_method_details(subscription)

@spec challenge_method_details(MPP.Intents.Subscription.t()) :: map()

Return the public Stripe subscription challenge fields.

process_event(event, config)

@spec process_event(map(), map()) ::
  {:ok, MPP.Subscription.Record.t()} | {:error, MPP.Errors.t()}

Process a Stripe subscription event after its webhook signature has been verified.

process_invoice(event_id, invoice_id, config)

@spec process_invoice(String.t(), String.t(), map()) ::
  {:ok, MPP.Receipt.t()} | {:error, MPP.Errors.t()}

Validate and durably record a paid Stripe renewal invoice.

validate_config!(config)

@spec validate_config!(map()) :: :ok

Validate Stripe subscription configuration at Plug initialization.

verify(payload, subscription)

@spec verify(map(), MPP.Intents.Subscription.t()) ::
  {:ok, MPP.Receipt.t()} | {:error, MPP.Errors.t()}

Activate a Stripe subscription and verify its synchronously paid first invoice.

void_stale_invoice(subscription_id, invoice_id, as_of, config)

@spec void_stale_invoice(String.t(), String.t(), DateTime.t(), map()) ::
  {:ok, MPP.Subscription.Record.t()} | {:error, MPP.Errors.t()}

Stop Stripe collection for an unpaid invoice after its canonical period closes.