调用Paysafe服务器时如何解决错误401

时间:2018-11-15 18:00:20

标签: cors policy unauthorized paysafe

当我致电Paysafe服务器以使用接收到的令牌获取交易详细信息时,我收到错误401。Paysafe正在阻止来自https://localhost的请求?如何解决此问题,我无权访问真正的服务器进行开发。

代码如下:

$.ajax
({
    type: "POST",
    url: "https://api.test.paysafe.com/cardpayments/v1/accounts/1001285700/auths",
    dataType: 'json',
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Basic " + "mycodehere"
    },
    data: {
        "merchantRefNum": "123456789",
        "amount": 5000,
        "settleWithAuth": true,
        "dupCheck": false,
        "card": {
            "paymentToken": result.token
        }
    },
    success: function (data) {
        console.log(data);
    }
});

这是答案:

jquery.js:9631 OPTIONS **https://api.test.paysafe.com/cardpayments/v1/accounts/99999999/auths 401 (Unauthorized)**
send @ jquery.js:9631
ajax @ jquery.js:9176
(anonymous) @ PublicInvoice.aspx?id=93&CompanyId=020000001&Fr=1:734
i @ paysafe.min.js:1
(anonymous) @ paysafe.min.js:1
(anonymous) @ paysafe.min.js:1
i @ paysafe.min.js:1
e.onMessage @ paysafe.min.js:1
t @ paysafe.min.js:1
PublicInvoice.aspx?id=93&CompanyId=020000001&Fr=1:1 Access to XMLHttpRequest at 'https://api.test.paysafe.com/cardpayments/v1/accounts/1001285700/auths' from origin 'https://localhost:8411' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

0 个答案:

没有答案