PayPal .NET 2.0The sample API code provided by PayPal has not been updated in some time. When it comes to recent versions of Microsoft’s .NET platform, not only is PayPal missing some DLLs needed to use it ‘out of the box’, the sample functions are actually wrong!

We discovered the problem while working on a custom built .NET web application for the Council of Public Relations Firms that includes integrated eCommerce. Thankfully, with some sleuthing and tinkering, we were able to update the necessary DLLs and correct the functions.

Let’s start with the out of date function documentation; this fix is pretty easy. At some point, PayPal started requiring developers to set some boolean values when passing the credit card expiration month and year.

Original (Example) Code:

pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = CVV2;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = expMonth;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = expYear;

Corrected Code:

pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = CVV2;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = expMonth;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonthSpecified = true;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = expYear;
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYearSpecified = true;

Without those boolean values, the PayPal API server will send back a failure error indicating that the credit card expiration month and year are missing, even if they were sent. This change is required in all functions that use the credit card, either both provided by PayPal or written by the developer.

The bigger hurdle is the pre-compiled DLL provided by PayPal, which is missing support DLLs and will not run under .NET 2.0 or newer. To make the DLL yourself, you’ll need the PayPal SDK (available here). With some direction from a variety of forums and some tinkering on my own part, I was able to use the SDK source to create and compile a .NET 2.0 compatible DLL with the required support DLLs.

We’ve made the package available here: PayPal ASP.NET 2.0 SDK Compiled

To use it, just extract the files into your ASP.NET “Bin” folder.

What do you think?

*(required)

Allen Waldrop

By Allen Waldrop

Web Software Engineer

Allen is a locally trained software engineer with a focus on web technologies, including PHP, MySQL, ASP, C#, and SQL Server. He has an uncanny ability to switch from programming language to language with remarkable ease. Allen takes a keen interest in working with web-based system APIs and has recently worked with APIs from Salesforce.com, Google, Acuity, Satuit and Ning to achieve data interoperability between client systems and these third party services.

Read More About Allen Follow on Twitter

Post Meta

Topics

Programming

Tags (Keywords)

, , , , ,

Oomph is a full-service digital agency providing strategy, design & development and a host of other web services. A leader in WordPress and Drupal implementation, Oomph pushes the boundaries of today’s web platforms. Oomph has a diverse portfolio of non-profits, international corporations and publications. Team Oomph is always thinking creatively about the digital world. Oomph is located in Providence and Boston.