PayPal Classic API Authenticates one call but not the next

左心房为你撑大大i 提交于 2020-01-15 19:22:08

问题


I am trying to download transaction history from PayPal. To do this I am calling TransactionSearch to get a basic list of transactions within a date range. I then call GetTransactionDetails to get the full details of each transaction.

        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. The Second call to GetTransactionDetails returns an error:

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.

Has anyone seen this before?


回答1:


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"

You can hard code the API credentials and then try .



来源:https://stackoverflow.com/questions/26277889/paypal-classic-api-authenticates-one-call-but-not-the-next

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!