Coding Bits
April 11th, 2024

Moan-routine: Stripe Prices

Moan-routine

I love coding and anything computers. I've spent, and continue to spend, a significant amount of my life writing code. And on the whole, it's been a magical experience.

But not always.

Sometimes I encounter something that makes me wonder why? Why was that designed that way? Why doesn't it work? Why couldn't this be easier? You encounter something that blocks you or puzzles you, maybe even questions how anything in computers can work at all. You've got things to do, and you try your best to work around the problem. Sometimes you succeed. Most times you get blocked and need to find some other way to fix it. And so the frustration builds, with no easy way to dissipate it.

Well, this is my attempt to do just that. I need a place to write these somethings down, not least to make me feel better. To air thy grievance is to start the healing process. They say that "a moan begun is half done" after all. Well, okay, no-one has ever said that. But maybe we should. We may not have the power or energy to change things, or even to find out why things the way they are, but by God, we can make sure others hear about it.

So enjoy these "moan-routines". Or don't. Honestly, it's totally up to you. 🙂  P.S. The name moan-routine is a play on go-routine, a concept in Go.

Today's Moan


We'll start the moans with something that saved my bacon today: which is Stripe prices. Actually, what saved me was something that we didn't do with Stripe prices, which was archive them. For you see, archiving a price in Stripe makes it effectively unusable.

This is arguably a good thing: you change a price, you don't want anyone using the old one. Well, I say "change"; what I actually mean is replace. You can't "change" a price directly in Stripe, say from $10 to $12. Instead, you create a new $12 price which will replace the old $10 one. Any new subscriptions you create will use the $12 one from now on, and ideally you'd never use that $10 price ever again.

So you want to archive the $10 price. But there's a problem: you've got all these customers with subscriptions still paying the old $10 price. Stripe doesn't provide an easy way to move customers over to the new $12 one: this is something you have to do yourself. And you may not want to do that anyway. You may want to send your customers an email informing them about the price change; letting them know they have 30 days or whatever to be ready for it.

And until you actually go in and change their subscriptions, they'll be paying this old $10 price. And the minute you archive that $10 price, it becomes radioactive. Any attempt to do anything with it, or any subscription using it, will resolve in an error.

Which gets to the moan: why do this for archive prices? I would've thought that Stripe was aware that subscriptions with old price was a thing. Am I to keep this old price active for as long as those accounts are still using it? Even if no-one else will ever get that price again? I wouldn't be able to archive anything at all until them. And it may be a while before accounts do get changed. Think beta users grandfathered in-to a lower rate.

So I'd like Stripe to change this. Either get rid of the pitfalls around archive prices, or make it easy to port subscriptions over to the new price in some way (subscription schedules are a whole other moan). Instead, I stuck keeping old prices active because I'm afraid that archiving them will things. This clutters up the dashboard and introduce traps like creating a subscription with an old price.

Look, prices change. It's just the way of the world. And if Stripe is going to make prices effectively immutable, it would be helpful for us to make it easy to mark a price as "don't use this for new stuff but keep the old staff effectively unchanged." I expected this what archiving a price would be. Turns out I was wrong.