#uneatenbreakfast
1 messages · Page 1 of 1 (latest)
It sounds like your client is not set up to retrieve the Checkout Session as the connected account that you created the Checkout Session on
Objects live on the account that created them, so the connected account needs to be specified on the backend and frontend when making requests like this
Here is how I'm creating products/prices/checkoutsessions:
// product creation
const product = await stripe.products.create(
{
name: productName,
},
{
stripeAccount: connectedAccount,
}
);
// prices creation
const price = await stripe.prices.create(
{
product: product.id,
unit_amount: priceInCents,
currency: "usd",
},
{
stripeAccount: connectedAccount,
}
);
// create checkout session
const session = await stripe.checkout.sessions.create(
{
ui_mode: "embedded",
line_items: [
...checkoutItems.map((x) => {
return {
price: x.priceId,
quantity: x.qty,
};
}),
],
custom_fields: [
{
key: "notes",
label: {
type: "custom",
custom: "Notes",
},
type: "text",
},
],
mode: "payment",
return_url: `${siteHost}/return?session_id={CHECKOUT_SESSION_ID}`,
},
{
stripeAccount: connectedAccount,
}
);
And connectedAccount is the same connected account id every time.
Anything jumping out at you?
Do you know the specific line of code that you are getting this error on?
It doesn't look like that error would come out of that code
It would come out of somethign later that tries to use that Checkout Session's ID
The error comes from the EmbeddedCheckout component that is provided by @stripe/react-stripe-js
Although, it does take in a client secret, and.. it is pointing to my platform's public key... rather than the connected account's public key (i think this is what you meant by my client not being set up properly?)
How do I get my connected account's public key?
You won't use their public key
You use your public key and their account ID
Looking in to how to do this
Thanks for that! That was the clue! You had posted a link in a later convo that touched on a similar area: https://stripe.com/docs/js/initializing#init_stripe_js-options-stripeAccount
I needed to also specify the stripeAccount when loading the stripe promise (which was used in the stripe docs example)
It's all working as expected now 🙂