2

I want to download PayPal activity via an api. (i.e. just get a report of a month's payments received).

We are using WooCommerce with PayPal ExpressCheckout. It appears to use the NVP api. (I tried using the REST API and got no results).

I've downloaded the merchant-sdk-dotnet samples (https://github.com/paypal/merchant-sdk-dotnet) but had trouble running them. I've tried to extract the few pieces I need and implement them in a console application (see below). (VS2012 C#)

I'm using the sandbox credentials that were in the aspx samples above (but have also tried our live / real credentials).

The code below always results in a AckCodeType.FAILURE (and no transactions).

...
    using PayPal.PayPalAPIInterfaceService;
    using PayPal.PayPalAPIInterfaceService.Model;

    namespace PayPalToDBMerch
    {
        class Program
        {
            static void Main(string[] args)
            {
                TransactionSearchRequestType request = new TransactionSearchRequestType();
                TransactionSearchReq wrapper = new TransactionSearchReq();
                wrapper.TransactionSearchRequest = request;
                Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();
                PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);
                TransactionSearchResponseType transactionDetails = service.TransactionSearch(wrapper);
                if (transactionDetails.Ack == AckCodeType.FAILURE)
                {
                    Console.WriteLine("This is always the result."); // 
                }
                else
                {
                    Console.WriteLine("I never get here.");
                }
            }
        }

Your help is appreciated.

Walter de Jong
  • 1,565
  • 2
  • 12
  • 17

1 Answers1

0

I have found the NVP api is the right one to use in this case. I have found the merchant-sdk-dotnet samples (https://github.com/paypal/merchant-sdk-dotnet) works for this scenario. It helped when I found the .Errors method :-)

    if (transactionDetails.Ack == AckCodeType.FAILURE)
    {
        foreach (var e in transactionDetails.Errors)
        {
            Console.WriteLine(e.LongMessage); // 
        }
    }

I needed to include a StartDate parameter value

request.StartDate = DateTime.Now.AddDays(-30).ToString("yyyy-MM-ddTHH:mm:ss");
Walter de Jong
  • 1,565
  • 2
  • 12
  • 17