I'm using stripe to create an payment integration in my system, after creating an payment intent i want to create checkout session for this payment, after this i want to retrieve an url property from this checkout and send to the user.
But i don't have an idea how to "connect" created payment intent to checkout session.
Right now i create payment intent in this way:
const paymentIntent = await stripe.paymentIntents.create(
{
amount: 500,
currency: "usd",
customer: customerId
},
{
stripeAccount: ""
}
);
and checkout session:
const session = await stripe.checkout.sessions.create({
success_url: "",
cancel_url: "",
mode: "payment",
customer: customerId,
payment_method_types: ["card"]
});
The problem is in this, that i don't know how to create checkout session based on created before an payment intent.
Thanks for any help!
The Checkout Session itself will create a PaymentIntent. You can create an equivalent PaymentIntent with the line_items.price_data.unit_amount[1], line_items.price_data.currency[2], and customer[3] parameters of the checkout.sessions.create call. Make sure to pass in the stripeAccount parameter to your Session creation call as well if you want to create the Session/PaymentIntent on their account.
[3] https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer