#dave_73622
1 messages · Page 1 of 1 (latest)
Hello! Do you have two example customer IDs I can take a look at?
yes. here is one customer that was created twice. here the 2 different customer ids for the same customer:
cus_Oy9OExiQeg8ohN
cus_Oy9PmFcn8nEKKI
here is another example:
cus_OyEEMsrnDkKiz9
cus_OyELGktObJRUOB
Do you have any logic on your end to prevent duplicate customers being created?
By default, Stripe doesn't do any dedeuplication for you so it's expected behavior that the same user would be able to create two different checkout sessions and generate two separate customers
i don't specifically have logic to prevent that. technically our users could create 2 different accounts in the product and sign up 2 different times, but these users signed up twice under the same account which we've not seen before
i suppose we may need logic to look at the users email address when the signup and if they already have an account, then prevent the signup from happening again?
something like that?
yup!
do you think its possible that the webhook created the customer, then failed somewhere else, then re-ran, and created the customer again?
No, I'm fairly sure that isn't the case here. All the example customers you gave me were for Customers that were created during the Checkout process
hmm ok. yea, that makes sense.
so, perhaps these customers just created 2 checkout portals and actually signed up twice all on their own
i just dont understand why they would do that
it feels more like a bug in our code
can you look at this checkout session code and see if anything jumps out at you?
const session = await stripe.checkout.sessions.create({
mode: 'setup',
payment_method_types: ['card'],
customer_email: req.body.user.email,
metadata: {
auth0UserId: id,
customer_email: req.body.user.email,
price: req.body.stripePriceId,
isAffiliateReferral: req.body.isAffiliateReferral,
affiliateId: req.body.affiliateId
},
customer_creation: 'always',
billing_address_collection: 'required',
// {CHECKOUT_SESSION_ID} is a string literal; do not change it!
// the actual Session ID is returned in the query parameter when your customer
// is redirected to the success page.
success_url: `${process.env.SUCCESS_CHECKOUT_REDIRECT_URL}?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.CANCEL_CHECKOUT_REDIRECT_URL}`
});
Nothings jumping out at me - I agree it's strange, but really the only way they could've ended up in this state is if they opened two searpate Checkout Sessions and completed both