#patrick_error

1 messages ยท Page 1 of 1 (latest)

fluid lilyBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

broken cargo
#

It looks like you mixed up the Checkout Session and Payment Intent integration

#

Elements only supports Payment Intent (pi_xxx), but not Checkout Session (cs_xxx)

#

There is no client_secret from the Checkout Session

versed quarry
#

app.post("/create-checkout-session", async (req, res) => {
try {
const session = await stripe.checkout.sessions.create({
line_items: [
{
price: "price_1Oz8hhKJh7RBv6HQdoJtBPXP",
quantity: 1,
},
],
mode: "subscription",
ui_mode: "embedded",
redirect_on_completion: "never",
});

    res.send({
        sessionId: session.id,
        clientSecret: session.client_secret,
    });
} catch (error) {
    return res.status(400).send({ error: { message: error.message } });
}

});

#

so I can't use the clientSecret from stripe.checkout.sessions.create to cardNumberElement?

broken cargo
#

Checkout Session is Stripe hosted payment page and it can't be used with CardNumberElement

#

Checkout Session doesn't have client_secret for Element since the payment is expected to be done in Stripe page

#

CardNumberElement only supports client_secret from subscription = await stripe.subscriptions.create()

versed quarry
#

Thanks for your reply. I'll try embedded mode again

broken cargo
#

No problem! Happy to help ๐Ÿ˜„

versed quarry
#

Can I customize the embeded view? Only keep the card information and subscription button?

broken cargo
#

I'm afraid embedded Checkout Session is not customisable

versed quarry
#

It seems that the workload on the server side is unavoidable. Thanks again for your reply.