Defines the behavior for billing providers (Stripe, Paddle, LemonSqueezy, etc.).
Summary
Callbacks
Cancels a subscription in the billing provider.
Creates a checkout session for subscriptions or one-time payments.
Creates a customer in the billing provider.
Creates a billing portal session where customers can manage their payment methods and subscriptions.
Retrieves a subscription from the billing provider.
Resumes a subscription that was scheduled to cancel at period end.
Swaps an active subscription to a new price/plan, with optional proration behavior.
Verifies an incoming webhook payload and signature.
Returns {:ok, event_map} if valid, or {:error, reason} if invalid.
Types
Callbacks
@callback cancel_subscription(subscription_id(), opts :: opts()) :: {:ok, map()} | {:error, term()}
Cancels a subscription in the billing provider.
@callback create_checkout_session(params :: map(), opts :: opts()) :: {:ok, %{url: session_url(), id: session_id()}} | {:error, term()}
Creates a checkout session for subscriptions or one-time payments.
@callback create_customer(params :: map(), opts :: opts()) :: {:ok, customer_id()} | {:error, term()}
Creates a customer in the billing provider.
@callback create_portal_session(params :: map(), opts :: opts()) :: {:ok, %{url: session_url()}} | {:error, term()}
Creates a billing portal session where customers can manage their payment methods and subscriptions.
@callback get_subscription(subscription_id(), opts :: opts()) :: {:ok, map()} | {:error, term()}
Retrieves a subscription from the billing provider.
@callback resume_subscription(subscription_id(), opts :: opts()) :: {:ok, map()} | {:error, term()}
Resumes a subscription that was scheduled to cancel at period end.
@callback swap_plan(subscription_id(), new_price_id :: String.t(), opts :: opts()) :: {:ok, map()} | {:error, term()}
Swaps an active subscription to a new price/plan, with optional proration behavior.
@callback verify_webhook( payload :: binary(), signature_header :: String.t() | nil, secret :: String.t(), opts :: opts() ) :: {:ok, map()} | {:error, term()}
Verifies an incoming webhook payload and signature.
Returns {:ok, event_map} if valid, or {:error, reason} if invalid.