PayPal’s New API: So Close, Yet So Far

I got an email from the PayPal Developer Network today announcing PayPal’s new “NVP” (or “Name-Value Pair“) API. Clearly they’ve learned that the complexity of SOAP is counter productive to adoption. Here’s what the email had to say about their new API:

NVP Is Your Integration MVP
We’re proud to announce that PayPal’s Name-Value Pair API has launched. Complex SOAP structure is now gone. All API methods are supported, except for AddressVerify. Get exclusive sample code – download two SDKs (Java and .NET). Get Details

Taking a look at their examples (in .ASP, .PHP, or ColdFusion) and their SDKs (for Java and ASP.NET [v1.1]) it’s nice to see they are using POST instead of GET. The following is one of their functions from their PHP examples (CallerService.php) that illustrates how their code is calling their NVP API (I edited for line-length only):

function hash_call($methodName,$nvpStr)
   //declaring of global variables
   global $API_Endpoint,$version,$API_UserName,

   //setting the curl parameters.
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
   curl_setopt($ch, CURLOPT_VERBOSE, 1);

   //turning off the server and peer verification
   //(TrustManager Concept).
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
   curl_setopt($ch, CURLOPT_POST, 1);

   //if USE_PROXY constant set to TRUE in Constants.php,
   //then only proxy will be enabled. if USE_PROXY constant
   //set to TRUE in Constants.php, then only proxy will be
   //Set proxy name to PROXY_HOST and port number to
   // PROXY_PORT in constants.php
      curl_setopt ($ch,

   //NVPRequest for submitting to server
   $nvpreq= “METHOD=”.urlencode($methodName).

   //setting the nvpreq as POST FIELD to curl

   //getting response from server
   $response = curl_exec($ch);

   //convrting NVPResponse to an Associative Array

   if (curl_errno($ch)) {
        // moving to display page to display curl errors
        $_SESSION['curl_error_no']=curl_errno($ch) ;
        $location = “APIError.php”;
        header(“Location: $location”);
    } else {
        //closing the curl

return $nvpResArray;

Much nicer and simplier than having to go to all the effort to set up a SOAP call.

Unfortunately, PayPal missed a huge opportunity to make their new API fully RESTful. Instead of designing a URL-centric REST interface (with a hypermedia component to keep the purist or the pure RESTafarians happy) they instead tunneled method calls over HTTP!  They used methods like “DoDirectPayment” and “RefundTransaction” Sheesh! (Note: these links to their methods load slower than any website I can remember visiting in ages and while loading my browser does lots of clicking. What the heck is going on in there I have no idea! You can go to the main docs via a much faster downloading PDF here. Wow, if that isn’t usually an oxymoron!)

Though much easier than calling SOAP, clearly not very RESTful.  Three steps forward, and two steps back. Sigh…

This entry was posted in Commentary, Framework Developers, Leading Companies, REST, SOAP, SoapBox, Web Developers, Website Owners. Bookmark the permalink.

2 Responses to PayPal’s New API: So Close, Yet So Far

  1. Dinakar says:

    I am using NVP over SOAP for my website. my manager says SOAP is better because in NVP, if the server goes down, it will be a problem. But, isnt it a problem either way? if the server goes down, the webservice (i.e., even using SOAP API) also goes down with it ….am I correct?

  2. As far as I’m concerned SOAP is a complete nightmare and yes, you are correct if the server goes down it’s the same problem. That is unless you use SOAP over store-and-forward mechanisms (like SMTP) instead of over HTTP but then what you are doing is a completely different type of web service.

    Let me repeat, SOAP is a nightmare. RESTful web services are the way to go. If you need high-availability, use Amazon EC2 or something similar.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>