如何创建付款意向的结账会话



我正在使用stripe在我的系统中创建支付集成,在创建payment intent之后,我想为该支付创建checkout session,之后我想从该签出中检索url属性并发送给用户。

但我不知道如何";"连接";创建了付款意向结账会话。

现在我以这种方式创建付款意向:

const paymentIntent = await stripe.paymentIntents.create(
{
amount: 500,
currency: "usd",
customer: customerId
},
{
stripeAccount: ""
}
);

和结账会话:

const session = await stripe.checkout.sessions.create({
success_url: "",
cancel_url: "",
mode: "payment",
customer: customerId,
payment_method_types: ["card"]
});

问题是,我不知道如何根据付款前创建的意图创建结账会话。

谢谢你的帮助!

Checkout会话本身将创建一个PaymentIntent。您可以使用checkout.sessions.create调用的line_items.price_data.unit_amount[1]、line_items.price_data.currency[2]和customer[3]参数创建等效的PaymentIntent。如果您想在他们的帐户上创建会话/PaymentIntent,请确保将stripeAccount参数也传递给会话创建调用。

[1]https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-unit_amount

[2]https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-current

[3]https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-客户

最新更新