node.js - Stripe 抛出无效整数错误

标签 node.js stripe-payments payment-gateway payment payment-processing

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

Stripe Checkout Price error - Invalid Integer

Stripe Rails: Invalid integer: 1.06

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

 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 以获取更多详细信息,请查看链接:

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.

关于node.js - Stripe 抛出无效整数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45453090/

相关文章:

javascript - Node.js:WAITING异步调用的响应

node.js - Stripe 不允许将一笔费用与一次性来源的客户关联起来

java - CONNECTED_STRIPE_ACCOUNT_ID 是什么?如何从android平台获取它?

paypal - Prestashop Paypal 付款错误

node.js - 使用 Botframework 进行 OAuth 时的神奇代码。有办法吗?

javascript - 在socket.io中的每个连接的客户端上显示光标

Android - 实现 Stripe 库后出现 "Manifest Merger Failed"错误

php - Paypal 按钮不工作 - 我们很抱歉错误

ruby-on-rails - Stripe 创建后获取订阅 ID

node.js - 使用 npm uninstall 时自动从 package.json 中删除依赖项