Best Elixir Stripe library available?

Hi, I am writing a Phoenix app where I need to integrate with Stripe. mainly for subscriptions and plans. Have you used any available open source Elixir Stripe library? What is your experience?

1 Like

Have a look at this:

You may also be interested in this:

3 Likes

Hi, I’ve had some success with Stripity Stripe (https://hex.pm/packages/stripity_stripe) to sign people up to subscription plans, and a bit of Stripe Connect to make charges on behalf of other users. Unfortunately it looks like I picked it a the time the library was going through a major re-write so whilst it works for me at the moment it’s on my list of things to reassess in the future. I do incoming webhook handling mostly manually, using the signatures or re-fetching the event directly using the API is also on my todo list for now.

I had to make a few tiny changes to the code at the time, but since their development’s moved on it’s not going to get merged back in so I’m a bit out on a limb now but none the less it works ok. It’s here: https://github.com/wardes/stripity_stripe/commits/wardes-cust-patch-1

So maybe worth seeing what their current version is like instead. They do all seem to have different approaches to wrapping the API and data structures.
Cheers.

3 Likes

We just managed without one. Stripe’s api is very clean and well documented. building and sending requests was not hard. e.g.

def create_a_charge(charge, token) do
  %{"object" => "customer", "id" => stripe_customer_id} = token
  data = %{
    amount: charge.amount,
    currency: "GBP",
    customer: stripe_customer_id,
    description: charge.description,
    metadata: charge.metadata,
  }

  request = request(:POST, "/v1/charges")
  |> set_authorization(:bearer, api_secret())
  |> set_header("idempotency-key", charge.transaction_id)
  |> accept(:json)
  |> send_form(data)

  handle_response(send_sync(request, api_host()))
end
12 Likes

FWIW: I emailed Stripe sometime ago and I’m happy to say they finally added Elixir as a language to the Community Libraries section:

11 Likes

I never mentioned here what send_sync was. Previously it was a cumbersome wrapper around HTTPoison. Now I am working on a Client library that takes full request objects and just handles sending them.
You can see it in this Pull Request. Currently looking for feedback.

1 Like

I agree with this. Stripe’s API is so well documented and clean that I had no problem implementing it on my own.

For me I only needed to implement a few endpoints, so it was easy enough.

1 Like