I'm coming off putting together my first site with stripe, but I feel like I could have designed my stripe integration much better than I had. The main issues that I came across were, how do I maintain the state of the stripe account (trialing and past due etc) what are the important webhooks (and the best ways to deal with all the events), and how much data should i be duplicating in my database, and how much should i just pull from Stripe database.
Would love to throw some ideas around on what would be best. For reference I developed my site in Ruby on rails, deployed to heroku, used send grid heroku add on to send email notifications about bills, late payments, etc.
Also for those using stripe on RoR here are some good resources that I used (though I haven't found one that really covers recurring/subscription billing with stripe):
RailsCast:
Ofcourse the stripe documentation and api:
This little piece of code for webhooks/mailing
With regards to duplication - I chose to only store the CustomerKey on my User records locally. Everything else, Invoices, Transactions, etc is all stored in Stripe. IMO best not to attempt to keep parity between both systems - at best you'll have duplicate data, at worst, you'll cause all kinds of headaches by not being in sync...
The SaaS Rails Kit (that I created) integrates with stripe by just storing the card info with stripe (not setting up a recurring charge), getting back the token, then billing the token with a daily cron job when people's accounts come due.
A couple of benefits to this approach include not having to worry about webhooks / keeping the two systems in sync and being able to do metered billing in addition to a flat monthly fee.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With