#ricky-u_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1414960124081995887
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- ricky-u_api, 16 minutes ago, 22 messages
Here is my previous chat on this subject just a few moments ago, I am still unabel to find a workaround or solutions to what seems to be a fairly common scenario. #dev-help message
Hi there, looking at this now
Thanks nobs.
Can you share the request you made to create the checkout session?
the code?
const session = await s.checkout.sessions.create(sessionParams); return c.json({clientSecret: session.client_secret }, 200);
It returns the secret, which then on my frontend app, i use to mount the checkout, but at the same times, it calling customers create, which i am not calling -- this is the point i am confused about -- from the last chat ,the dev seem to think i was surely calling that, but i am not. only sessions.create.. the docs say in a roundabout way that it will create the customer by itself.
I mean the request ID from your logs, so I can see the exact parameters you're sending
Got it. In this request, you're passing in a customer ID that you created earlier. If you don't pass in a customer parameter, then the Checkout Session will create it later, which sounds like the behavior you want
If blank for Checkout Sessions in subscription mode or with customer_creation set as always in payment mode, Checkout will create a new Customer object based on information provided during the payment flow.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
let me see, one moment,
When you mentioned 'created earlier' i didn't. My guess is that as you mentioned it was done for me. I do pass in the customer_email which is just pre-filled in the form, but it wasnt created earlier in stripe. its a new user. -- Yes i want to create the customer account and the subscription simultaneously .. I can acheiuve this if i don't pass the customer email or id, but in this case stripe will create a Duplicate account with the same customer email -- so in order to prevent this the i ask the user ahead of time for their new user email, then i pass this to the backend with the price id to create the checkout session - the problem with this is as we discussed, it creates the custoemr first, then send me the session token , then it mounts it.. and IF the customer fails to complete the form, i am left with a ghost customer in stripe.
so it seems it is by design -- hence do i have a workaround for embedded checkout not creating a new customer but WITH a prefilled customer email? So in the case where a customer exisits, stripe will attach the subcription to that customer. - that was my main goal.
I can acheiuve this if i don't pass the customer email or id, but in this case stripe will create a Duplicate account with the same customer email -- so in order to prevent this the i ask the user ahead of time for their new user email
If you have the user's email, you can make a request to see if that user already exists as one of your customers. If it does, then you can pass that customer's ID in the Checkout Session create request. If it doesn't, then the Checkout Session will create the customer for you. Does this work for your use case?
Yes, but if there is no customer in stripe, there are still 1 problem, which is that I cant prefil the embed with the users email. which is what i need to do.
so either way i need the stripe embed to be prefilled, and a) dont create the customer if none exists and create it only with the subcription and payment method which the embed will do. b) if the customer exits, add the subscription to them which does work since the customer_email is passed along.. --- i really wonder why though i can just embed with an prefill email, and not have the customer created. ---
In that case, if you just want to prefill the email address, you can pass in the customer_email parameter
If provided, this value will be used when the Customer object is created. If not provided, customers will be asked to enter their email address. Use this parameter to prefill customer data if you already have an email on file. To access information about the customer once a session is complete, use the customer field.
This will create a Stripe customer, but only afterwards if the Checkout Session is completed. So this should fit your use case
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
When is the checkout session compelte, thought, isnt it compelte after server returns the secret, but before the embed is mounted?
Sorry, should have been more clear - Checkout will create a new Customer object based on information provided during the payment flow, not before it is embedded.
information provided in the payment flow, thats waht the docs say and left me equally confused...
the payment flow is stripe.checkout.sessions.create(sessionParams)
now in the session params, i am only passing in the customer_email -- but still the customer is created.
Can you share the customer ID for this specific example?
sure.
just a sec
cus_T1VFnXPL04nDEO
this was created when i used stripe.checkout.sessions.create(sessionParams) and i only passed in customer_email.
the embed is still on the frontend, and not submitted, however the custoer has already been created.
is this a thing: "customer_creation": "if_required", !?
customer_creation": "if_required" is only for when a customer id is passed in.
This customer was not created by the Checkout Session, you created this explicitly:
https://dashboard.stripe.com/logs/req_grl4OgRezCkNwZ
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Do you mean in my code i have 'stripe.customers.create' somewhere?
yes
just a moment...
another moment...
unbeliveable.. i am.
okay -- let me check again.
Hi there, I'll be taking over from my colleague. Let me catch up.
so nobs was right, i was creating a new customer before creation the checkout session .
but now the problem arrises, where if i have an exiting customer_email, and one already exits on stripe, stripe will create another user with teh same email,, i guess i should also find out stripe id and pass that in in the checkout session
Yes, that is the best approach. You can find the Customer based on their e-mail [0][1]
[0] https://docs.stripe.com/api/customers/search
[1] https://docs.stripe.com/search#query-fields-for-customers
would this work :
const customers = await stripe.customers.list({
email: body.email
limit: 1,
});
that should only return customers with the same email correct?