#angel_azm
1 messages · Page 1 of 1 (latest)
Hello! If you're using Checkout Sessions in payment mode you can set payment_intent_data.transfer_group (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-transfer_group)
The transfers are something you'd have to create separately yourself after the payment is complete
(You can listen for the checkout.session.completed webhook event to know when payment finished)
Example:
const paymentIntent = await stripe.paymentIntents.create({
amount: 10000, // $100
currency: 'usd',
transfer_group: 'ORDER10',
});
const transfer = await stripe.transfers.create({
amount: 7000, // $70
currency: "usd",
destination: "{{STRIPE_ID}}",
transfer_group: "ORDER10",
});
const transfer = await stripe.transfers.create({
amount: 2000, // $20
currency: "usd",
destination: "{{STRIPE_ID2}}",
transfer_group: "ORDER10",
});
app.post("/create-checkout-session", async (req, res) => {
const session = await stripe.checkout.sessions.create({
line_items: itemsArray,
payment_intent_data: paymentIntent,
mode: "payment",
success_url: "http://localhost:4242/success",
cancel_url: "http://localhost:4242/cancel",
});
res.redirect(303, session.url);
});
Is that the way it should be?
No, that's not how this works - you can't pass in a PaymentIntent that you created yourself when using a Checkout Session
Checkout creates it's own payment intent when it attempts payment
Instead of payment_intent_data: paymentIntent,
you'd do something like
payment_intent_data: {
transfer_group: 'ORDER10'
}
thanks, I will try to do it this way