Stripe payments 将PaymentIntent链接到产品
我正在使用from条带将在线支付添加到我的网站,该网站使用服务器端点创建Stripe payments 将PaymentIntent链接到产品,stripe-payments,Stripe Payments,我正在使用from条带将在线支付添加到我的网站,该网站使用服务器端点创建PaymentIntent如下: app.post(“/create payment intent”),异步(请求、回复)=>{ const{items}=req.body; //使用订单金额和货币创建PaymentIntent const paymentIntent=wait stripe.paymentIntents.create({ 金额:499, 货币:“美元” }); res.send({ clientSecret
PaymentIntent
如下:
app.post(“/create payment intent”),异步(请求、回复)=>{
const{items}=req.body;
//使用订单金额和货币创建PaymentIntent
const paymentIntent=wait stripe.paymentIntents.create({
金额:499,
货币:“美元”
});
res.send({
clientSecret:paymentIntent.client\u secret
});
});
我想知道,不是直接在PaymentIntent
中设置价格和货币,而是在Stripe上创建的产品的价格和货币吗?我知道我可以自己创建它,从API中获取相关的产品
和价格
,并从中创建我的PaymentIntent
,但是Stripe将无法“跟踪”该产品的付款(用于分析)
我知道这可以通过结帐来实现,其中产品可以与其关联。但我找不到任何自定义签出流
干杯 在支持将价格和产品直接与PaymentIntent关联之前,一个选项是利用PaymentIntent上的元数据来跟踪哪些价格对最终金额有贡献[1]。然后,您将有机会在数据库中记录这些信息,或者从PaymentIntents API查询这些信息
[1] 将此产品添加到PaymentIntentCreateParams的元数据中,如下所示
Product order = new Product();
Map<String, String> metadata = new HashMap<>();
metadata.put("productId", order.getProductId());
metadata.put("description", order.getDescription());
PaymentIntentCreateParams paymentIntentParams = PaymentIntentCreateParams.builder().putAllMetadata(metadata)
.setAmount(amountPaymentIntent).setCurrency(currencyPaymentIntent).setCustomer(customer.getId())
.build();
PaymentIntent paymentIntent = PaymentIntent.create(paymentIntentParams);
产品订单=新产品();
映射元数据=新建HashMap();
put(“productId”,order.getProductId());
put(“description”,order.getDescription());
PaymentIntentCreateParams paymentIntentParams=PaymentIntentCreateParams.builder().putAllMetadata(元数据)
.setAmount(amountPaymentIntent).setCurrency(currencyPaymentIntent).setCustomer(customer.getId())
.build();
PaymentIntent PaymentIntent=PaymentIntent.create(paymentIntentParams);