#ayushh_code
1 messages ยท Page 1 of 1 (latest)
๐ 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.
- ayushh_best-practices, 1 day ago, 16 messages
- ayushh_error, 4 days ago, 15 messages
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'.
stripeAccount should go inside of the object in the second argument: https://docs.stripe.com/connect/authentication?lang=node#stripe-account-header
This is not a valid JavaScript.
stripe.checkout.sessions.create({
customer:
...
}, {
stripeAccount: 'acct_xxx'
})
Does it work?
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
Could you please share the Request ID req_xxx? https://support.stripe.com/questions/finding-the-id-for-an-api-request
I think I know where the issue is.
You create the Customer on your Platform account, but then create the Checkout Session on your Connected account with stripeAccount header.
This won't work since you can only use the Customer objects from the Connected account.
oh, so you mean the email of the connected account and the customer email should match?
No, this is not what I mean.
Could you please share the Request ID with the error req_xxx? https://support.stripe.com/questions/finding-the-id-for-an-api-request
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.
Oh
What are you trying to build with Stripe Connect exactly?
I am building a rideshare web application where rider can select the ride from the available drivers.
The rider has to pay ride fee + 4.5% fees to our platform and the driver has to pay 10% from their profit to our platform.
hi! I'm taking over this thread.
Hi
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)
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
first you have to decide a few things:
- which type of connected account you want to create: https://docs.stripe.com/connect/accounts
- which type of charge you want to use: https://docs.stripe.com/connect/charges
Based on my requirement which connected account will be best suited?
please read the doc, it explains all the difference in details
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
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.
Another error with webhook now
resource_missing - customer
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?
wait a sec
I am unable to see the request id in my checkout session object
req_aUWCD4gTu9H1gC
This error, the request that returned this error
This is the req id
Got the request id
Looking
It's because cus_Rfy5Q8N1WmqhRR exists on different account (acct_1QbIflCAkUDxAcxa) to the two used in the request
But the customer id that I passed to the checkout session is different
Not according to the error. I'd check your code/logic to ensure it's passing the cus_xxx you expect
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?
What is the 'correct' ID?
cus_RiXDo4Q3DKRiUQ
correct stripe customer id which I have recorded in the db
Not sure then โ the request you sent me clearly uses a different ID. You can see for yourself: https://dashboard.stripe.com/logs/req_aUWCD4gTu9H1gC
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Something in your code isn't working as you expect
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
Request suceeded. Which webhook?
it should have called my backend server faire-backend.vercel.app/api/webhook
for the checkout session completed
No that event only fires when the session is completed (paid), not created
Well that event wouldn't fire either until somebody opened the Checkout Session URL and made a payment
yes ofc
I am making a test payment
it's sending to a different webhook rather than mine
OK then you should see events assuming your webhook is configured correctly
What is the evt_xxx ID you're expecting?
I m not recording evt ID in my db
evt_3Qp7BvIDD0gqKgBn1bOlaMtu
this is the failed event
What's the ID of the webhook it should go to (we_xxx)?
we_1Qp6dVIDD0gqKgBnw4kd7vJJ
You need to configure a Connect webhook to receive those events on your platform: https://docs.stripe.com/connect/webhooks
we_1Qp6dVIDD0gqKgBnw4kd7vJJ only receives events on your platform account
evt_3Qp7BvIDD0gqKgBn1bOlaMtu fired on the connected account, as it's related to a direct charge
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
What is th event Id ?
evt_3Qp7OEIDD0gqKgBn0s17p2Cq
I created another non-connected webhook
but still unable to receive event
That event was delivered to this webhook endpoint we_1QaimqIDD0gqKgBn6KKkXwTa