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
Link to this section Types
Link to this section Functions
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 prefixsk_test_
and live mode secret keys have the prefixsk_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"})
@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.