Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe recurring/subscription billing best design/practices?

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:

  • http://railscasts.com/episodes/288-billing-with-stripe

Ofcourse the stripe documentation and api:

  • https://stripe.com/docs
  • https://stripe.com/docs/api

This little piece of code for webhooks/mailing

  • https://github.com/boucher/stripe-webhook-mailer/blob/master/mailer.rb
like image 747
hajpoj Avatar asked Apr 24 '12 04:04

hajpoj


2 Answers

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...

like image 144
cman77 Avatar answered Oct 17 '22 08:10

cman77


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.

like image 1
Benjamin Curtis Avatar answered Oct 17 '22 09:10

Benjamin Curtis