#stachujone5
1 messages · Page 1 of 1 (latest)
Express Checkout Element doesn't have a line items concept I'm afraid
const stripeSession = await stripe.checkout.sessions.create({
line_items: boughtProductsWithBoughtVariants.map((bm) => {
return {
price: bm.product.priceId,
quantity: bm.quantity
};
}),
mode: 'payment',
success_url: successURL,
cancel_url: cancelURL,
...(user?.customerId ? { customer_update: { shipping: 'auto' } } : {}),
customer: user?.customerId ?? undefined,
shipping_options: [{ shipping_rate: 'some rate' }],
shipping_address_collection: {
allowed_countries: allowedCountries
},
automatic_tax: {
enabled: true
},
invoice_creation: {
enabled: true
},
allow_promotion_codes: true,
metadata: {
type: 'merch',
orderId: order.id,
cartId: input.cartId ?? null
}
});
Thats how I use normal checkout
I'd like to do the same but with apple pay button
and google pay button
embedded on my page
From reading the docs I see that I should use ExpressCheckout element
What should I do to implement the same logic for express checkout as I do in normal checkout?
As I stated, you can't use line items with Express Checkout Element. You interact with the Payment Intents APIs directly which don't have a line item field/concept
Why not just embed Checkout on your page? https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=embedded-checkout
Okey so lets assume that I dont pass line items, just a full amount.
Then user pays and webhook runs. How do I proceed the webhook and pass all the necessery info such as product info etc.
Becuase I'd like to have normal checkout and additioanlly apple and google pay buttons near the Pay btn which triggers external stripe checkout
Do i need to pass all the data as a metadata?
Then user pays and webhook runs. How do I proceed the webhook and pass all the necessery info such as product info etc.
Well, you can't because Payment Intents don't work with Products/Prices directly
That's an option yes
And what about other things that normal checkout has - ```ts
automatic_tax: {
enabled: true
},
invoice_creation: {
enabled: true
},
allow_promotion_codes: true,
shipping rate
And prices added in stripe's dashboard?
I've prices added with multiple currencies
So when user starts checkout from US price is in dollars
And when he starts checkout from DE its in euro
Nope, you can't use them with Checkout
And the price localisation is a Checkout feature
eh thats bad
And would I be able to use it if I used PaymentRequestButton instead of express checkout?
I mean all of those above^^
Did you look at embedding it on your site as opposed to using the hosted/redirect flow?