title: How to save in database the data response by paypal in laravel?
body: <p>I am trying to save the data in database which is response by paypal.
  Here is my try, I get the data from paypal response like this.</p>
  
  <pre><code>public function getDone(Request $request)
  {
      $id = $request-&gt;get('paymentId');
      $token = $request-&gt;get('token');
      $payer_id = $request-&gt;get('PayerID');
  
      $payment = PayPal::getById($id, $this-&gt;_apiContext);
  
      $paymentExecution = PayPal::PaymentExecution();
  
      $paymentExecution-&gt;setPayerId($payer_id);
      $executePayment = $payment-&gt;execute($paymentExecution, $this-&gt;_apiContext);
  
  
      print_r($executePayment);
  }
  </code></pre>
  
  <p>the result is here </p>
  
  <pre><code>PayPal\Rest\ApiContext Object ( [requestId:PayPal\Rest\ApiContext:private] =&gt; 216056242044171493312944593 [credential:PayPal\Rest\ApiContext:private] =&gt; PayPal\Auth\OAuthTokenCredential Object ( [logger:PayPal\Auth\OAuthTokenCredential:private] =&gt; PayPal\Core\PayPalLoggingManager Object ( [loggerName:PayPal\Core\PayPalLoggingManager:private] =&gt; PayPal\Auth\OAuthTokenCredential [isLoggingEnabled:PayPal\Core\PayPalLoggingManager:private] =&gt; [loggingLevel:PayPal\Core\PayPalLoggingManager:private] =&gt; [loggerFile:PayPal\Core\PayPalLoggingManager:private] =&gt; ) [clientId:PayPal\Auth\OAuthTokenCredential:private] =&gt; AVFGCgHNihKu_MpwgbpDPuB9FO8Z5hdgGrEx1mZPhQoOs2vLzFf1Dv6qA2bN5Ja_qucPYkN0X5Hrz9ZE [clientSecret:PayPal\Auth\OAuthTokenCredential:private] =&gt; EBdP51X4tMAi9WYcgI1ue0TQLljyvDBxO1yQAFJn7X7z_GP7mAOMnAsDCsREotfEOCESD_D6Qp14plTy [accessToken:PayPal\Auth\OAuthTokenCredential:private] =&gt; A21AAG85CiMoJ6JFJfQIfSMdzPm1sbwy7AZcT1zyxNbfw2-WXms8hgALJK3uFJy9DfG3oVQTKrIEApTwvDoiXAp49SrIiBfmw [tokenExpiresIn:PayPal\Auth\OAuthTokenCredential:private] =&gt; 32315 [tokenCreateTime:PayPal\Auth\OAuthTokenCredential:private] =&gt; 1493312949 [cipher:PayPal\Auth\OAuthTokenCredential:private] =&gt; PayPal\Security\Cipher Object ( [secretKey:PayPal\Security\Cipher:private] =&gt; EBdP51X4tMAi9WYcgI1ue0TQLljyvDBxO1yQAFJn7X7z_GP7mAOMnAsDCsREotfEOCESD_D6Qp14plTy ) [_propMap:PayPal\Common\PayPalModel:private] =&gt; Array ( ) ) )
  </code></pre>
  
  <p>I want to save in database and how i try to do it is here</p>
  
  <pre><code>public function getDone(Request $request)
  {
      $id = $request-&gt;get('paymentId');
      $token = $request-&gt;get('token');
      $payer_id = $request-&gt;get('PayerID');
  
      $payment = PayPal::getById($id, $this-&gt;_apiContext);
  
      $paymentExecution = PayPal::PaymentExecution();
  
      $paymentExecution-&gt;setPayerId($payer_id);
      $executePayment = $payment-&gt;execute($paymentExecution, $this-&gt;_apiContext);
  
        if($request-&gt;tx){
          if($payment=Payment::where('transaction_id',$request-&gt;tx)-&gt;first()){
              $payment_id=$payment-&gt;id;
          }else{
              $payment=new Payment;
              $payment-&gt;transaction_id=$request-&gt;email;
              $payment-&gt;transaction_id=$request-&gt;name;
              $payment-&gt;item_number=$request-&gt;item_number;
              $payment-&gt;transaction_id=$request-&gt;tx;
              $payment-&gt;currency_code=$request-&gt;cc;
              $payment-&gt;payment_status=$request-&gt;st;
              $payment-&gt;save();
              $payment_id=$payment-&gt;id;
          }
      return 'Pyament has been done and your payment id is : '.$payment_id;
  
      }else{
          return 'Payment has failed';
      }
  
  
  
  }
  </code></pre>
  
  <p>The error is showing like </p>
  
  <blockquote>
    <p>Payment has failed</p>
  </blockquote>
  
  <p>Here is my database which is trying to save in </p>
  
  <pre><code> public function up()
  {
      Schema::create('payments', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;string('email');
          $table-&gt;string('name');
          $table-&gt;string('item_number');
          $table-&gt;string('transaction_id');
          $table-&gt;string('currency_code');
          $table-&gt;string('payment_status');
          $table-&gt;timestamps();
      });
  }
  </code></pre>
  
  <p>Where am i wrong in my codes, please guide me to save in database.
  Please guide me. Thanks.</p>