所以这是我的代码:
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,因为这个函数在别处被调用,我试图找到错误的来源。
这里是通话代码:
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,任何想法为什么?
谢谢和问候。
答案 0 :(得分:2)
Stripe期望amount
以尽可能小的单位设置。通过提供3
作为值和USD
作为货币,您基本上收取0.03美元。
amount
(正整数或零)最小货币单位的正整数(例如,100美分收取1.00美元或100美元收取100日元,0-十进制货币)表示收取多少费用。最低金额为0.50美元或等值的收费货币。