#ayushh_code

1 messages ยท Page 1 of 1 (latest)

obsidian pivotBOT
#

๐Ÿ‘‹ 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/1336622843013632021

๐Ÿ“ 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.

tribal wraith
#

It's payment_intent_data not payment_method_data

obsidian pivotBOT
tacit orbit
# tribal wraith It's `payment_intent_data` not `payment_method_data`

now getting

No overload matches this call.
  Overload 1 of 2, '(params?: SessionCreateParams, options?: RequestOptions): Promise<Response<Session>>', gave the following error.
    Object literal may only specify known properties, and 'stripeAccount' does not exist in type 'SessionCreateParams'.
  Overload 2 of 2, '(options?: RequestOptions): Promise<Response<Session>>', gave the following error.
    Object literal may only specify known properties, and 'customer' does not exist in type 'RequestOptions'.
twin depot
tacit orbit
twin depot
#

This is not a valid JavaScript.

#
stripe.checkout.sessions.create({
  customer:
  ...
}, {
  stripeAccount: 'acct_xxx'
})
tacit orbit
#

This is correct?

twin depot
#

Does it work?

tacit orbit
#

Lemme try

#

Hi vanya

#

I am getting a new error

#

On the backend logs

#

[STRIPE CHECKOUT ERROR] StripeInvalidRequestError: No such customer: cus_xxxx

#

even tho I cleared the stripeCustomer table on my db

#
 let stripeCustomer = await db.stripeCustomer.findUnique({
            where: {
                userId: id
            },
            select: {
                stripeCustomerId: true
            }
        });

        if (!stripeCustomer) {
            const customer = await stripe.customers.create({
                email: user.email,
            });

            stripeCustomer = await db.stripeCustomer.create({
                data: {
                    userId: id,
                    stripeCustomerId: customer.id
                }
            });
        }
#

this part already creates customer

twin depot
twin depot
#

This won't work since you can only use the Customer objects from the Connected account.

tacit orbit
#

oh, so you mean the email of the connected account and the customer email should match?

twin depot
#

No, this is not what I mean.

tacit orbit
#

Give me few mins

#

@twin depot req_AfVSGtl4r5UCIi

obsidian pivotBOT
twin depot
#

As I suspected. The problem is: you create the Customer without stripeAccount='acct_xxx' header, but then you create a Checkout Session with the stripeAccount header. Which results in these 2 actions happening on 2 different Stripe accounts, and produces the error.

tacit orbit
#

Oh

twin depot
#

What are you trying to build with Stripe Connect exactly?

tacit orbit
summer geyser
#

hi! I'm taking over this thread.

tacit orbit
#

Hi

summer geyser
#

you have to chose:

  • do you want the payment and customer obejct to live on the platform account (if so, don't use the Stripe-Account header)
  • or do you want everything to live on the connected account (if so, use the Stripe-Account header)
    here you are trying to do a mix between the two (the Checkout Session use the Stripe-Account header, but not the Customer, so it can't work)
tacit orbit
#

can you share with me the correct flow of how to handle the split?

#

The driver has to connect their stripe account to the site using stripe connect to start taking rides

#

the user will select the source and destination address

#

the drivers will be listed

summer geyser
tacit orbit
summer geyser
#

please read the doc, it explains all the difference in details

tacit orbit
#

For the Connected account, Express Account seems good
For the Charges, Seperate charge and transfers seems good since the user payment will go the driver selected and the platform

summer geyser
#

yep, Express with Seperate charge and transfers is a combinaison that makes sense.

#

in this case, when you create the Chekcout Session, don't set the Stripe-Account header, since all objects should live on your platform account.

#

note that Express + Destination Charges can also work.

tacit orbit
#

yes correct

#

Lemme try

tacit orbit
#

Another error with webhook now

obsidian pivotBOT
tacit orbit
#

resource_missing - customer

hot cairn
#

Likely using the wrong API keys in your request. The object probably exists on a different account

#

Do you have the req_xxx ID and I can confirm?

tacit orbit
#

wait a sec

#

I am unable to see the request id in my checkout session object

#

req_aUWCD4gTu9H1gC

hot cairn
tacit orbit
#

This is the req id

tacit orbit
hot cairn
#

Looking

tacit orbit
#

and also

#

the customer id is incorrect

#

in the error

hot cairn
#

It's because cus_Rfy5Q8N1WmqhRR exists on different account (acct_1QbIflCAkUDxAcxa) to the two used in the request

tacit orbit
#

But the customer id that I passed to the checkout session is different

hot cairn
#

Not according to the error. I'd check your code/logic to ensure it's passing the cus_xxx you expect

tacit orbit
#
if (!stripeCustomer) {
            const customer = await stripe.customers.create({
                email: user.email,
            });
        
            stripeCustomer = await db.stripeCustomer.create({
                data: {
                    userId: id,
                    stripeCustomerId: customer.id
                }
            });
        }

        const stripeSession = await stripe.checkout.sessions.create({
            customer: stripeCustomer.stripeCustomerId,
            line_items,
            payment_intent_data: {
                application_fee_amount: Math.round((Number(riderLogExists.netDriverPayout + riderLogExists.riderPercentageFee)) * 100),
                transfer_data: {
                    destination: stripeAccountId.stripeAccountId
                }
            },
            mode: "payment",
            success_url: `${process.env.FRONTEND_URL}/payment_success`,
            cancel_url: `${process.env.FRONTEND_URL}/payment_cancel`,
            metadata: {
                id: id,
                email: user.email,
                riderLogId,
                rideType: riderLogExists.type,
                dateAssigned: riderLogExists.dateAssigned.toISOString()
            }
        });
#

and indeed in the logs I am getting the correct stripe customer id

#

Would you like me to try again?

hot cairn
tacit orbit
#

cus_RiXDo4Q3DKRiUQ

tacit orbit
hot cairn
#

Something in your code isn't working as you expect

tacit orbit
#

Lemme try again

#

req_QtwggE5Tv5XPBH

#

can you check this request id?

#

I am unable to see my webhook being called

#

I ll brb in a moment

hot cairn
#

Request suceeded. Which webhook?

tacit orbit
#

it should have called my backend server faire-backend.vercel.app/api/webhook

#

for the checkout session completed

hot cairn
#

No that event only fires when the session is completed (paid), not created

tacit orbit
#

okay

#

I am trying the payment intent succeeded one

#

give me a moment

hot cairn
#

Well that event wouldn't fire either until somebody opened the Checkout Session URL and made a payment

tacit orbit
#

yes ofc

#

I am making a test payment

#

it's sending to a different webhook rather than mine

hot cairn
#

OK then you should see events assuming your webhook is configured correctly

tacit orbit
hot cairn
#

What is the evt_xxx ID you're expecting?

tacit orbit
#

evt_3Qp7BvIDD0gqKgBn1bOlaMtu

#

this is the failed event

hot cairn
#

What's the ID of the webhook it should go to (we_xxx)?

tacit orbit
#

we_1Qp6dVIDD0gqKgBnw4kd7vJJ

hot cairn
#

we_1Qp6dVIDD0gqKgBnw4kd7vJJ only receives events on your platform account

#

evt_3Qp7BvIDD0gqKgBn1bOlaMtu fired on the connected account, as it's related to a direct charge

obsidian pivotBOT
tacit orbit
#

Hi

#

Unable to receive events again

#
 const stripeSession = await stripe.checkout.sessions.create({
            customer: stripeCustomer.stripeCustomerId,
            line_items,
            payment_intent_data: {
                application_fee_amount: Math.round((Number(riderLogExists.driverTaxRate + riderLogExists.riderPercentageFee)) * 100),
                transfer_data: {
                    destination: stripeAccountId.stripeAccountId
                }
            },
            mode: "payment",
            success_url: `${process.env.FRONTEND_URL}/payment_success`,
            cancel_url: `${process.env.FRONTEND_URL}/payment_cancel`,
            metadata: {
                id: id,
                email: user.email,
                riderLogId,
                rideType: riderLogExists.type,
                dateAssigned: riderLogExists.dateAssigned.toISOString()
            }
        });
#

destinationid: we_1Qp7KmIDD0gqKgBn5MAeST4y

next rune
#

What is th event Id ?

tacit orbit
#

evt_3Qp7OEIDD0gqKgBn0s17p2Cq

#

I created another non-connected webhook

#

but still unable to receive event

next rune
#

That event was delivered to this webhook endpoint we_1QaimqIDD0gqKgBn6KKkXwTa