#hannamitri

1 messages · Page 1 of 1 (latest)

jovial kilnBOT
steep parcel
#

Hi there!

loud mulch
#

Sure, 2 mins

#

req_GNMYX8DNpMJEW4

#

req_QhDB5eqOMj3HuW

#

Not sure which one of those 2

steep parcel
#

Thanks! Give me a few minutes to look into this.

loud mulch
#

Sure, np. Thanks for looking into it

steep parcel
#

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?

loud mulch
#

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

steep parcel
#

Indeed that's strange. Having a deeper look...

loud mulch
#

I'm losing my brain cells with that 😂

#

If you need more details or more code let me know

steep parcel
#

You don't see it there?

#

Maybe it took a few minutes to display in the dashboard, can you retry?

loud mulch
#

Hmm I think that's connected to another email

#

Those payments are from different emails

#

I added that card manually

steep parcel
#

I added that card manually
Oh right. Hum...

loud mulch
#

Isn't it very weird

steep parcel
#

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.

loud mulch
#

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

steep parcel
#

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
loud mulch
#

Hmm

#

Why isn't it showing here tho

#

I'm a bit confused about that part

steep parcel
#

You are looking at the wrong customer. The one you passed in the Checkout Session is cus_O7ymameNJyq4c9

loud mulch
#

Do you know why is it creating 2 customers?

#

And why is it added with those

steep parcel
#

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.

loud mulch
#

Oh I see, so that will be probably solved in prod?

steep parcel
#

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.

loud mulch
#
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

steep parcel
#

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.

loud mulch
#

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?

steep parcel
#

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.

loud mulch
#

Yep so what I'm doing it correct

steep parcel
#

Yes absolutly!

loud mulch
#

I think as you mentioned, it has something to do with the same card being used or something like that

steep parcel
#

Yes, you can just ignore the "related payments" in test mode.

loud mulch
#

Like why are 2 customers being created with the same email, and one shows the payment and the other doesn't

steep parcel
#

Can you share the customer ID you'r looking at? cus_xxx

loud mulch
#

1: cus_O7z6AWzY4EutdU
2: cus_O7z6CWnHBr9hqk

steep parcel
#

To be clear, one Checkout Session only creates one customer.

loud mulch
steep parcel
#

But it's totally possible to have multiple customer objects with teh same email

loud mulch
#

Yep, but i'mn confused on why the other why is even being created

steep parcel
loud mulch
#

the empty one

steep parcel
#

So it's your code that created these customers.

loud mulch
#

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?

steep parcel
#

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.

loud mulch
#

How is it creating 2 customers then if the code runs once

#

Do you have any idea?

steep parcel
#

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.

loud mulch
#

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*

steep parcel
#

Yes you can create as many customers you want, and it will work.

loud mulch
#

Alright, thanks for the help!