尝试整合sofort时我在做什么错?

时间:2019-04-10 20:28:45

标签: node.js integration payment-gateway

我尝试将sofort作为一种付款选项集成到我的node js应用程序中,但是即使我使用了github文档中显示的示例,也始终记录错误:

C:\Users\User\Desktop\shopping-cart\node_modules\node- 
sofort\lib\sofort.js:124
                    throw new SofortException('Error postData', ['401 
Unauthorized'],
  response.statusCode);
                    ^
SofortException: Error postData -> 401 Unauthorized

这是我使用的代码:

router.get('/sofort', function(req, res, next) {
'use strict';
var util = require('util');
var Sofort = new (require('node-sofort'))({
    configKey : '12345:12345:70967t65668a0f89be9b6d381822d'
});

try {
   Sofort.createPayment(10.00, 'EUR', ['Demo1'], {}, function (err, data) {
    console.log(data);
});
} catch (e) {
    console.log(e);
}


try {
    Sofort.parseNotification('<?xml version="1.0" encoding="UTF-8" ?> 
    <status_notification><transaction>27276-146697-55E48EAD- 
    A3EB</transaction><time>2015-08-30T22:30:29+02:00</time> 
    </status_notification>',function(err,result){
    console.log(util.inspect(result, {showHidden: false, depth: null}));
});
} catch (e) {
    console.log(e);
}
})

0 个答案:

没有答案