2016-09-16 13 views
0

因此,这里是我的代码:条纹除以100的NodeJS

PaymentDaemon.authorize = function(req, callback) { 
    console.log("on est dans authorize"); 
    console.log(req.amount); 
    stripe.charges.create({ 
    amount: 3,//req.amount, 
    currency: req.currency, 
    source: req.card, 
    description: req.details, 
    capture: false 
    }, function(err, charge) { 
    if (err != null) 
     console.error("ERROR in PaymentDaemon.authorize: " + err); 
    else { 
     req.paidDate = null; 
     req.way = cfg.payment.way.in; 
     req.stripe = charge.id; 
     var search = {}; 
     if (req.payment != null) 
     search._id = req.payment; 
     Payment.update(search, req, { upsert: true }, function(error) { 
     if (error != null) { 
      console.error("ERROR in PaymentDaemon.authorize: " + err); 
      console.error("ERROR Data not inserted in DB: " + JSON.stringify(req)); 
     } 
     }); 
    } 
    callback(err, charge); 
    }); 
} 

我已经把3,因为该功能在其他地方打了个电话,我试图找到哪儿来的错误。

这里是callling代码:

var req = { 
    amount: amount, 
    currency: currency, 
    card: idcard, 
    details: null, // fixme 
}; 
console.log("on est dans charge"); 
PaymentDaemon.authorize(req, function(error, charge) { 
    if (error != null) 
    { 
    console.error('ERROR PaymentDaemon.createPayment() (4): ' + error); 
    } 
    else 
    { 
    console.log(charge); 
    res.status(200).send(charge); 
    } 
}); 

,当我打电话吧,我有这样的错误:

ERROR in PaymentDaemon.authorize: Error: Amount must convert to at least 50 cents. €0.03 converts to approximately $0.03. 
ERROR PaymentDaemon.createPayment() (4): Error: Amount must convert to at least 50 cents. €0.03 converts to approximately $0.03. 

所以条纹似乎除以100我的量,任何想法,为什么?

感谢和问候。

回答

2

条纹预计amount设置为尽可能最小的单位。通过提供3作为货币和USD作为货币,您基本上收取0.03美元。

每其API reference

amount(正整数或零)

在最小货币单位的正整数(例如,100分收取$ 1.00 100充电¥100,0代表要收多少钱。最低金额为$ 0.50美元或同等收费货币。

+0

非常感谢和抱歉。 – user462794