Live data from Hacker News

Implementing API Billing with Stripe

daily.co

41–50 of 84 posts

Re: Implementing API Billing with Stripe

#41

Maybe noob questions, but how to do tests with stripe API? For example, how to write a test for plan upgrade? From what I remember there can be set testing env in stripe but the shortest subscription time was 1 day, so how to use it in automatic tests?

We disable live API interaction w/ stripe in our tests and use hardcoded response values. You can use a library to do this or patch the stripe sdk - depending on the language/framework you are using.

Re: Implementing API Billing with Stripe

#43

Maybe noob questions, but how to do tests with stripe API? For example, how to write a test for plan upgrade? From what I remember there can be set testing env in stripe but the shortest subscription time was 1 day, so how to use it in automatic tests?

Just create a stub with the possible responses.

Re: Implementing API Billing with Stripe

#44
post #16
post #8

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 meth…

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

> a third party payment processor as "one true source" seems suicidal

for small product/shop/site with no strong core competence in billing it may be wise versa..

Re: Implementing API Billing with Stripe

#45
post #42

I so wish Stripe would stop ignoring a number of countries and make their billing available there (Poland is an example). I am stuck with Braintree and it is not a happy ride.

Poland is currently in private beta. You can request invite here: https://stripe.com/global#PL

Re: Implementing API Billing with Stripe

#46
post #8

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 meth…

Couldn't agree more. Reading over it's tied to Stripe and their implementation, not even any sort of abstracted interfaces. Vendor lock-in isn't a good plan and to your point, make it easier to add another payment system when needed. Good choice

> Vendor lock-in isn't a good plan

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!

Re: Implementing API Billing with Stripe

#47
post #27

Earlier quoted context omitted.

I'm a Stripe fan, so my perspective on this is that Stripe has done an incredible job making "easy things easy," and a pretty good job making "hard things possible." 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…

You're right, their documentation is great and the API is nice to work with, but you are forced to do things their way. I was recently working with Billing and ran into a pretty big issue: A customer on a recurring plan upgrades to a more expensive plan. As long as the customer has a valid source on file, the upgrade is processed. Stripe's default is to adjust the payment to be collected and charge it on the next inv…

Why can't you just charge the card directly?

Re: Implementing API Billing with Stripe

#48
post #20

Earlier quoted context omitted.

Yeah, I definitely feel your pain regarding iterating on plans and features. 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…

Agreed, making the plans hard to modify definitely makes sense, but then I feel like I need another abstraction on top of Stripe. Have you come across any good ways for handling this?

No, haven't seen anything. Everything looks like a hammer, of course, but to me this just feels like a general software engineering thing, if that makes sense -- building an abstraction on top of a library service. Our plan is to evolve the plans literal in our code into this abstraction (it already kind of is). Next step is probably to add something a little like feature flags, but we're still thinking this through.

Re: Implementing API Billing with Stripe

#49

Earlier quoted context omitted.

Couldn't agree more. Reading over it's tied to Stripe and their implementation, not even any sort of abstracted interfaces. Vendor lock-in isn't a good plan and to your point, make it easier to add another payment system when needed. Good choice

> Vendor lock-in isn't a good plan 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 c…

I think it really depends on the situation. Low level functionality (eg payments api) is more generic than high level functionality (billing cycles, dashboards, handling failed payments, etc) and therefore more likely to have a solution which will completely solve your problem.

Re: Implementing API Billing with Stripe

#50
post #27

Earlier quoted context omitted.

I'm a Stripe fan, so my perspective on this is that Stripe has done an incredible job making "easy things easy," and a pretty good job making "hard things possible." 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…

You're right, their documentation is great and the API is nice to work with, but you are forced to do things their way. I was recently working with Billing and ran into a pretty big issue: A customer on a recurring plan upgrades to a more expensive plan. As long as the customer has a valid source on file, the upgrade is processed. Stripe's default is to adjust the payment to be collected and charge it on the next inv…

Our experience is that manual invoices are charged right away. I wonder what's different about our setups? The only thing I can think of off the top of my head is webhooks that aren't responding, which would delay the invoice closing. But I think that would make the delay 72 hours, rather than 24.
Post reply on HN