代码之家  ›  专栏  ›  技术社区  ›  Sanchita Santra

智能树集成-gateway.transaction.sale永远不会到达err,result函数

  •  0
  • Sanchita Santra  · 技术社区  · 6 年前

    我使用firebase函数来集成braintree服务器端。我已经检查了firebase云函数和其他函数,它们运行良好。所以,这肯定和脑树有关。我在github中查看了braintree nodejs实现指南,我的代码很好。 https://github.com/braintree/braintree_node

    问题是函数总是 catch 具有 unexpectedError 是的。密码永远达不到 then 部分代码。

    exports.setNonce = functions.https.onRequest((req, res) => {
    
    // Grab the parameters.
    if (req.body.nonce === undefined) {
        // This is an error case, as "message" is required
        return res.status(400).send('No nonce defined!');
    } else {
        return gateway.transaction.sale({
            amount: '5.00',
            paymentMethodNonce: 'fake-valid-nonce',
            options: {
              submitForSettlement: true
            }
          }).then((err, result) => {
            if(err) {
                return res.status(406).send(err);
            }
            else {
                return res.status(200).json({"hash" : "Successful"});
            }
          }).catch((error) => {
            return res.status(406).send(error);
          });
    }
    });
    

    我已经试过的东西 -

    1. 使用Bluebird将gateway.transaction.sale转换为Promise。它仍然会产生同样的错误- How to promisify a braintree method?

    2. 通过选择测试卡更改数量并给出另一个nonce- https://developers.braintreepayments.com/reference/general/testing/node#test-value-2223000048400011

    3. 删除 options -什么都没变

    1 回复  |  直到 6 年前
        1
  •  1
  •   Diego P    6 年前

    这可能是因为您处于空闲层(spark),因此传出的套接字连接被阻塞。您必须将项目升级到 Blaze plan 启用传出连接。这个 火焰计划 有大量的配额限制,所以你可能不会被收费。