#max

1 messages ยท Page 1 of 1 (latest)

turbid umbraBOT
halcyon pollen
#

Good question. Is the free plan an option that they can choose in the Checkout Session? If not, can you tell me how a user might have multiple of them here?

solemn elbow
#

When the user creates a new environment, they choose a plan on my end, which in turn creates a checkout session for that environment. They pay and all is fine.
Later the user can up-/downgrade using the Customer portal, which is where the issue comes in: I want to allow the user to downgrade to the free plan if no other environment is on the free plan, but disallow them if another one is currently using the free one.

halcyon pollen
#

How are these environments differentiated in Stripe? Are they entirely different products or are they the same products but with different metadata on the subscription or something?

solemn elbow
#

I hope I'm making sense ๐Ÿ˜…

dawn scarab
#

Hi there ๐Ÿ‘‹ taking over for @halcyon pollen

Give me a few minutes to get caught up.

#

How are you currently accounting for duplicate customers? Do you accept a phone number and check it against a database? Or something else?

solemn elbow
#

As of right now, I'm not (besides duplicate emails), however it's extremely annoying for someone to possess multiple accounts and phone verification is planned for the near future

dawn scarab
#

I see. Yeah, this is one of those use-cases where having a phone number on file is really useful.

Do you sync your Stripe data with a database at all?

solemn elbow
#

Absolutely, all customers are also on my local database, just as their environments

#

Or rather anything that's actually environment related is stored on my local database (such as name, run options and plan for quick access) together with it's ID and stripe ID.
That way I just query the Stripe API whenever I need something that's specifically there for billing

dawn scarab
#

The only thing I can think of aside from phone verification, is running a check against your database for as much customer info as possible before you create new subscriptions or upgrade/downgrade subscriptions.

solemn elbow
#

Well, it's not exactly my goal to prevent people from having multiple accounts right now (although that's also being worked on), I just need to have a way to only allow one subscription of the free plan per stripe customer, so that they can't have 2 subscriptions on the free plan.

#

Specifically in a way that works with the customer portal, since I'm using that for handling up/downgrades

dawn scarab
#

Wait, so the Customer Portal doesn't allow the customer to create new Subscriptions I don't think, they would have to be doing that via Checkout. Are you putting the page that creates a Checkout Session, behind a custom login portal? Or can anyone just go directly to the Checkout page from your website without registering?

solemn elbow
#

I think I explained myself kind of weirdly, so stand by, I'm rewriting my description, maybe record a video

solemn elbow
#

Ok, so imagine this:
A customer has 2 subscriptions, like this:
https://3001.catgirl.host/i/btkt5sgc.png
Now they go and update their plan to be the starter plan like this
https://3001.catgirl.host/i/2jvbf2om.png
https://3001.catgirl.host/i/szz7p06h.png
This is how it should work.
However, when the customer should not be able to downgrade the other subscription to the free plan as well, meaning that them having more than one subscription set to the free plan should be impossible
https://3001.catgirl.host/i/6ms5kdjo.png

#

Also excuse the German, I got no clue how to set the customer portal to English on the client

dawn scarab
#

So you won't be able to add that logic to the Customer Portal. If you give them the option to downgrade, and they already have a free tier subscription, then they will always be able to use that workaround to have multiple free tier subscriptions.

There are 2 ways you could fix this:
(1) listen for the customer.subscription.updated event and check to see if the Customer has multiple free tier subscriptions, or
(2) make sure each customer only ever has one subscription at a time by always sending them to the Customer Portal to upgrade (e.g. do not create multiple subscriptions for customers)

solemn elbow
#

Hm, alrighty then, custom solution time

#

(also, general note, multiple subscription are intentional, not side effects)

dawn scarab
# solemn elbow (also, general note, multiple subscription are intentional, not side effects)

Ahhh, okay. That makes sense. So yeah, I think the webhook solution would be an ideal one, since you can just cancel the customer's free-tier subscription once the customer.subscription.updated fires. It fires whenever a customer upgrades/downgrades a subscription, so you can essentially make sure your webhook handler is setup to do that and whatever else you want to happen at the end of this scenario

solemn elbow
#

Alright, thanks for the help, I'll go and do that