gpt4 book ai didi

c# - PayPal Classic API 验证一个调用但不验证下一个

转载 作者:太空宇宙 更新时间:2023-11-03 16:01:26 26 4
gpt4 key购买 nike

我正在尝试从 PayPal 下载交易历史记录。为此,我调用 TransactionSearch 来获取日期范围内交易的基本列表。然后我调用 GetTransactionDetails 以获取每笔交易的完整详细信息。

        using (var client = new PayPalService.PayPalAPIInterfaceClient())
{
var credentials = new PayPalService.CustomSecurityHeaderType
{
Credentials = new PayPalService.UserIdPasswordType
{
Username = "MyUserName",
Password = "MyPassword",
Signature = "MySignature"
}
};

TransactionSearchReq request = new TransactionSearchReq();
request.TransactionSearchRequest = new TransactionSearchRequestType();
request.TransactionSearchRequest.StartDate = DateTime.Now.AddHours(-12);
request.TransactionSearchRequest.EndDate = DateTime.Now;
request.TransactionSearchRequest.Version = "117.0";

TransactionSearchResponseType transactionSearchResponseType = client.TransactionSearch(ref credentials, request);
foreach (PaymentTransactionSearchResultType t in transactionSearchResponseType.PaymentTransactions)
{
var reqType = new GetTransactionDetailsRequestType
{
TransactionID = t.TransactionID,
Version = "117.0"
};
reqType.DetailLevel = new DetailLevelCodeType[1];
reqType.DetailLevel[0] = DetailLevelCodeType.ReturnAll;

var treq = new GetTransactionDetailsReq
{
GetTransactionDetailsRequest = reqType
};
GetTransactionDetailsResponseType transaction = client.GetTransactionDetails(ref credentials, treq);
}

}

TransactionSearch 的第一次调用有效并返回了一个交易列表。第二次调用 GetTransactionDetails 返回错误:

Error Code: "10002"
Long Message: "You do not have permissions to make this API call"
Short Message: "Authentication/Authorization Failed"
Correlation ID: 67970b9729a82
Ack: Failure
Build: 000000
Version: "117.0"
Any: null
PropertyChanged: null

我已经三次检查我在调用中传递的 TransactionId 是否是我的有效交易之一,它是。

有人见过这个吗?

最佳答案

似乎有些凭据没有在您的代码中为给定变量传递。确保以下变量包含值:

用户名 = "我的用户名",密码 = "我的密码",Sgnature = "我的签名"

您可以对 API 凭据进行硬编码,然后尝试 .

关于c# - PayPal Classic API 验证一个调用但不验证下一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26277889/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com