Quantcast
Channel: Oomph » .net
Viewing all articles
Browse latest Browse all 2

PayPal API and .NET 2.0 compatibility fix

$
0
0

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.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images