#hannamitri
1 messages · Page 1 of 1 (latest)
Hi there!
Can you share the request ID (req_xxx) that created the Checkout Session? You can find it here https://dashboard.stripe.com/test/logs
Thanks! Give me a few minutes to look into this.
Sure, np. Thanks for looking into it
This is the request that created the Checkout Session: https://dashboard.stripe.com/test/logs/req_rklS0d0LmGQYJ4
I do see setup_future_usage: "off_session" is set correctly.
but it's not being connected to the customer
Can you clarify what that means? You don't see the payment method in teh dashboard? Or you can't make other payment with that payment method? Or somehting else?
So basically, i see that
When I click on the customer
When I click on the payment intent
U know that I mean?
Like I cannot see the payment nor the card details inside the customer
Indeed that's strange. Having a deeper look...
I'm losing my brain cells with that 😂
If you need more details or more code let me know
Wait, I just checked your customer and I do see a payment method in the dashboard: https://dashboard.stripe.com/test/customers/cus_O7yQHZ7lHyvy3i
You don't see it there?
Maybe it took a few minutes to display in the dashboard, can you retry?
Hmm I think that's connected to another email
Those payments are from different emails
I added that card manually
I added that card manually
Oh right. Hum...
Isn't it very weird
Can you try creating a new Checkout Session with setup_future_usage: "off_session" and a brand new customer?
I just tried to reproduce this on my own account, and it worked as expected.
Let me try
Are the guest payments connected because of my IP?
I tried again, same thing. Idk why it's being added to related guest payments
Do you have any idea why?
req_A1siabCNktIigU
cus_O7ymPDR2xC6L7H
For example it's not showing on this customer
Thanks, having a look
Wiat no, everything worked as expected (and last time too)!
- You created the Checkout Session in this request req_A1siabCNktIigU for this customer cus_O7ymameNJyq4c9
- Now if you check the customer in the dashboard they do have a payment method set pm_1NLipAJkrlmcPYXMETpCTYC0, which was created by the Checkout Session
You are looking at the wrong customer. The one you passed in the Checkout Session is cus_O7ymameNJyq4c9
I'm not sure how exacty the dashboard display the "related payments", but you can probably ignore this part in test mode, since all payment most likely come from the same IP and use the same test card.
When creating the Chekcout Session you set cus_O7ymameNJyq4c9, so you should only look at cus_O7ymameNJyq4c9 and there you do see the payment and the card added.
Oh I see, so that will be probably solved in prod?
You mean the "related guest payment"? Yes, but again I would't put too much emphasis on it. If you are using Checkout Session and passing specific customer ID, then you should only care about those specific IDs.
const { uid, email } = request.body;
const customer = await stripe.customers.create({
email,
description: `Firebase UID: ${uid}`,
});
let stripeObj = {
mode: "payment",
customer: customer.id,
success_url: "_",
cancel_url: "_",
line_items: [{ price: "_", quantity: 1 }],
payment_intent_data: {
setup_future_usage: "off_session",
},
billing_address_collection: "auto",
};
try {
const session = await stripe.checkout.sessions.create(stripeObj);
await admin
.firestore()
.collection("customers")
.doc(uid)
.collection("checkout_sessions")
.add(stripeObj);
response.send({ sessionId: session.id });
But isn't this code creating a new customer each time it runs?
It's not static
True, but you are creating the customer yourself every time.
And you could do things differently, like reusing an existing customer object if you know it's the same person.
I have this code that opens the portal
const response = await fetch(api, body);
const { sessionId } = await response.json();
if (sessionId) {
const stripe = await loadStripe(process.env.STRIPE_KEY);
await stripe.redirectToCheckout({ sessionId });
}
Do you think I need to remove the create customer?
Do you think I need to remove the create customer?
What do you mean? You don't have to create a customer yourself, but since you want to save the payment method, it does make sense to provide a customer object.
The setup_future_usage doc says:
If a Customer has been provided or Checkout creates a new Customer, Checkout will attach the payment method to the Customer.
If Checkout does not create a Customer, the payment method is not attached to a Customer. To reuse the payment method, you can retrieve it from the Checkout Session’s PaymentIntent.
https://stripe.com/docs/api/checkout/sessions/create?lang=php#create_checkout_session-payment_intent_data-setup_future_usage
Yep so what I'm doing it correct
Yes absolutly!
I think as you mentioned, it has something to do with the same card being used or something like that
Yes, you can just ignore the "related payments" in test mode.
I understood everything except that part, I'm not sure why it's creating the customer like that
Like why are 2 customers being created with the same email, and one shows the payment and the other doesn't
Can you share the customer ID you'r looking at? cus_xxx
1: cus_O7z6AWzY4EutdU
2: cus_O7z6CWnHBr9hqk
Under the same email:
hannamitri827@gmail.com
To be clear, one Checkout Session only creates one customer.
100% but it looks like 2 are being created
But it's totally possible to have multiple customer objects with teh same email
Yep, but i'mn confused on why the other why is even being created
First customer was created here: https://dashboard.stripe.com/test/logs/req_ocKehG6U0KJahD
Second here: https://dashboard.stripe.com/test/logs/req_J9cZQDj3t5kbUc
the empty one
So it's your code that created these customers.
Can you confirm if what I'm saying is true:
I created a customer in the code using stripe.customers.create, so that's 1.
The other one is created using stripe.checkout.sessions.create, hence why 2 customers are being created
And I can't do anything about it. Is that correct?
No, each customers you shared were created by stripe.customers.create.
Chekcout Session does't create any customer in yoru case, it's just using the customer you passed in the parameters.
It's simple: the code stripe.customers.create was executed twice.
Stripe got two API calls to create a customer, so Stripe created 2 customers.
If that's not expected, then you need to check your integration to see what happens. Maybe you have another code somewhere that creates a customer. Maybe you clicked on the pay button twice in a row which made the code run twice, maybe something else. Hard to tell from my point of view.
Ah alright, I see
And even if it was running twice, there won't be any issue with it, correct?
There won't be any issue with creating 2 customers*
Yes you can create as many customers you want, and it will work.
Alright, thanks for the help!