I've been trying to find a valid and good example on how to use the PayPal's TransactionSearch method which returns the history of all transactions for the specified time range..
I've stumbled upon this example:
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);
}
But most of these classes are unavailable. I've installed PayPal .NET SDK and PayPal Merchant API...
Am I missing something here or these classes have been removed/ ie. new method of writing this request has been introduced?
Edit: just found a solution (For those who might need this in the future)
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;