贝宝争议沙盒测试

Paypal Disputes Sandbox Testing

我试图在沙盒中测试贝宝争议并遵循本指南: https://developer.paypal.com/docs/integration/direct/customer-disputes/integration-guide/#sandbox-only-methods.

然而,在步骤 2(获得买家的许可)中,paypal 提供的用于生成连接按钮的代码抛出 js 语法错误,因此我将其更改为:

<span id='cwppButton'></span>
<script src="https://www.paypalobjects.com/js/external/connect/api.js"></script>
<script>
        paypal.use( ['login'], function (login) {
                login.render ({
                        "appid": "MY_CLIENT_ID",
                        "authend": "sandbox",
                        "scopes": "openid",
                        "containerid": "cwppButton",
                        "locale": "en-us",
                        "buttonType": "CWP",
                        "buttonSize": "lg",
                        "returnurl": "https://a62add0d.ngrok.io/api/payments/paypal/get-token/"
                });
          });
</script>

你怎么能看到我将范围更改为 "openid",因为在此示例中由 paypal 提供的分隔链接给了我 "Invalid Scope" 错误 但是我在这一步中从按钮获得了访问令牌。 我面临的下一个问题是在第 4 步(为 PayPal 授权断言生成 JSON 网络令牌),paypal 提供的代码给出了语法错误,所以我将其替换为:

<span id='cwppButton'></span>
<html>
<script>
            function base64url(source) {
                    encodedSource = btoa(source);
                    encodedSource = encodedSource.replace(/=+$/, '"');
                    encodedSource = encodedSource.replace(/\+/g, '-');
                    encodedSource = encodedSource.replace(/\//g, '-');

                    return encodedSource;
            }
            function generateJWT() {
                    var header = {"alg": "none", "typ": "JWT"};
                    var data = {"iss"   :"MY_CLIENT_ID",
                               "email" : "casino.player@gmail.com" };
                    document.write(base64url(JSON.stringify(header)) + "." +
                    base64url(JSON.stringify(data)) + ".");
            }
</script>
<body onload="generateJWT()"/>

结果 运行 在第 6 步创建争议请求时出现此错误:

{
    "error": "invalid_request",
    "error_description": "No permissions to set target_client_id"
}

我的问题是如何在沙盒中正确设置和测试贝宝争议?如果有人在争议测试中遇到同样的问题?

从步骤 1 https://developer.paypal.com/docs/integration/direct/customer-disputes/integration-guide/#sandbox-only-methods :

Set up your REST app with the following scope:

https://uri.paypal.com/services/disputes/create = DISPUTE_CREATE

你做到了吗?第一步可能需要通过 PayPal 为您的沙盒帐户/沙盒客户端 ID REST APP 完成,因为您正在集成需要批准的 API。

然后,您将能够完成必要范围内的第 2 步。


如果没有所需的范围和权限,您将在第 4 步中遇到该错误。