Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/blakewilliams/elixir-stripe

A work in progress wrapper around the Stripe API in Elixir.
https://github.com/blakewilliams/elixir-stripe

Last synced: 16 days ago
JSON representation

A work in progress wrapper around the Stripe API in Elixir.

Awesome Lists containing this project

README

        

# Stripe
A work in progress for using Elixir with the Stripe API.

Since this is only a thing wrapper around Stripe everything passed to and returned by
Stripe should be a HashDict.

## Usage
Before you do anything you have to set your API token. If you're running the tests
(they actually hit the API at the moment) you need to set an environment variable called
`STRIPE_SECRET_KEY` before you run the tests. You can also just modify the test_helper and
pass the key there.

```elixir
Stripe.set_secret("Your Secret Here")
```

### Creating a Customer

```elixir
attrs = HashDict.new([
email: '[email protected]',
description: 'New user'
])

{:ok, customer} = Stripe.Customer.create(attrs)
IO.puts HashDict.get(customer, "email") # [email protected]
```

### Updating a Customer

```elixir
attrs = HashDict.new([
email: '[email protected]',
description: 'Updated description'
])

{:ok, customer} = Stripe.Customer.update("cus_3aDRxsZH8sTV6F", attrs)
```

### Deleting a Customer

```elixir
id = "cus_3aDRxsZH8sTV6F"
{:ok, message} = Stripe.Customer.delete(id)
```

### Retrieving a Customer

```elixir
id = "cus_3aDRxsZH8sTV6F"
{:ok, customer} = Stripe.Customer.retrieve(id)
```

### Listing Customers

```elixir
{:ok, customers} = Stripe.Customer.list
customers = HashDict.get(customers, "data")

Enum.each customers, fn customer ->
IO.puts HashDict.get(customer, "id")
end
```

All implemented API methods use the same names as above when applicable except
Cards, Discounts, and Subscriptions which each take a `customer_id` as their
first argument.

## Todo

* Document existing code

The following parts of the API need to be implemented

* ~~Charges~~
* ~~Customers~~
* ~~Cards~~
* Subscriptions
* ~~Plans~~
* Coupons
* Discounts
* Invoices
* Invoice Items
* Disputes
* Transfers
* Recipients
* Application Fees
* Account
* Balance
* Events
* ~~Tokens~~