Accrue.Plug.PutConnectedAccount (accrue v0.3.0)

Copy Markdown View Source

Stashes a per-request Connect stripe_account id into the process dictionary for the lifetime of the request.

The scope value is resolved from a compile-time MFA tuple — never from a raw HTTP header or query parameter. The configured tenancy function receives the %Plug.Conn{} as its last argument so the host app can read conn.assigns, session data, or subdomain to decide which connected account the request operates on.

Usage

plug Accrue.Plug.PutConnectedAccount,
  from: {MyAppWeb.Tenancy, :current_stripe_account, []}

MyAppWeb.Tenancy.current_stripe_account/1 (note: Accrue appends conn as the trailing argument, so the declared arity is length(args) + 1) must return one of:

  • nil — platform scope (default; plug is a no-op)
  • a binary "acct_..." id
  • an %Accrue.Connect.Account{} struct

Any other return shape raises ArgumentError.