title: Error in Paypal authentication in Sandbox mode : Laravel 5.5
body: <h1><strong><a href="http://learninglaravel.net/integrate-paypal-sdk-into-laravel-4-laravel-5/link" rel="nofollow noreferrer">Reference</a></strong></h1>
  
  <p><strong>Code</strong></p>
  
  <pre><code>public function ShowPaymentWithPaypal()
  {
      $payer = new Payer();
      $payer-&gt;setPaymentMethod('paypal');
      $item_1 = new Item();
      $item_1-&gt;setName('Item 1') /** item name **/
          -&gt;setCurrency('USD')
          -&gt;setQuantity(1)
          -&gt;setPrice(2); /** unit price **/
  
      $item_list = new ItemList();
      $item_list-&gt;setItems(array($item_1));
      $amount = new Amount();
      $amount-&gt;setCurrency('USD')
          -&gt;setTotal(2);
  
      $transaction = new Transaction();
      $transaction-&gt;setAmount($amount)
          -&gt;setItemList($item_list)
          -&gt;setDescription('Your transaction description');
  
      $redirect_urls = new RedirectUrls();
      $redirect_urls-&gt;setReturnUrl(\URL::route('ReturnedFromPaypal')) /** Specify return URL **/
          -&gt;setCancelUrl(\URL::route('CancelledPaymentWithPaypal'));
  
      $payment = new Payment();
      $payment-&gt;setIntent('Sale')
          -&gt;setPayer($payer)
          -&gt;setRedirectUrls($redirect_urls)
          -&gt;setTransactions(array($transaction));
          /** dd($payment-&gt;create($this-&gt;_api_context));exit; **/
  
      try {
          $payment-&gt;create($this-&gt;_api_context);
      } catch (\PayPal\Exception\PPConnectionException $ex) {
          dd($ex);
          if (\Config::get('app.debug')) {
              \Session::put('error','Connection timeout');
              return "Error occured";
              /** echo "Exception: " . $ex-&gt;getMessage() . PHP_EOL; **/
              /** $err_data = json_decode($ex-&gt;getData(), true); **/
              /** exit; **/
          } else {
              \Session::put('error','Some error occur, sorry for inconvenient');
              return "Error occured";
              /** die('Some error occur, sorry for inconvenient'); **/
          }
      }
      foreach($payment-&gt;getLinks() as $link) {
          if($link-&gt;getRel() == 'approval_url') {
              $redirect_url = $link-&gt;getHref();
              break;
          }
      }
      /** add payment ID to session **/
      \Session::put('paypal_payment_id', $payment-&gt;getId());
      if(isset($redirect_url)) {
          /** redirect to paypal **/
          return \Redirect::away($redirect_url);
      }
      \Session::put('error','Unknown error occurred');
      return "Last line error";
  }
  </code></pre>
  
  <h1><strong>What's the problem ?</strong></h1>
  
  <p>When I try to do the login for doing payment using sandbox credentials, I get the below error.</p>
  
  <blockquote>
    <p>We aren't able to process your payment using your PayPal account at
    this time. Please go back to the merchant and try using a different
    payment method.</p>
  </blockquote>
  
  <p><strong><a href="http://learninglaravel.net/integrate-paypal-sdk-into-laravel-4-laravel-5/link" rel="nofollow noreferrer">I am following this to configure Paypal in Laravel 5.5</a></strong></p>
  
  <p><strong>XHR Error Details</strong></p>
  
  <p><a href="https://i.stack.imgur.com/9R2v2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9R2v2.png" alt="enter image description here"></a>
  Am I missing something ?</p>