How do you implement subscription payment in SaaS?

24 points by stealthmodeclan ↗ HN
I've never seen a clean way to implement subscription in a SaaS product. Most apps use glue script + stripe.

How do you do it?

7 comments

[ 4.3 ms ] story [ 19.6 ms ] thread
Have a subscriptions table with a paid_through date column, a payments table for records, and a daily script that selects rows with a paid_through less than or equal to the current date, and makes a charge for those subscriptions. That script implements all the pricing plans, coupons, discounts, dunning mails, etc. I've done that for a half dozen businesses, with millions of dollars in revenue. Is this the "glue script" that isn't clean enough? It doesn't matter what payment gateway/service you use so long as they've got an API for you to store and charge cards; I prefer Spreedly as a wrapper that lets you change payment providers at will.
I second this. Just do it yourself with a cron job. It can be really simple in the beginning, and very flexible later when you need it. As your business grows, your charging can quickly get complicated. Think custom subscriptions with conditional coupons, multi-currency, custom pro-rating, special discounts with specific conditions. With your own charging solution, you can do all these with ease. But if you off-load billing and charging schedule to an external service (and use webhooks or reverse APIs), you will quickly discover you're pretty limited.
Laravel's cashier does a pretty good job at it. I think it hardly takes 5 to 10 minutes to integrate and you can have multiple integrations like Stripe, Braintree, etc with Access control, coupons, etc..
What don't you find 'clean' about the Stripe integration?
Stripe will handle the subscription plans, the period (monthly, annual, etc) invoicing, the credit card security, the payment forms, discounts and pretty much everything you need to run subscription payments. It took me less than 1 day to implement using their payment forms.

There are many stripe templates on github that help you get started in almost any framework/language.

If you build your webhook correctly, you don't have to build any backend payment management, you can manage directly in the stripe dashboard and it will update your customer records directly through the webhook.

I've just this week built stripe into my app. I use CRA with an ExpressJS server to communicate with the Stripe API. I use Stripe to manage everything, the only part I needed to implement was the webhook endpoint for cancelled subscriptions so I can disable the account on my end and another endpoint I call from the frontend to create the specific plan the user picked.