AuroraMeter.Billing (Aurora Meter v0.4.0)

View Source

Facade over the configured AuroraMeter.Billing.Provider (AuroraMeter.Config.provider/0, default AuroraMeter.Billing.Noop).

With only the free core installed these return {:error, :not_configured}; install and configure the Pro Stripe provider to enable checkout and billing.

Summary

Functions

Starts a checkout session for plan_id and returns a redirect URL.

Returns a billing-portal URL for the tenant.

Synchronizes a subscription using the configured provider.

Functions

checkout(tenant, plan_id, opts \\ [])

@spec checkout(term(), atom() | String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Starts a checkout session for plan_id and returns a redirect URL.

portal_url(tenant, opts \\ [])

@spec portal_url(
  term(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}

Returns a billing-portal URL for the tenant.

sync_subscription(payload)

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

Synchronizes a subscription using the configured provider.

Examples

AuroraMeter.Billing.sync_subscription(%{"id" => "sub_example"})
#=> {:ok, subscription} | {:error, reason}