问题描述
我在应用程序中使用了 Braintree。前一段时间它没有任何问题。现在它并不总是工作,当它不工作时。我在控制台上收到此错误:
我在前端使用 React。
Node.js 代码
const gateway = new braintree.BraintreeGateway({
environment: braintree.Environment.SandBox,merchantId: process.env.BRAINTREE_MERCHANT_ID,publicKey: process.env.BRAINTREE_PUBLIC_KEY,privateKey: process.env.BRAINTREE_PRIVATE_KEY
});
exports.generatetoken = (req,res) => {
gateway.clientToken.generate({},function(err,response) {
//Se verdade vamos trazer o token
if(err){
res.status(500).send(err)
}else{
res.send(response)
}
});
};
exports.processpayment = (req,res) => {
let nonceFromTheClient = req.body.paymentMethodNonce
let amountFromTheClient = req.body.amount
//charge
let newTransaction = gateway.transaction.sale({
amount: amountFromTheClient,paymentMethodNonce: nonceFromTheClient,options: {
submitForSettlement: true
}
}).then(function (result) {
if (result.success) {
res.json(result);
} else {
console.log(result.errors)
//res.status(500).json(error);
}
}).catch(function (err) {
console.error(err);
});
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)