Stripe 抛出无效整数错误

Stripe throws invalid integer error

我无法在条纹中收取 49.99 美元的金额。我正在浏览以下链接,但没有锻炼

我想按原样收款。我不想四舍五入付款

 stripe.charges.create({
    // Charge the customer in stripe
// amount: req.query.amount,
    amount: 49.99,
    currency: 'usd',
    customer: req.customer
  }).then(function(charge) {
    // Use and save the charge info in our db
    var successTransaction = {
      stripeId: charge.customer,
      transactionId: charge.id,
      amount: charge.amount,
      currency: charge.currency,
      message: charge.outcome.seller_message,
      paidStatus: charge.paid,
      summary: charge
    };

Stripe 只允许价格中的整数值,因此需要将您的价格(金额)更改为美分(*100),所以现在您的代码数量为 499,在 stripe 仪表板中,您会看到 49.99 以获取更多详细信息,请查看 link:

https://stripe.com/docs/api#charges

In other words, Stripe's API always takes smallest supported unit as input (without need to configure anything), for example, amount of 1 means 1-Cent not 1-Dollar.

您可以使用以下方法,因为它可以帮助您使用小数值作为金额,并在发票和付款时显示相同的金额。

金额:Math.round(49.99 * 100)

Stripe 允许整数值作为价格,如果你想收取 49.99 美元然后乘以 100。

条纹允许的最小价格单位是分。

599 cents = .99