View Source Stripe (Striped v0.5.0)

Library to interface with the Stripe Api. Most of the code is generated from the Stripe OpenApi definitions.

Inspiration was drawn from Stripity Stripe and openapi.

installation

Installation

def deps do
  [
    {:striped, "~> 0.5.0"}
  ]
end

usage

Usage

client = Stripe.new(api_key: "sk_test_123")
{:ok, %Stripe.Customer{}} = Stripe.Customer.retrieve(client, "cus123")

{:ok, %Stripe.Customer{}} =
               Stripe.Customer.create(client, %{
                 description: "Test description"
               })

For the exact parameters you can consult the Stripe docs.

errors

Errors

Stripe errors can be found in the Stripe.ApiErrors struct. Network errors etc. will be found in the error term.

{:error, %Stripe.ApiErrors{}} =
               Stripe.Customer.retrieve(client, "bogus")

telemetry

Telemetry

Stripe api calls made through this library emit Telemetry events. See the Stripe.Telemetry module for more information

api-version

Api Version

Striped uses the OpenApi definitions to build itself, so it uses the latest Api Version. You can however override the version by passing the :version option to the client.

This SDK is generated for version: 2022-11-15

See https://stripe.com/docs/upgrades#2022-11-15 for breaking changes.

limitations

Limitations

  • File Uploads currently don't work.
  • Connected Accounts are not supported yet.

Link to this section Summary

Types

t()

Stripe config

Functions

Returns new client.

Link to this section Types

@type t() :: %Stripe{
  api_key: binary(),
  base_url: binary(),
  http_client: term(),
  idempotency_key: nil | binary(),
  max_network_retries: pos_integer(),
  user_agent: binary(),
  version: binary()
}

Stripe config

Link to this section Functions

@spec new(Keyword.t()) :: t()

Returns new client.

Options

  • :version Set Stripe api version. All requests use your account API settings, unless you override the API version.
  • :api_key Set Stripe api keys. Test mode secret keys have the prefix sk_test_ and live mode secret keys have the prefix sk_live_.
  • :idempotency_key Override default idempotency key
  • :base_url Override default base url. E.g. for local testing
  • :http_client Override http client, defaults to Stripe.HTTPClient.HTTPC. Must conform to Stripe.HTTPClient behaviour.

Example

client = Stripe.new()
Stripe.Customer.create(client, %{description: "a description"})
Link to this function

request(method, path, client, params, opts \\ [])

View Source
@spec request(
  method :: binary(),
  path :: binary(),
  client :: t(),
  params :: map(),
  opts :: Keyword.t()
) :: {:ok, term()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Perform Stripe API requests.