title: PAYPAL RESTful API execute call occasional error
body: <p>I have fully integrated my website with paypal using  paypal RESTful's API PHP SDK. Now my problem is every once in a while on the payment process, once the user approves the payment and it comes back to my website for execution, the API execution request comes back with the following responses from paypal. The HTTP response code's in these scenarios are 400 and 500. Below I have listed the error name and error message which comes as a part of the JSON response I get form paypal on execute action (<a href="https://api.paypal.com/v1/payments/payment/PAY-xxxxxxxxxxxxxxxxxxxxxxxxxx/execute" rel="nofollow">https://api.paypal.com/v1/payments/payment/PAY-xxxxxxxxxxxxxxxxxxxxxxxxxx/execute</a>):</p>
  
  <p>400 PAYMENT_NOT_APPROVED_FOR_EXECUTION,Payer has not approved payment
  500 INTERNAL_SERVICE_ERROR,An internal service error has occurred</p>
  
  <p>In terms of the code I use to make that call I have added the function which executes the payment. I should add that this is working in 98% of times. Below is the code:</p>
  
  <pre><code>public function getExecute()
  {
      // Payment is cancelled
      if (!(Input::get('success') &amp;&amp; Input::get('success') == 'true')) 
          return $this-&gt;runPaymentExitProcess();
  
      // No paymentId
      if (!Session::has('paymentId')) 
          return "No payment id to execute";
  
      $paymentId = Session::get('paymentId');
  
  
      $this-&gt;payment = Payment::get($paymentId, $this-&gt;apiContext);
  
      // The payer_id is added to the request query parameters when the user is redirected from paypal back to your site
      $this-&gt;execution-&gt;setPayer_id(Input::get('PayerID'));
  
      $response = $this-&gt;payment-&gt;execute($this-&gt;execution, $this-&gt;apiContext);
  
  
      // Check for paypal errors
      if (isset($response-&gt;name)) {
          // When we have a paypal error
          if ($this-&gt;hasPaypalError($response)) {
              $error = array('name' =&gt; $response-&gt;name, 'message' =&gt; $response-&gt;message);
  
  
      Session::put('error', $error);
  
              return (MODE == 'LIVE') ? Redirect::to('/paypalerror') : Redirect::to('/paypalerror'.MODE_PARAM);
              die;
          }   
      }   
  
      // Unset session
      Session::forget('paymentId');
  
      // execution successful
      if ($this-&gt;addPaymentIdToUser($paymentId))
          return (MODE == 'LIVE') ? Redirect::to('/') : Redirect::to('/'.MODE_PARAM);
  
  }
  </code></pre>
  
  <p>The code is in laravel. Please note that the $this->apiContext is set in the constructor of the class. Also this is the function is the success url which is set in the API under redirect_urls. </p>
  
  <p>Can someone please help me figure out if this issue is coming from my side or Paypal's side?</p>