简体   繁体   English

如何为付款意图创建结帐 session?

[英]How to create checkout session for payment intent?

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.我正在使用stripe在我的系统中创建支付集成,在创建payment intent后,我想为此支付创建checkout session ,之后我想从此结帐中检索url属性并发送给用户。

But i don't have an idea how to "connect" created payment intent to checkout session.但我不知道如何“连接”创建付款意图以结帐 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:并结帐 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.问题在于,我不知道如何根据付款意图之前创建的结帐 session 创建结帐。

Thanks for any help!谢谢你的帮助!

The Checkout Session itself will create a PaymentIntent. Checkout Session 本身将创建一个 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.您可以使用checkout.sessions.create调用的line_items.price_data.unit_amount [1]、 line_items.price_data.currency [2] 和customer [3] 参数创建等效的 PaymentIntent。 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.如果您想在他们的帐户上创建 Session/PaymentIntent,请确保将stripeAccount参数传递给您的 Session 创建调用。

[1] https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-unit_amount [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-currency [2] https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-currency

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM