#uneatenbreakfast

1 messages · Page 1 of 1 (latest)

floral meteorBOT
fallow hamlet
#

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

hot cloak
#

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?

fallow hamlet
#

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

hot cloak
#

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?

fallow hamlet
#

You won't use their public key

#

You use your public key and their account ID

#

Looking in to how to do this

hot cloak
#

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 🙂

fallow hamlet
#

Nice find! I was just about to send you the doc link for that

#

Glad things are working!