Implementing API Billing with Stripe
daily.co
daily.co
A good first question to ask about a data model is, "where does the data live?"
In general, we think it's a good idea to make Stripe the "one true source" for as much of your customer and billing data as possible.
Our company went the opposite way, we have our own model and we abstract stripe as a payment option supported. Recently with the same model we were able to add Paypal and other country specific payment methods.> In general, we think it's a good idea to make Stripe the "one true source" for as much of your customer and billing data as possible.
Customer and billing data are mission critical and as such having a third party payment processor as "one true source" seems suicidal, frankly.
We have Stripe handle the actual payments and nothing else.
Like most things in engineering, you can move the tradeoffs around to optimize for different use cases.
The "one true source" approach allows you to avoid writing logic to keep data in sync between your customer records and Stripe's systems. It also implicitly pushes you to think about how to store enough data in Stripe that the Stripe dashboards become your interactive way of managing and viewing customers. Those are both big enough wins that I do think it's the right approach to take for lots of folks who are just spinning up charging for a product, and for relatively simple recurring revenue use cases.
If you need to use multiple payment processors, or you need to have a complex view of your customer and lifecycle, then it's not the right approach.
Engineering is one thing but it must never trump strategic business thinking. Sometimes the cleverer engineering option is a business death trap.
Any solution that puts your balls into someone else's hands is suicidal.
for small product/shop/site with no strong core competence in billing it may be wise versa..
I'll take vendor lockin over being locked into a bunch of homebrew garbage that some former developer managed to sucker the entire company into creating because of "vendor lockin". So many times engineers come up with fears about "vendor lockin" and forget how easy it is to lock the company into an unsupported, half-baked homebuilt product that has nothing to do with the company's core business.
I've seen it with reporting and analytics, I've seen it with frameworks, I've seen it with deployment systems, build systems and configuration management systems. I've seen it with payment systems, crappy half-baked hybrid cloud implementations, database provisioning systems and more. All in the name of "avoid vendor lock-in".
Being locked into your own garbage-tier product that has nothing to do with your business sucks. If stripe kicks the bucket, you won't be the only person in that boat and there will be a path forward. Know what is worse? How about when the only developer who can support your crappy half-baked payment system leaves the company? Which stack overflow article will show how to get out of that mess? Talk about vendor lockin! You locked yourself into your own mess!
Stripe might leave the servers online in a half broken state for a few weeks, but they will not answer tickets or phone calls about critical issues if they've decided to can a product.
https://www.pymnts.com/news/partnerships-acquisitions/2018/s...
Eventually, when they decided to streamline their payment and billing operations on their own tools, due to historical data on Stripe servers, they built a custom presentation layer on top of Stripe APIs. They ended up spending pretty much the same time and effort as they would have done by managing the business flows on their own systems and storing all the data on their DBs and using Stripe just for processing payments. Worse yet, they still depend on Stripe for stuff like reporting.
I'm encouraged by your success of this model. I'm currently struggling with the 'billing system as source of truth' model.
We built the abstraction around the requirements for our business model, although after some iterations it became similar to the model used by Stripe (customers, sources, plans...). We support saved payment options and on them we do recurring billing and one-stop payments.
A user for us can have multiple sources and a source is a saved external card or payment method, in the case of Stripe a source is a combination of the Stripe customer id and Stripe source token.
Most payment gateways support some kind of token that represents a saved card or similar on which you can do a charge.
My last company processed >$100MM/yr of tshirts, split between Stripe and PayPal. Stripe was wonderful; PayPal was hell. It required a lot of engineering effort to build and maintain the system, even as simple purchases (no subscriptions). But if you're selling impulse buys online, PayPal is required.
Current company is B2B SaaS, smaller team, and I said "no freaking way" to PayPal. Built the subscription system around Stripe. Lack of PayPal has probably cost a few sales but our pace of development is much faster, and the new features we're able to roll out (like a referral program) move the needle more.
If you go the "straddle multiple billing systems" route, expect to dedicate one fulltime engineer to billing for the life of the project. That may be reasonable for a team of 10, but it's death for a team of 2.
Paddle looks like the service I need on the long run:
I can only imagine the elevated pain of abstracting across multiple subscription systems. Ouch.
I scan recent invoice history periodically to keep Credits up to date. Payouts are via PayPal masspay. Spends (using credit balance to offset their SaaS bill) are created on the invoice.created webhook, which adds a corresponding negative line item to the invoice.
I considered doing everything in Stripe - you can add pending invoice items instead of credits and payouts, then 'spends' are just the natural processing of bills - but it would have been very difficult to get analytics (eg, total outstanding payout liability).
It's really nice to be in control of the invoicing, without having to implement it ourselves, and of course not depend on only one provider. It also has support for taxes with plugins.
The article is completely missing any mention of tax, be it sales tax or VAT. This is my biggest complaint of Stripe.
For a lot of us, we live in countries where we simply _have_ to start collecting and remitting tax from the very first customer.
For example Braintree is good in that sense: https://developers.braintreepayments.com/guides/recurring-bi...
I know it's not a payment gateway's responsibility, but some further handholding on tax and VAT, invoicing issues would be handy.
Stripe has indicated that they're working on it, but no timeline yet: https://www.indiehackers.com/forum/stripe-onboarding-integra...
Small disclaimer here, I was implementing Stripe Billing, not Stripe Payments. The Billing suite is a lot more complicated compared to the Payment suite.
Nonetheless I took me a really long time to figure out all the special cases such as: renewing a card, switching to a different payment method, up/downgrading a plan, multiple currencies, etc.
At some point you'll be almost finished with the integration and only then do you find the need to implement webhooks for certain asynchronous payment methods (especially needed when you are in Europe). Once implemented, webhooks give you endless new workflows to handle, and many race conditions between your frontend and backend. So it constantly feels like one step forward and two steps back.
I don't think it's Stripe's fault though that my implementation took so long. Stripe's documentation is pretty solid. It's just that billing touches just about every part of your stack (frontend, backend, database, testing, tooling, accounting) and it's painful if you find out you have a bug that caused you to over/undercharge a customer. You need to take your time to get it right.
[0] shameless plug: https://www.mailhardener.com
There are surprising edge cases that crop up. For example, canceling a subscription and then restarting it is actually somewhat painful.
But yes, their documentation is stellar!
There are things I'd love to see added to the Stripe Billing APIs (some of which I mentioned in the article), but I have a really healthy respect for the amount of good work that's gone into the design of an API that, as you say, touches just about every part of a potential customer/payments workflow.
Stripe's API has consistent naming, a clean design of the core data objects, consistent data formatting and request patterns, good dashboard tools for seeing what's happened in requests and webhooks, and great documentation. All of which are non-trivial, and basically none of which any of the other "name brand" APIs I've used in the last year or so do. :-)
For example: if you change the default payment method of a Customer, the default payment method of all this customer's Subscriptions is not changed. The documentation is not clear about that.
Also, if you remove a payment method from a customer, the subscriptions seems unaffected. If you're not careful you might still end up charging this customers card when the subscription auto-renews.
I'm still a fan of Stripe though. I have my fair share of experience implementing other PSP's and they were an unbelievable PITA. As far is my experience goes, Stripe is miles ahead of their (european) competitors.
name
account_holder_name
first_name + last_name
And four different structures for addresses: address_line1
address.line1
legal_entity.line1 (a personal address, old as of new version)
legal_entity.personal_address.line1 (personal address when the prior is a business, old as of new version)[0] https://stripe.com/docs/billing/invoices/subscription#genera...
It's one of those things where once you're already "in the know", the simple use cases are in fact simple to implement. But sifting through the massive and complex API set, with outdated and partial documentation/examples all over the internet, it's very difficult to get into. Every single example starts with "this is not production ready..." And the official docs are difficult to piece together into an "E2E best practices" setup.
Not saying there is a better solution, just that as a competent dev with a simple use case, I found Stripe overly complex.
- Stripe Checkout (https://stripe.com/docs/checkout) vs implementing your custom credit card form and using the API directly (https://stripe.com/docs/charges)
- Standard, Express, Custom options for Stripe Connect (e.g. take money from someone and give it to someone else): https://stripe.com/docs/connect/accounts
We are currently working on a new version of our Checkout product[0] and would love feedback. We are working on making the simplest drop-in integration to get up and running on Stripe, and we support Stripe Billing! Send me any thoughts you have (matt at stripe).
I’m curious why there is an even number of cents requirement on stripe’s end?
I’m also not a fan of the quantity 1 line item rollup, although I understand the workaround. For the customer receiving the invoice, it makes it harder to breakdown the invoice in an automated way, since the detail info is moved to a text block.
Likely to prevent floating point screwups.
At my last startup, we used our DB as the single source of truth. I think using Stripe as the source of truth like you suggest would have alleviated a lot of our issues keeping things in sync.
My biggest pain point though was around managing features on the client side. We had a bunch of different plans from lots of iterating (and customers coming from different sources that had similar but slightly different experiences), so it became hard to decide "should I allow the user to see this feature/do this action?". I haven't yet seen a great way to handle that. The plans literal here looks like a great starting point though!
Stripe explicitly makes it hard to modify most aspects of Stripe-level plans after they are created, which definitely is the right call because user expectations about recurring payments need to remain stable. But that means you have to build your own plan->feature mapping to manage a proliferation of plans, if you do any experimenting with or evolution of your pricing.
One big win you get with Billing, though, is automatic generation of invoices each subscription period. It’s nice not to have to write that code, and the automatic invoices tie in nicely to a few other things Stripe can do better than we can, like automatic retries of payments that fail.
A lot of things were abstracted away and i got a much better admin panel and can change payment processors anytime.
I've researched something like this some months ago and couldn't find anything that had the quality and features we needed. I'm sure lots of companies would pay for a solution like this (my company included).
Would you be open to sharing your thoughts on how you'd like something like this to work? I might be interested in giving it a shot. My email address is hello@wyatt.engineer
https://userappstore.com/public/2-powered-by-dashboard.png
https://github.com/userappstore/dashboard
I am putting the finishing polish and fixes on a platform and marketplace using this software, just working on the final integration tests that verify it all works together.
https://web.archive.org/web/20181206180323/https://plasso.co...
I don't understand how this is supposed to work when you're sending in aggregated data. How can you know before the period has ended?
- Stripe's list of prohibited businesses is much larger than PayPal's. They are not business-friendly.
- PayPal is available in over 200 countries. You can accept payments in many countries Stripe is not available in.
- On PayPal you can start accepting payments immediately, no need to submit complex business docs.
- PayPal is easier to setup (Paypal.me link, buttons, send via email etc.) and has lower fees for small transactions.
- People might be more comfortable buying from a relatively unknown site when they are using trusted 3rd party provider like PayPal.