我一直在努力寻找一个有效且良好的例子来说明如何使用PayPal的TransactionSearch方法,该方法返回指定时间范围内所有交易的历史记录。
我偶然发现了这个例子:
AccountType accountType = AccountType.Live;
tblPayPalAccount account = PayPalAPICallHelperSOAP.GetAccount(accountType);
DateTime endDate = new DateTime(2012, 1, 1);
DateTime startDate = new DateTime(2012, 12, 31);
using (PayPalAPIInterfaceClient client = new PayPalAPIInterfaceClient())
{
client.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://api-3t.paypal.com/2.0");
UserIdPasswordType userIdPasswordType = PayPalAPICallHelperSOAP.GetUserIdPasswordType(account);
CustomSecurityHeaderType header = new CustomSecurityHeaderType();
header.Credentials = userIdPasswordType;
TransactionSearchReq request = new TransactionSearchReq();
request.TransactionSearchRequest = new TransactionSearchRequestType();
request.TransactionSearchRequest.Version = account.version;
request.TransactionSearchRequest.StartDate = startDate;
request.TransactionSearchRequest.EndDate = endDate;
TransactionSearchResponseType transactionSearchResponseType = client.TransactionSearch(ref header, request);
}
但是大多数这些课程都不可用。我已经安装了PayPal .NET SDK和PayPal Merchant API ......
我在这里遗漏了什么或这些课程已被删除/即。编写此请求的新方法已经引入?
编辑:刚找到一个解决方案(对于那些将来可能需要这个的人)
DateTime endDate = new DateTime(2016, 11, 1);
DateTime startDate = new DateTime(2016, 12, 1);
TransactionSearchReq req = new TransactionSearchReq();
req.TransactionSearchRequest = new TransactionSearchRequestType();
req.TransactionSearchRequest.StartDate = startDate.ToString();
req.TransactionSearchRequest.EndDate = endDate.ToString();
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(Configuration.GetConfig());
//Configuration.GetConfig(); => load the NVP SOAP data from config file...
TransactionSearchResponseType transactionSearchResponseType = service.TransactionSearch(req);
return transactionSearchResponseType;