简体   繁体   English

PayPal Classic API对一个呼叫进行身份验证,但对下一个呼叫则不进行身份验证

[英]PayPal Classic API Authenticates one call but not the next

I am trying to download transaction history from PayPal. 我正在尝试从PayPal下载交易记录。 To do this I am calling TransactionSearch to get a basic list of transactions within a date range. 为此,我要调用TransactionSearch以获得日期范围内的基本交易列表。 I then call GetTransactionDetails to get the full details of each transaction. 然后,我调用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);
            }

        }

The first call to TransactionSearch works and returns me a list of transactions. TransactionSearch的第一个调用起作用,并向我返回交易列表。 The Second call to GetTransactionDetails returns an error: 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

I have triple check that the TransactionId I am passing in the call is one of my valid transactions and it is. 我有三次检查,确认我在通话中传递的TransactionId是我的有效交易之一。

Has anyone seen this before? 谁看过这个吗?

It seems that some how the credentials are not being passed in your code for the given variables . 对于给定的变量,似乎没有如何在代码中传递凭据。 Make sure below variables contain values : 确保以下变量包含值:

Username = "MyUserName", Password = "MyPassword", Sgnature = "MySignature" 用户名=“ MyUserName”,密码=“ MyPassword”,Sgnature =“ MySignature”

You can hard code the API credentials and then try . 您可以对API凭据进行硬编码,然后尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM