#kirenhunocoly_api

1 messages · Page 1 of 1 (latest)

silk marshBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1261252264862154804

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

urban sentinel
#

👋 happy to help

#

would you mind elaborating more

dusky siren
#

Sure ,Wait a moment pls

urban sentinel
#

take your time

dusky siren
#

When we create a checkout session, we need to define the id of our customer, and we need Stripe to automatically create a customer for the new user id. How should we configure the parameters?

#

We use Stripe for organizational subscriptions on our SAAS platform, one Stripe customer corresponds to one organization on our SAAS platform. How should we achieve this?

urban sentinel
dusky siren
#

I‘ve checked this document

#

I didn't find a parameter to achieve my goul

#

goal

#

Oh, you mean this one [client_reference_id]?

urban sentinel
#

yes

dusky siren
#

Here's what I expect: When a new user subscribes, Stripe creates a new user based on this parameter, and Stripe may maintain a Stripe customer id; When you subscribe again, the client reference id is the same, and the Stripe automatically corresponds to the Stripe customer id that has been created. Am I getting this right?

urban sentinel
#

that's not possible automatically with Checkout Sessions

#

what you need to do is to find the customer before creating the Checkout Session and if it exists pass it to the Checkout Session upon creation

dusky siren
#

ok, I will explain my requirements separately. My requirements are as follows: We have multiple organizations with multiple users. Each user in the organization may make a purchase, but the service purchased by any user is bound to the organization. Since a Stripe customer corresponds to a SAAS organization, we use the Stripe customer portal for organizational subscription management.

#

So your suggestion is that we need to check before we create a session, does the current organization have a customer id created in Stripe?

dusky siren
#

Could you pls provide a link of the document?

urban sentinel
#

there is no specific doc about this

#

but I guess I could summarize the steps for you
1- Search for a customer that has a metadata.reference_id = x
https://docs.stripe.com/api/customers/search
2.a- if customer exists create a Checkout Session and pass the customer Id https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-customer
2.b- else you create the Checkout Session and pass the client_reference_id
3. using webhooks listen to the checkout.session.completed event
4. If the checkout session has a client_reference_id update the newly created customer's metadata.reference_id with the client_reference_id

dusky siren
#

I wanna know this parameter's function

#

customer-creation

silk marshBOT
unreal badger
#

Hey! Taking over for my colleague. What is not clear exactly ?

dusky siren
unreal badger
#

No, I don't see other option honestly...