StripeClient
Warning! This is pre-release, work-in-progress, alpha grade material.
An interface to Stripe for Elixir.
This library is not sponsored or supported by Stripe in any way. Please use it at your own risk. I encourage you to review the code and test suite before using.
Installation
Add
stripe_clientto your list of dependencies inmix.exs:def deps do
[{:stripe_client, "~> 0.0.3"}]end
Ensure
stripe_clientis started before your application:def application do
[applications: [:stripe_client]]end
Configure StripeClient in
config.exs(or environment equivalent):config :stripe_client, :adapter, StripeClient.Adapter.HTTPoison config :stripe_client, :credentials,
secret_key: "secret key from Stripe", public_key: "public key from Stripe"
Usage
StripeClient uses a pluggable adapter framework. Currently it only ships with
a HTTPoison-based adapter. A memory test server adapter is planned in the
future in order to provide a robust test environment without having to rely
on mocking HTTP requests.
Stripe resources are represented as Elixir structs. Currently, the following resources are implemented:
account:StripeClient.Accountcard:StripeClient.Cardcustomer:StripeClient.Customerevent:StripeClient.Eventlist:StripeClient.Listplan:StripeClient.Plansubscription:StripeClient.Subscriptiontoken:StripeClient.Token
Example
{:ok, token} = StripeClient.Token.create(%{
"card[number]" => "4242-4242-4242-4242",
"card[exp_month]" => "11",
"card[exp_year]" => "2017",
"card[cvc]" => "123",
"card[name]" => "EXAMPLE PERSON"
})
{:ok, customer} = StripeClient.Customer.create(
email: "hello@example.com",
source: token.id
)