ValidationErrorsCollection: Braintree 我不知道为什么我会收到这个错误

时间:2021-02-01 20:21:00

标签: node.js reactjs braintree-sandbox

我在应用程序中使用了 Braintree。前一段时间它没有任何问题。现在它并不总是工作,当它不工作时。我在控制台上收到此错误: enter image description here

我在前端使用 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);
          });

}

0 个答案:

没有答案
相关问题