Stripe checkout

#17
Posted in General

adamlogic
adamlogic

@jeremysmithco In your latest podcast you mentioned almost but not quite using the nocheckout gem. I hadn't seen that before, and I love the approach.

Are you able to say more about why you didn't use it?

👍️

jeremysmithco
jeremysmithco

Hey @adamlogic, for sure! I didn't need the webhooks piece for launch, and there was enough indirection in the CheckoutSessionsController that I had trouble following the flow and figuring out how best to extend it with subclassing. So I ended up just copying that controller into Liminal and refactored/rewrote it into a style that is probably more procedural, but made more sense to my brain.

This is roughly the result:
https://gist.github.com/jeremysmithco/ff58f4324b975fa2b62afc510fa108bd

I added barebones StripeCustomer and StripeSubscription AR models to the app to hold the references to user's stripe customer and connected subscriptions. And after checkout, I assign the subscription to the space they create.

I'm not quite covering all edge cases here, so there may be some exceptions raised, but this got me going in an afternoon and has covered a couple sales so far!

❤️
2

adamlogic
adamlogic

That makes a lot of sense, and thanks so much for sharing the code snippet! I think we've overcomplicated our Stripe integration in Judoscale, and this is a great example of how it can be kept simple and lightweight.

🙌

jeremysmithco
jeremysmithco

Hey, sure thing Adam! :)

Log in to reply to this topic.

Log in

Topic Details

Status
Open
Participants
jeremysmithco adamlogic