#Ninja man

1 messages · Page 1 of 1 (latest)

velvet stormBOT
barren niche
#

Hi there

#

Hmm this doesn't sound right. You should be able to manage multiple Subscriptions from the Customer Portal if I remember correctly

flint raven
#

The product i subscibed to before is totally gone from the portal once i start another one

#

It just says: CURRENT PLAN

#

and shows the new subscripion

barren niche
#

Let's pause for a second

#

Are you trying to create a new Subscription from the Customer Portal?

#

Because that's not possible

#

You can only manage current Subscriptions

#

So what it sounds like is you are updating a current Subscription if you are doing this in the Customer Portal

flint raven
#

No.

I have created 2 products with a subscription.

I subscribe to the first product and then i see it in the customer portal.

Then i start a subscription for the other product, and now that is the only product i se in the customer pportal

barren niche
#

Okay can you give me an example Customer and a screenshot from the Customer Portal for what you are seeing?

flint raven
barren niche
#

Great and can you give me the Customer ID associated with that Portal Session?

flint raven
#

Very weird thing, in the "customers" section, it has 2 customers with the same email 🤔 So that would explain why this is happening. But how can this even be possible? I use the same email when i started to subcribe to both products?

barren niche
#

How are you creating the Subscriptions?

flint raven
#

By a payment link

barren niche
#

Yeah that's why

#

Payment Links have no Customer association

#

They are meant for one-to-many

#

So there is no authentication up front for return Customers

#

If you want to maintain a Customer here then you would use a Checkout Session

#

And pass the Customer ID to the Checkout Session for a return customer

flint raven
#

Ahhhhh okay, so how can i test this from the dashboard?

barren niche
#

Well you could just manually create a Customer in the Dashboard and then create two Subscriptions for that Customer via the Dashboard if you just want to test the Customer Portal

#

You need to write a little bit of code to test it through Checkout

flint raven
#

So this is what i have in my project, or do i need to add something more for it to be able for the return customer thing?

barren niche
#

So basically, look at the Customer ID that was created from the initial time that you completed the Checkout Sesssion

#

And pass that ID to the second Session you create

#

Then the new Subscription will be created for that same Customer

flint raven
#

hmmmm alright but this sounds like i need to store something on my side in a database 🤔 I would just want this to work without having to work with storing users data

barren niche
#

Yeah that's correct... you wold need an authentication flow when a customer visits your site to match them to a Customer ID. Which yes, requires a database.

#

Otherwise there is no way to know whether it is a new or returning customer

flint raven
#

ahhh damnit lol.. Well in this case i could just build out my own portal if i need to have auth and all that..

barren niche
#

I mean sure you could. But that would be a ton more work than using the Customer Portal

flint raven
#

But i mean like if i need to build out a auth flow, have database, have server, implement that on the frontend etc, that is what will take long time. Then when thats done i would just use stripe API to do al of those things which wouldnt be so hard i suppose

barren niche
#

Yeah we don't support an auth flow ourselves, unfortunately. So there isn't really another path here if you want to allow for Subscription management with multiple Subs.

flint raven
#

Alright yeah, i mean 1 easy way would be: Before you subscribe, you create an account with https://magic.link/ and store the account ID in mongo DB atlas. Now when you start the subscription you check if the user has any custmer ID in mongo DB, and if so, pass it to the checkout session.

This would take me like 1-2 hours to do and i use Next JS so i will have all this logic in the server.

Magic

Magic is the #1 user authentication and private key management solution for Web3 and Web2.

barren niche
#

Yep that would be a good flow

flint raven
#

Also if i do that, would it be an easy way to get what products the customer is subscriped to from stripe api? As i would save the customer ID in mongo

barren niche
#

Yep, there are a few ways to do that

#

Are you planning on using Webhooks?

flint raven
#

Nope i don't think so? I can use a simple fetch request

barren niche
flint raven
#

Ahhh i meant: I want to get all products the customer is subscribed to, to show what products the customer have already subscribed to in the web shop

barren niche
flint raven
#

Ahh cool so what would be the endpoint? I cant find it

barren niche
#

Yep it is the List subscriptions endpoint

#

See the API Reference link above

flint raven
#

Ah nice, so:

  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d limit=3```

Would be good to have a node js exampel lol
barren niche
#

There is a toggle in the right side of the reference where you can flip it to a Node example

#

So yeah you want: const subscriptions = await stripe.subscriptions.list({ customer: 'cus_xyz' });