有什么方法可以代表客户添加跟踪信息吗?

Is there any way to add tracking info on behalf of the clients?

有没有什么方法可以使用新的 REST API 代表其他客户添加跟踪信息字段? 如果没有,我仍然可以创建使用旧 API 或任何其他方式的贝宝应用程序吗?

有一个旧的 Question 演示了我正在尝试做的事情。

按照此 Documentation page 我设法使用以下 C# 代码更新了我的沙盒帐户信息...

private static string SendRequest()
{
    var client = new HttpClient();
    var end_point = "https://api.sandbox.paypal.com/v1/shipping/trackers-batch";
    try
    {
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
        var requestMessage = new HttpRequestMessage
        {
            RequestUri = new Uri(end_point),
            Method = HttpMethod.Post,

        };
        string clientId = "";
        string secret = "";

        requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Basic",
            Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes($"{clientId}:{secret}")));

        string body = File.ReadAllText("data.json");
        requestMessage.Content = new StringContent(body, Encoding.UTF8, "application/json");
        var x = client.SendAsync(requestMessage).Result;
        string responseStr = x.Content.ReadAsStringAsync().Result;

        return responseStr;
    }
    catch (Exception exp)
    {
        Debug.Print(exp.Message);
        return null;
    }
    finally
    {
        client.Dispose();
    }
}

data.json

{
  "trackers": [
    {
      "transaction_id": "04YE27.....",
      "tracking_number": "443844....",
      "status": "SHIPPED",
      "carrier": "FEDEX"
    }
  ]
}

但它无法更新另一个 SandBox 帐户数据,即使我从该帐户设置向我的应用程序授予了权限。这是服务器响应:

{
   "tracker_identifiers":[

   ],
   "errors":[
      {
         "name":"NOT_AUTHORIZED",
         "message":"Authorization failed due to insufficient permissions",
         "details":[
            {
               "field":"/trackers/1/transaction_id",
               "value":"04YE27.....",
               "location":"body",
               "issue":"USER_NOT_AUTHORIZED",
               "description":"You are not authorized to add or modify tracking number for this transaction"
            }
         ],
         "links":[

         ]
      }
   ],
   "links":[
      {
         "href":"https://api.sandbox.paypal.com/v1/shipping/trackers-batch",
         "rel":"self",
         "method":"POST",
         "encType":"application/json"
      }
   ]
}

我可以要求用户授予我的应用所需的权限。但我不能要求每个人都创建一个应用程序并给我他们的客户端 ID 和密码。

I can't ask everyone to create an app and give me their Client ID and secret.

这正是您需要做的,才能对他们的 PayPal 帐户中的交易级别信息进行这种级别的精细控制。

除了为您创建应用程序并共享其凭据外,他们没有授予权限的机制。

If not, can I still create paypal apps that use the old API, or any other way?

旧的 API 和应用程序不提供更新跟踪信息的方法。它们也不支持新的集成,不应再使用(仅向后 compatibility/maintenance)