AuroraMeter.Billing.Provider behaviour (Aurora Meter v0.1.0)

View Source

Behaviour for a billing provider. The core ships AuroraMeter.Billing.Noop; the Pro package provides a Stripe implementation. Only ever call a provider through the AuroraMeter.Billing facade.

Summary

Callbacks

Returns a billing-portal URL for the tenant.

Creates a checkout session and returns a redirect URL.

Reports metered usage entries to the provider.

Syncs a provider subscription payload into local storage.

Callbacks

billing_portal_url(tenant, opts)

@callback billing_portal_url(tenant :: term(), opts :: keyword()) ::
  {:ok, String.t()} | {:error, term()}

Returns a billing-portal URL for the tenant.

create_checkout_session(tenant, opts)

@callback create_checkout_session(tenant :: term(), opts :: keyword()) ::
  {:ok, String.t()} | {:error, term()}

Creates a checkout session and returns a redirect URL.

report_usage(entries)

@callback report_usage(entries :: list()) :: :ok | {:error, term()}

Reports metered usage entries to the provider.

sync_subscription(payload)

@callback sync_subscription(payload :: map()) :: {:ok, term()} | {:error, term()}

Syncs a provider subscription payload into local storage.