Stripe (tiger_stripe v0.3.0)

Copy Markdown View Source

Elixir SDK and client for the Stripe API.

Client Configuration

Create a client with explicit options:

client = Stripe.client("sk_test_...")

{:ok, customer} = Stripe.Services.CustomerService.create(client, %{
  email: "jane@example.com"
})

Per-Client Options

# Connect: act on behalf of a connected account
client = Stripe.client("sk_test_...", stripe_account: "acct_...")

# Explicit key with retry policy
client = Stripe.client("sk_test_other", max_retries: 5)

Supported Client Options

  • :api_key - Stripe secret key (required)
  • :api_version - Pin a specific Stripe API version
  • :stripe_account - Default connected account ID (Stripe Connect)
  • :client_id - OAuth client ID
  • :max_retries - Maximum retry attempts (default: 2)
  • :open_timeout - Connection timeout in ms (default: 30_000)
  • :read_timeout - Read timeout in ms (default: 80_000)
  • :finch - Custom Finch instance name (default: Stripe.Finch)
  • :transport - Custom HTTP transport for tests or advanced integrations

Summary

Functions

Returns a child spec for the default Finch pool.

Raises because libraries should not read application configuration.

Create a new Stripe client.

Create a new Stripe client with an explicit API key.

Returns the library version.

Functions

child_spec(opts \\ [])

@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns a child spec for the default Finch pool.

Add this to your application's supervision tree when using the default Stripe.Finch pool:

children = [
  Stripe
]

Pass finch: MyApp.Finch to Stripe.client/2 when using your own Finch pool instead.

client()

@spec client() :: no_return()

Raises because libraries should not read application configuration.

Pass an API key explicitly with Stripe.client/1, or read credentials from your own application's configuration before constructing a client.

client(api_key)

@spec client(String.t() | keyword()) :: Stripe.Client.t()

Create a new Stripe client.

When given a string, treated as an explicit API key. When given a keyword list, the list must include :api_key.

Examples

client = Stripe.client("sk_test_...")
client = Stripe.client(api_key: "sk_test_...", max_retries: 5)

client(api_key, opts)

@spec client(
  String.t(),
  keyword()
) :: Stripe.Client.t()

Create a new Stripe client with an explicit API key.

Examples

client = Stripe.client("sk_test_...")
client = Stripe.client("sk_test_...", stripe_account: "acct_...", max_retries: 5)

version()

@spec version() :: String.t()

Returns the library version.