PayPal API and .NET 2.0 compatibility fix
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 (). 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.