将 PaymentIntent 链接到产品

Thé*_*ion 6 stripe-payments

我正在使用stripe的自定义结帐流程将在线支付添加到我的网站,该网站使用服务器端点来创建PaymentIntent类似的内容:

app.post("/create-payment-intent", async (req, res) => {
  const { items } = req.body;
  // Create a PaymentIntent with the order amount and currency
  const paymentIntent = await stripe.paymentIntents.create({
    amount: 499,
    currency: "usd"
  });
  res.send({
    clientSecret: paymentIntent.client_secret
  });
});
Run Code Online (Sandbox Code Playgroud)

我想知道,不是直接在 中设置价格和货币PaymentIntent,而是可以Product在 Stripe 上创建?我知道我可以自己创建并从 API 中获取关联的Product和并从中创建我的,但是 Stripe 将无法“跟踪”该产品的付款(对于分析有用)。PricePaymentIntent

我知道这可能与Checkout产品与其关联的位置有关。但我找不到任何自定义结账流程的信息。

干杯!

v3n*_*man 2

在支持将价格和产品直接与 PaymentIntents 关联之前,一种选择是利用 PaymentIntent 上的元数据来跟踪哪些价格对最终金额有贡献 [1]。然后您将有机会将其记录在数据库中或从 PaymentIntents API 中查询。

[1] https://stripe.com/docs/api/ payment_intents/ object# payment_intent_object-metadata