#kirenhunocoly_api
1 messages · Page 1 of 1 (latest)
👋 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.
Sure ,Wait a moment pls
take your time
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?
you can pass the https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-client_reference_id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I‘ve checked this document
I didn't find a parameter to achieve my goul
goal
Oh, you mean this one [client_reference_id]?
yes
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?
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
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?
yes correct
Could you pls provide a link of the document?
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hey! Taking over for my colleague. What is not clear exactly ?
Too complex. We don't have another solution, do we?
No, I don't see other option honestly...