贝宝合作伙伴推荐 API URL

PayPal Partner Referrals API URL

使用 Node 调用 PayPal API 时,我在设置合作伙伴推荐时遇到问题。

每次我尝试调用 API 时,我都会收到以下错误:

error: "invalid_token" error_description: "The token passed in was not found in the system"

根据 documentation 调用 URL 是 https://api-m.sandbox.paypal.com/v2/customer/partner-referrals

查看 URL 和错误消息,我相信我收到此错误是因为我使用的是生产凭据,而不是沙箱。但是,我找不到任何显示此产品的文档 URL。

我认为这是沙盒 URL 是否正确?如果是这样,产量是多少URL?

我遵循了 onboarding checklist 但似乎无法完成这项工作。

这是我的代码:

 getAuthToken = async () => {
    const clientIdAndSecret = "mylongsecret";
    const authUrl = "https://api-m.paypal.com/v1/oauth2/token";
    const base64 = Buffer.from(clientIdAndSecret).toString('base64')

    const response = await fetch(authUrl, { 
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'Accept-Language': 'en_US',
            'Authorization': `Basic ${base64}`,
        },
        body: 'grant_type=client_credentials'
    });
    const data = await response.json();
    return data;
}

setUpMerchant = async () => {
    let authData = await this.getAuthToken();
    const partnerUrl = "https://api-m.sandbox.paypal.com/v2/customer/partner-referrals";
    let data = {
        "operations": [
          {
            "operation": "API_INTEGRATION",
            "api_integration_preference": {
              "rest_api_integration": {
                "integration_method": "PAYPAL",
                "integration_type": "THIRD_PARTY",
                "third_party_details": {
                  "features": [
                    "PAYMENT",
                    "REFUND"
                 ]
                }
              }
            }
          }
        ],
        "products": [
          "EXPRESS_CHECKOUT"
        ],
        "legal_consents": [
          {
            "type": "SHARE_DATA_CONSENT",
            "granted": true
          }
        ]
    };
    const request = await fetch(partnerUrl, { 
        method: 'POST', 
        headers: {
          'Authorization': 'Bearer '+authData.access_token, 
          'Content-Type': 'application/json',
          'data': data,
        }, 
    });
    const partnerData = await request.json();
    return partnerData;
}

编辑:我发现问题是我 运行 是 GET 请求而不是 POST。接受的答案是正确的 URL

According to the documentation the URL to call is https://api-m.sandbox.paypal.com/v2/customer/partner-referrals

作品 URL 在域中没有 sandbox.