Accrue.Stripe (accrue v0.3.0)

Copy Markdown View Source

Stripe-specific helpers for host applications (D2-15).

This module provides process-dictionary-scoped overrides for Stripe API settings. The primary use case is traffic-split API version rollouts:

Accrue.Stripe.with_api_version("2026-03-25.dahlia", fn ->
  Accrue.Billing.create_customer(user)
end)

The scoped version is read by Accrue.Processor.Stripe via the three-level precedence chain (D2-14):

opts[:api_version] > pdict > Accrue.Config.stripe_api_version/0

Summary

Functions

Runs fun with the given Stripe API version set in the process dictionary. Restores the prior value (or clears it) in an after block, even if fun raises.

Functions

with_api_version(version, fun)

@spec with_api_version(String.t(), (-> result)) :: result when result: var

Runs fun with the given Stripe API version set in the process dictionary. Restores the prior value (or clears it) in an after block, even if fun raises.

Examples

Accrue.Stripe.with_api_version("2025-01-01.test", fn ->
  Accrue.Billing.create_customer(user)
end)