title: Paypal PHP SDK Payout in Laravel
body: <p>I am getting </p>
  
  <blockquote>
    <p>PayPal \ Exception \ PayPalConnectionException (500)</p>
  </blockquote>
  
  <p>I am getting Http response code 500 when accessing <em><a href="https://api.sandbox.paypal.com/v1/payments/payouts" rel="nofollow noreferrer">https://api.sandbox.paypal.com/v1/payments/payouts</a>?</em> when I try to process a batch payout with Pypal PHP SDK</p>
  
  <p>Here is My Controller:</p>
  
  <pre><code>private $_api_context;
  public function __construct()
  {
      /** setup PayPal api context **/
      $paypal_conf = Config::get('paypal');
      $this-&gt;_api_context = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['client_secret']));
      $this-&gt;_api_context-&gt;setConfig($paypal_conf['settings']);
  }
  
  public function batchPayout(){
      $payouts    =   new Payout();
      $senderBatchHeader  = new PayoutSenderBatchHeader();
  
      $senderBatchHeader-&gt;setSenderBatchId(uniqid())
          -&gt;setEmailSubject("You have a ");
  
      $senderItem1    =   new PayoutItem();
      $senderItem1-&gt;setRecipientType('Email')
          -&gt;setNote("New Payment")
          -&gt;setReceiver('xxx@gmail.com')
          -&gt;setSenderItemId(uniqid())
          -&gt;setAmount(new Currency('{
          "value":"99",
          "currency":"USD"
          }'));
  
      $payouts-&gt;setSenderBatchHeader($senderBatchHeader)
          -&gt;addItem($senderItem1);
  
      $request    =   clone $payouts;
  
      try{
          $output =   $payouts-&gt;create(null, $this-&gt;_api_context);
      }catch (Exception $ex){
          return $ex-&gt;getMessage();
      }
      return $output;
  }}
  </code></pre>