paypal - 有什么方法可以代表客户添加跟踪信息?
问题描述
有没有办法使用新的 REST API 代表其他客户添加跟踪信息字段?如果没有,我还能创建使用旧 API 或任何其他方式的贝宝应用程序吗?
有一个老问题展示了我正在尝试做的事情。
通过遵循此文档页面,我设法使用以下 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();
}
}
数据.json
{
"trackers": [
{
"transaction_id": "04YE27.....",
"tracking_number": "443844....",
"status": "SHIPPED",
"carrier": "FEDEX"
}
]
}
但是,即使我将该帐户设置中的权限授予我的应用程序,它也无法更新另一个沙盒帐户数据。这是服务器响应:
{
"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 和密码。
解决方案
我不能要求每个人都创建一个应用程序并给我他们的客户 ID 和密码。
这正是您需要做的,以便对其 PayPal 帐户中的交易级别信息进行这种级别的精细控制。
除了为您创建应用程序并共享其凭据之外,他们没有授予权限的机制。
如果没有,我还能创建使用旧 API 或任何其他方式的贝宝应用程序吗?
旧的 API 和应用程序不提供更新跟踪信息的方法。新集成也不支持它们,并且不应再使用它们(仅限向后兼容性/维护)
推荐阅读
- nginx - 如何禁用 NGINX 静态媒体 URL 根
- android - 使用视图寻呼机从 android 中的 mysql 获取图像的图像滑块
- sql - 如何在更新中将 bigint 转换为 postgres 中的时区时间戳
- vue.js - vue-router 在每条新路由上重新加载 App.vue
- google-analytics - 谷歌标签管理器 - 数据层
- sql - 用于报表的大表的 Oracle 查询优化
- java - 如何打印过滤行的特定列值
- reactjs - NextJS:在多个页面的多个路由中使用相同的组件
- java - java.lang.RuntimeException:无法启动活动 android.content.res.Resources$NotFoundException:资源 ID #0x7f110002
- php - 在php中制作动态数组