stripe.com
Instant, zero-integration SaaS billing with Clerk + Stripe
Excerpt
So let’s jump into it. This is a really cool quote: “It took weeks to integrate billing with Clerk’s auth.” That sounds horrible, right? Like, why would we be promoting this as how great Clerk Billing is? Well, that’s because that’s what customers said to us in the past. They said, “You know what, Clerk is awesome, but it’s really hard to integrate billing.” And so we said, “That’s a good idea. Why don’t we build something to solve that?” So some of the things that they said to us was that writing code to sync webhooks is difficult. If anyone’s ever built a SaaS integration before, you know that can be tough and no fun. There’s a bunch of downsides to doing this yourself. Mostly it’s just pure frustration and pain, right? So what we wanted to do is build a solution that really takes minutes and takes advantage of the whole Clerk ecosystem. No webhooks necessary. So if you’re writing code and you’re building an app, you don’t have to build in any code to sync webhooks. … ... This is how Clerk knows, “Hey, here’s how we’re going to authenticate you and know which app you are trying to run here.” ... So what we could do is something like this, where we say, “has Platinum” or “has Gold.” And this would do it, right? I would be able to save this, and I’d be able to see that I have access to that special message. But this isn’t maintainable. You don’t want to keep adding a bunch of conditionals. So what can you do? Well, it’s pretty common when you’re building an app to build in this concept of features, where you could have a basic plan that has a list of features, and the pro plan has that same but more, right? … And so this is more like what you would actually build yourself, right? You’ve got a bunch of features. And so I’m still not able to access this thing. So let’s fix that. So instead of looking for a plan, let’s look for a feature. Let’s look for Widgets because, if you remember, both the Gold plan and the Platinum have access to Widgets. So I just save that and look at that. Now I have access again. And so this is a way easier, way, more maintainable way to control access to your app using Features. … Boom, got the environment keys changed. ... So orgs are now turned on. So if I go back here, well, what’s different? Well, there’s really nothing different. I have my user profile management stuff. So how can we make this good? ... And that would work. But again, that’s not super maintainable. I have access again, but it’s not maintainable. So what can we do here, right? Well, we could use the plan features, as I showed you before, but there’s something else with orgs, right? Typically, when you do RBAC, you have a role, and then you add permissions to it. … And so you can imagine in your own apps, as you build out a much deeper integration, how simple and easy this can be to set up. ... And what we’re doing right here is we’re giving Clerk—that’s us, that’s those people—we’re giving Clerk all the drudgery, the stuff that we don’t want to deal with, to Clerk, and Clerk is making it super easy for us to do. So that’s the end of my demo.