Request-scoped helpers for Stripe Connect behavior.
Stripe's Stripe-Account header is per request. PaperTiger models that by
storing the connected account ID in the process dictionary for the duration
of a request, then using it as part of the ETS storage namespace for normal
resources. Platform-owned resources can temporarily opt back into the base
namespace with without_account/1.
Summary
Functions
Returns true when an ID looks like a Stripe connected account ID.
Clears any connected account from the current process.
Returns the connected account ID for the current request, if any.
Sets the connected account for the current process.
Returns the storage namespace for the current sandbox + connected account.
Returns the storage namespace for a base sandbox namespace.
Runs fun with the given connected account ID in the process dictionary.
Runs fun in platform scope even if the request is account-scoped.
Types
@type account_id() :: String.t()
@type storage_namespace() :: pid() | :global | {pid() | :global, account_id()}
Functions
Returns true when an ID looks like a Stripe connected account ID.
@spec clear_account() :: :ok
Clears any connected account from the current process.
@spec current_account() :: account_id() | nil
Returns the connected account ID for the current request, if any.
@spec put_account(account_id()) :: :ok
Sets the connected account for the current process.
@spec storage_namespace() :: storage_namespace()
Returns the storage namespace for the current sandbox + connected account.
@spec storage_namespace(pid() | :global) :: storage_namespace()
Returns the storage namespace for a base sandbox namespace.
@spec with_account(account_id() | nil, (-> result)) :: result when result: term()
Runs fun with the given connected account ID in the process dictionary.
@spec without_account((-> result)) :: result when result: term()
Runs fun in platform scope even if the request is account-scoped.