#JCoDog - Checkout Customer Creation
1 messages ยท Page 1 of 1 (latest)
Hello! It depends on the Checkout Session's configuration. A Customer may not be created at all. If you want to be sure you're accounting for all Customer creation events you should listen for customer.created: https://stripe.com/docs/api/events/types#event_types-customer.created
Yes the issue is that I need the user's ID from their session that is only available in the checkout creation stage for obvious reasons not carried over to the webhook page as that is not configured to take log ins. So is there no way to get the customer ID from the checkout creation? Therefore do I have to keep updating the customer DB when they are sent to the success page?
Checkout Sessions have a customer property: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer
Have you tried listening for checkout.session.complete events and getting the customer from there? https://stripe.com/docs/api/events/types#event_types-checkout.session.completed
That is what I am doing. The issue was I need to get their user account ID from my customer database on the retrieval of that event.
I fixed it by adding new customers to my database from within the return page if they do not exist.
So you have your own customer ID on your end when you create the Checkout Session?
I have their user ID when they log in, but after their first payment I link a stripe customer ID so that their payment history is logged to the same person.
I think I fixed the issue of the customers not existing in my webhook now however... But I am still having the issue that my customer did not get the product updated and I cannot figure out why.
Sorry, I'm not sure I follow. Can you provide more details about exactly what you need help with?
My customer approached me because their digital currency for a game I made was not showing after a purchase. When I looked at the databse there was no customer, however I think I fixed that by just adding the addition of their stripe customer ID into my database when they are returned to my website. Now I think there is something wrong with my webhook as they still are not showing their purchase.
This is the code and it worked for the first price ID of my product, but this user used the second price option and it is not showing their purchase on my system at all
๐ i'm hopping in since @civic spruce has to head out
No worries.
Trying to think about how to approach this from another angle - do you have an example purchase that is not showing up in your system properly?
Yes
it is pi_3KdLnKEOJsqRXL0R0aCkheDN
but when I tested it in live mode earlier in the month it worked
pi_3KZD8BEOJsqRXL0R1EhfDhR0 is for the working purchase
Everything seems to be working except when it goes to update the balance in the DB
it was the SQL statement causing all the issues... I have fixed the issue. Sorry for wasting time.
Was it the insert SQL statement?
update
the only other issue now is I have in the place where I create the customer on them being returned to the website after payment a get statement for session ID, but I cannot see where I put that into the return URL, I am assuming that is added by stripe within the return URL?
Are you referring to the automatic insertion of the Checkout Session ID when you specify {CHECKOUT_SESSION_ID} in your return URL? We talk about this more here: https://stripe.com/docs/payments/checkout/custom-success-page
Yes, ok that's good thanks. Was confused as I copied a previous return page to make sure users are added to my customer database.
๐