Nodejs SOAP Payex提供错误代码ValidationError_HashNotValid

时间:2016-12-18 02:56:57

标签: node.js soap

谢谢你的时间!我尝试使用NodeJS建立SOAP连接以使用Payex验证卡。连接有效,但Payex返回:

Initialize8Result: '<?xml version="1.0" encoding="utf-8" ?>
  <payex>
    <header name="Payex Header v1.0">
      <id>7e6eb2d7317c4ca5ae3bec074ed9f4c4</id>
      <date>2016-12-18 01:45:13</date>
    </header>
    <status>
      <code>ValidationError_HashNotValid</code>
      <errorCode>ValidationError_HashNotValid</errorCode>
      <description>Admin.ValidateMerchantLogon:Invalid hash</description>
      <paramName /><thirdPartyError />
    </status>
  </payex>'

我不能为我的生活找出原因。我跟着the documentation located here。当前连接如下所示:

const soap = require('soap');
const crypto = require('crypto')

module.exports = (req, res) => {
    const wsdlUrl = 'https://external.externaltest.payex.com/pxorder/pxorder.asmx?WSDL';
    const encryptionKey = 'encryptionkey';

    const sendData = {
        AccountNumber: 1111111,
        purchaseOperation: 'AUTHORIZATION',
        price: 100,
        priceArgList: '',
        currency: 'NOK',
        vat: 0,
        orderID: 'test',
        productNumber: '1',
        description: 'test description',
        clientIPAddress: '127.0.0.1',
        clientIdentifier: 'USERAGENT=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
        additionalValues: 'RESPONSIVE=1',
        externalID: '',
        returnUrl: 'http://google.com',
        view: 'CREDITCARD',
        agreementRef: '',
        cancelUrl: 'http://google.com',
        clientLanguage: 'nb-NO',
    };

    const encryptString = Object.keys(sendData).map(key => sendData[key]).join('') + encryptionKey;
    const hash = crypto.createHash('md5').update(encryptString).digest('hex');

    sendData['hash'] = hash;

    soap.createClient(wsdlUrl, (err, soapClient) => {
        if (err) {
            return res.status(500).json(err);
        }
        soapClient.Initialize8(sendData, (err, res) => {
            if (err) {
                return res.status(500).json(err);
            }
            console.log(res);
        });
    });
};

我希望你们中的一个人看到我哪里出错了!谢谢&lt; 3

1 个答案:

答案 0 :(得分:1)

不得不改为 accountNumber: 1111111,

好的,payex的节点解决方案,如果有人想要/需要它,那么:)