PayPal缺少凭据 - TransactionSearch(经典API)

时间:2015-01-20 20:35:43

标签: c# paypal paypal-ipn paypal-sandbox

我试图调用TransactionSearch。但我得到了异常缺少凭据异常 enter image description here 这是我的代码



TransactionSearchResponseType responseTransactionSearchResponseType = new TransactionSearchResponseType();
TransactionSearchReq requestTransactionSearch = new TransactionSearchReq();
TransactionSearchRequestType transactionSearchRequest = new TransactionSearchRequestType("2012-12-25T00:00:00+0530");
requestTransactionSearch.TransactionSearchRequest = transactionSearchRequest;

Dictionary<string, string> paypalConfig = new Dictionary<string, string>();
paypalConfig.Add("apiUsername", "userName");
paypalConfig.Add("apiPassword", "passowrd");
paypalConfig.Add("apiSignature", "Signature");
paypalConfig.Add("appid", "appID");
paypalConfig.Add("ipn","https://www.paypal.com/cgi-bin/webscr");
paypalConfig.Add("url", "https://www.paypal.com/webscr&cmd=_express-checkout&token=");
paypalConfig.Add("endpoint", "https://api-3t.paypal.com/2.0/");
paypalConfig.Add("mode", "live");

PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(paypalConfig);
responseTransactionSearchResponseType = service.TransactionSearch(requestTransactionSearch);
&#13;
&#13;
&#13; 这是什么原因? 这不是我的凭证的问题。那么我的根本原因是什么?

请帮助我 谢谢

1 个答案:

答案 0 :(得分:1)

PayPal核心SDK 中的CredentialManager PayPal商家SDK 使用并且是此异常的来源)需要经典的帐户详细信息配置中的应用程序前面有account#.令牌。因此,对于单个帐户,如您设置代码的方式,配置详细信息应指定如下:

Dictionary<string, string> paypalConfig = new Dictionary<string, string>();
paypalConfig.Add("account1.apiUsername", "userName");
paypalConfig.Add("account1.apiPassword", "passowrd");
paypalConfig.Add("account1.apiSignature", "Signature");
paypalConfig.Add("account1.applicationId", "appID");
paypalConfig.Add("IPNEndpoint","https://www.paypal.com/cgi-bin/webscr");
paypalConfig.Add("url", "https://www.paypal.com/webscr&cmd=_express-checkout&token=");
paypalConfig.Add("endpoint", "https://api-3t.paypal.com/2.0/");
paypalConfig.Add("mode", "live");

可以通过递增account#.令牌来添加配置中的后续帐户。

此外,上面的代码更正了以下两个配置属性名称:

  • appid应为account#.applicationId
  • ipn应为IPNEndpoint

有关配置密钥的更多信息,请访问here