我收到了来自authorize.net支付网关的响应,并尝试了很多次和很多方法来解析它,但没有运气。
以下是来自www.example.com的主要回复authorize.net:
"{"transactionResponse":{"responseCode":"1","authCode":"XXXXXX","avsResultCode":"Y","cvvResultCode":"P","cavvResultCode":"2","transId":"11111111111","refTransID":"","transHash":"","testRequest":"0","accountNumber":"XXXX0002","accountType":"AmericanExpress","messages":[{"code":"1","description":"This transaction has been approved."}],"transHashSha2":"2E6533BDC93C975EE3C1134B7421A337D5B8FB9C257437DB8B4XXXX4BCD92024B33704B811C69E58527359CA8628E8E33E55AA68B881E6F3D15B5F2FEAEB490B","SupplementalDataQualificationIndicator":0,"networkTransId":"HLH5UGDQFZ98LHRLDGIZEG7"},"messages":{"resultCode":"Ok","message":[{"code":"I00001","text":"Successful."}]}}"
我正在学习这个教程。
我试过这个:
const result = JSON.parse(JSON.stringify(res.response));
console.log('1', result);
结果是:
我想要这样的结果:
{
"transactionResponse": {
"responseCode": "1",
"authCode": "XXXXXX",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "11111111111",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX0002",
"accountType": "AmericanExpress",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "2E6533BDC93C975EE3C1134B7421A337D5B8FB9C257437DB8B4XXXX4BCD92024B33704B811C69E58527359CA8628E8E33E55AA68B881E6F3D15B5F2FEAEB490B",
"SupplementalDataQualificationIndicator": 0,
"networkTransId": "HLH5UGDQFZ98LHRLDGIZEG7"
},
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
请指引我……
2条答案
按热度按时间b5buobof1#
这就是我的问题的答案:
我在res.response中获取此数据:
我解决了这个问题,所以我想我应该要张贴答案,它可能会对别人有帮助。
kxkpmulp2#
有一个NPM包“ngx-authorizenet”,它允许您使用Angular Tags从www.example.com发起付款Authorize.net。
然后在上面的控制器类中设置动作处理程序和配置:https://www.npmjs.com/package/ngx-authorizenet?activeTab=readme