eileennoonan

eileennoonan

PinStripe is a “small development kit” for Elixir and Stripe based off of @wojtekmach’s article SDKs with Req: Stripe on the Dashbit blog.

That blog post is great for more senior programmers and people who have time to roll their own integration. But what about those who just want to say “boom, Stripe”?

It would be great if Stripe provided an official Elixir SDK, but they don’t. The community project Stripity Stripe attempts to fill that gap. It has worked great for many people for a long time, but since the Stripe API is so sprawling it’s been cumbersome for maintainers and new code hasn’t been merged in over a year. This can give newcomers pause.

PinStripe aspires to find a middle ground by providing a maintainable, minimalistic interface with a few conveniences that should cover 95% of use cases without needing to meticulously cover the entire Stripe SDK.

Features include:

  • Simple API Client built on Req with automatic ID prefix recognition
  • Webhook Handler DSL using Spark for clean, declarative webhook handling
  • Automatic Signature Verification for webhook security
  • Code Generators powered by Igniter for zero-config setup
  • Sync with Stripe to keep your local handlers in sync with your Stripe dashboard

Please note this library is still experimental! Tests are passing, igniter installation and mix tasks all seem to work! But community feedback and contributions are very welcome.

Kudos to @lawik for help with the name!

Showing Posts 1 to 10

lawik

lawik

Nerves Core Team

ThinStripe, PinStripe, RacingStripe, TigerCantChangeIts. So many naming options :stuck_out_tongue:

olivermt

olivermt

EarnedMyStripes

eileennoonan

eileennoonan OP

Oh I really love PinStripe!

Gonna wait to see if more suggestions roll in before I pull the trigger on that but that’s great. Fun, fashionable, rolls of the tongue, and yet also suggests professionalism.

lawik

lawik

Nerves Core Team

And also organized crime :smiley:

eileennoonan

eileennoonan OP

It is pretty gangster :smiling_face_with_sunglasses:

eileennoonan

eileennoonan OP

TinyElixirStripe has officially been renamed to PinStripe!

Kudos to @lawik for the Don Draper energy!

@AstonJ - is it possible to update the title of this post?

kevinschweikert

kevinschweikert

Done :wink:

eileennoonan

eileennoonan OP

Thank you! Is it also possible to edit the tags? I’d like a pin-stripe tag I can subscribe to :folded_hands:

eileennoonan

eileennoonan OP

PinStripe v0.2.2: Testing Utilities

PinStripe now includes handy testing utilities. This release adds two new modules.

PinStripe.Test.Mock provides high-level mocking helpers that wrap Req.Test:

test "reads a customer using stub_read" do
  Mock.stub_read("cus_123", %{"id" => "cus_123", "email" => "test@example.com"})

  {:ok, response} = Client.read("cus_123")
  assert response.body["email"] == "test@example.com"
end

PinStripe.Test.Fixtures leans on Stripe CLI to provide fixture generation:

test "creates a customer" do
  # Load/generate a customer fixture (use atoms for API resources)
  customer = PinStripe.Test.Fixtures.load(:customer)

  # Use with Req.Test
  Req.Test.stub(PinStripe, fn conn ->
    Req.Test.json(conn, customer)
  end)

  {:ok, response} = Client.create(:customers, %{email: "test@example.com"})
  assert response.body["object"] == "customer"
end

Fixture generation requires a Stripe test API Key (live keys are not allowed). Each unique generated fixture will create a record in your Stripe dev dashboard and a cached version in test/fixtures/stripe.

If/when you change your Stripe API version, you can run mix pin_stripe.sync_api_version to fetch the current version and clear all locally cached fixtures. Fixtures will then be regenerated the next time you run your tests.

asianfilm

asianfilm

I don’t use Stripe, but it looks like your library’s approach to webhook handling could be extracted as, or inspire, a more general solution.

Curious how Spark is involved. I’ll read through the webhook handling code in the Dashbit blog and then see how you evolved it here.

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews