【问题标题】:Node.js PayUMoney Integration - response.headers.location is undefinedNode.js PayUMoney 集成 - response.headers.location 未定义
【发布时间】:2019-11-10 10:01:22
【问题描述】:

尝试了 2 个 Node.js 包:
https://www.npmjs.com/package/payumoney_nodejs
https://www.npmjs.com/package/payumoney-node

在本地主机上调试。
在每个包的node_modules下的index.js文件中调试。

params {
  key: 'x1FanfbP',
  salt: 'Vs2GrDyaMQ',
  service_provider: 'payu_paisa',
  hash: '65f75ced566e2d76dbc6153a277c25f591fc3c0a00a8f51a0699f609d5cbbc94dc7acd5d3be5fe0c0a855c4c6dc7faef49d8b6a1d77dd09398058f800bab068d',
  firstname: '',
  lastname: '',
  email: 'xxxxxxxx@xxxxx.xxx',
  phone: XXXXXXXXXX,
  amount: '100',
  productinfo: '',
  txnid: '5b51d253-5d6e-4512-951a-cd6d05bf9e6b',
  surl: 'http://localhost:3000/member/contribution/success',
  furl: 'http://localhost:3000/member/contribution/failure'
}

request.post(this.payUmoneyURL, form: params, headers: this.headers }, 
    function(error, response, body) {
        if (!error) {
            var result = response.headers.location;
            callback(error, result);
        }
});


request.post(payment_url[this.mode] + API.makePayment, { form: params, headers: this.headers }, function(error, response, body) {
        if (!error) {
            var result = response.headers.location;
            callback(error, result);
        }
});

response.headers 的响应:

response.headers {
    date: 'Fri, 28 Jun 2019 12:06:35 GMT',
    server: 'Apache',
    'x-powered-by': 'PHP/7.2.14',
    p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
    'set-cookie': [ 'PHPSESSID=naopga57qf58vl0hdfj5krq4n5; path=/; domain=.payu.in' ],
    expires: 'Thu, 19 Nov 1981 08:52:00 GMT',
    'cache-control': 'no-store, no-cache, must-revalidate',
    pragma: 'no-cache',
    vary: 'Accept-Encoding',
    'content-length': '3129',
    connection: 'close',
    'content-type': 'text/html; charset=UTF-8'
}

上面没有locationresponse.headers.location这样的键

有人可以帮忙知道为什么location 没有返回吗? 是因为在本地机器上开发吗?如果是,那么如何在 localhost 上测试呢?

感谢任何帮助。

【问题讨论】:

  • 为什么需要位置?
  • 在问题中提供的包 urls 中说 API 应该返回一个需要发送到 UI(在我的情况下为 Angular)的 URL,然后重定向到该 URL。
  • 在请求正文中,您是否按照文档设置了 surl 和 furl?
  • 如果你可以分享console.log(response)的输出
  • 它说“您将获得一个链接以响应重定向到 payUMoney”,您正在检查标头,但它可能在响应本身中。参考文章 - medium.com/@swapnilnakhate/…

标签: node.js payment-gateway payumoney


【解决方案1】:

这似乎是一个非常愚蠢的错误,但之前不知道在哪里查找 response 键中的错误。

在遍历整个response 对象后,发现在response 对象的最后发送了一个body 键,该对象具有HTML 字符串。此 HTML 指定是否发生了任何错误以及它到底是什么。

就我而言,这是缺少必填字段:

Error Reason
One or more mandatory parameters are missing in the transaction request.

Corrective Action
Please ensure that you send all mandatory parameters in the transaction request to PayU.

Mandatory parameters which must be sent in the transaction are: 
key, txnid, amount, productinfo, firstname, email, phone, surl, furl, hash.

The parameters which you have actually sent in the transaction are: 
key, txnid, amount, surl, hash, email, phone.

Mandatory parameter missing from your transaction request are: 
productinfo, firstname.

Please re-initiate the transaction with all the mandatory parameters.

为缺少的参数传递数据后,按预期收到response.headers.location 键中的url

集成现在按预期工作。

【讨论】:

    猜你喜欢
    • 2017-06-14
    • 1970-01-01
    • 2019-04-24
    • 1970-01-01
    • 1970-01-01
    • 2014-10-12
    • 2015-11-02
    • 2017-03-03
    • 1970-01-01
    相关资源
    最近更新 更多