2

在创建 Stripe Checkouts 表单时,我似乎找不到任何选项来向 Stripe Charge 方法添加数量,以便客户可以看到客户订购了多少。我搜索了Stripe 的 API文档,找不到任何关于向收费方法添加数量的内容(订阅计划有一个数量参数,但这不是我想要的)。有没有我缺少的关键字?还是 Stripe 不支持数量?

stripe(STRIPE_SECRET_KEY).charges.create({
    quantity: 2,
    receipt_email: body.stripeEmail,
    amount: body.amount,
    currency: body.currency,
    source: body.stripeToken, 
    description: body.description
  }, (err, charge) => {
    console.log(body.amount, body.currency);
    const status = err ? 400: 200;
    const message = err ? err.message: 'Payment successfully completed!';
    res.writeHead(status, { 'Content-Type': 'text/html' });
    return res.end('<h1>' + message + '</h1>');
  });
});
4

1 回答 1

1

对于此类一次性费用,数量不是 Charge 对象上可用的属性。如果您希望为用户提供大量购买的能力,您应该在您自己的应用程序逻辑中定义这一点,计算总数,然后指示 Stripe 收取最终金额。您可以将数量存储在元数据中以供您自己记录。或者,也许您可​​以考虑使用Orders

stripe.charges.create({
    metadata: {'quantity': 2, 'order_id': 'A6735'},
    receipt_email: body.stripeEmail,
    amount: body.amount,
    currency: body.currency,
    source: body.stripeToken, 
    description: body.description
}) 

...

于 2018-04-29T16:49:35.203 回答