title: Laravel 5 - Paypal Payment - Pass data form to controller
body: <p>i have problem to store forms inputs after the payment paypal.
  I have pass the data from form (name, phone_ship, address_ship ecc...) to my function orderSave () So i can store data with the other information. But it doesnt work. 
  My variabile $request->get('inputs of form') doesnt exist for function saveOrder</p>
  
  <blockquote>
    <p>Argument 1 passed to
    dixard\Http\Controllers\PaypalController::saveOrder() must be an
    instance of Illuminate\Http\Request, none given, called in
    C:\xampp\htdocs\2016\app\Http\Controllers\PaypalController.php on line
    191 and defined</p>
  </blockquote>
  
  <p>PAYPALCONTROLLER.php</p>
  
  <pre><code>&lt;?php
  
  namespace dixard\Http\Controllers;
  
  use Illuminate\Http\Request;
  
  use dixard\Http\Requests;
  use dixard\Http\Controllers\Controller;
  
  
  
  
  use Illuminate\Foundation\Bus\DispatchesCommands;
  use Illuminate\Routing\Controller as BaseController;
  use Illuminate\Foundation\Validation\ValidatesRequests;
  
  
  
  
  
  use PayPal\Rest\ApiContext;
  use PayPal\Auth\OAuthTokenCredential;
  use PayPal\Api\Amount;
  use PayPal\Api\Details;
  use PayPal\Api\Item;
  use PayPal\Api\ItemList;
  use PayPal\Api\Payer;
  use PayPal\Api\Payment;
  use PayPal\Api\RedirectUrls;
  use PayPal\Api\ExecutePayment;
  use PayPal\Api\PaymentExecution;
  use PayPal\Api\Transaction;
  
  use dixard\Order;
  use dixard\OrderItem;
  
  class PaypalController extends BaseController
  {
      private $_api_context; //conterrà tutte config
  
      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['secret']));
          $this-&gt;_api_context-&gt;setConfig($paypal_conf['settings']);
      }
  
      //
  
      public function postPayment(Request $request)
      {
          $payer = new Payer();
          $payer-&gt;setPaymentMethod('paypal');
  
          $items = array();
          $subtotal = 0;
          $cart = \Session::get('cart'); //ottenere tutta l'informazione dalla session cart
          $currency = 'EUR';
  
          $cell = $request-&gt;get('phone_ship');
  
          //return $cell;
  
          // impostiamo tutte le informazioni  
          foreach($cart as $producto){
              $item = new Item();
              $item-&gt;setName($producto-&gt;name)
              -&gt;setCurrency($currency)
              -&gt;setDescription($producto-&gt;extract)
              -&gt;setQuantity($producto-&gt;quantity)
              -&gt;setPrice($producto-&gt;price);
  
              $items[] = $item;
              $subtotal += $producto-&gt;quantity * $producto-&gt;price;
          }
  
          ////
          $item_list = new ItemList();
          $item_list-&gt;setItems($items);
          // //
          $details = new Details();
          $details-&gt;setSubtotal($subtotal)
          -&gt;setShipping(1);
  
          ////
  
          $total = $subtotal + 1;
  
          $amount = new Amount();
          $amount-&gt;setCurrency($currency)
              -&gt;setTotal($total)
              -&gt;setDetails($details);
  
          // creiamo oggetto transaction e passiamo l'imposrto
  
          $transaction = new Transaction();
          $transaction-&gt;setAmount($amount)
              -&gt;setItemList($item_list)
              -&gt;setDescription('order Laravel App Store');
  
  
          // Redirect //
          $redirect_urls = new RedirectUrls();
          $redirect_urls-&gt;setReturnUrl(\URL::route('payment.status'))
              -&gt;setCancelUrl(\URL::route('payment.status'));
  
          // ///
  
          $payment = new Payment();
          $payment-&gt;setIntent('Sale')
              -&gt;setPayer($payer)
              -&gt;setRedirectUrls($redirect_urls)
              -&gt;setTransactions(array($transaction));
  
          //controll api /
  
          try {
              $payment-&gt;create($this-&gt;_api_context);
          } catch (\PayPal\Exception\PPConnectionException $ex) {
              if (\Config::get('app.debug')) {
                  echo "Exception: " . $ex-&gt;getMessage() . PHP_EOL;
                  $err_data = json_decode($ex-&gt;getData(), true);
                  exit;
              } else {
                  die('Ups! error');
              }
          }
  
          // URL approval
  
          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);
          }
  
          // 
          return \Redirect::route('cart-show')
              -&gt;with('message', 'Ups! Error.');
  
  
  
  
      }
  
  
  
  
  
  
  
      public function getPaymentStatus()
      {
          // Get the payment ID before session clear
          $payment_id = \Session::get('paypal_payment_id');
  
          // clear the session payment ID
          \Session::forget('paypal_payment_id');
  
          $payerId = \Input::get('PayerID');
          $token = \Input::get('token');
  
          if (empty($payerId) || empty($token)) {
              return \Redirect('products')
                  -&gt;with('message', 'Error with payment');
          }
  
          $payment = Payment::get($payment_id, $this-&gt;_api_context);
  
          $execution = new PaymentExecution();
          $execution-&gt;setPayerId(\Input::get('PayerID'));
  
          $result = $payment-&gt;execute($execution, $this-&gt;_api_context);
  
  
          if ($result-&gt;getState() == 'approved') {
  
              $this-&gt;saveOrder(); // quindi richiamo metodo saveOrder e salviamo tutto
              // completat order
  
              \Session::forget('cart');
  
              return \Redirect('orderComplete')
                  -&gt;with('message', 'Order complete! good!');
          }
          return \Redirect('orderComplete')
              -&gt;with('message-error', 'Payment cancelled');
      }
  
      protected function saveOrder(Request $Request)
      {
          $subtotal = 0;
          $cart = \Session::get('cart');
          $shipping = 1;
  
  
  
  
          foreach($cart as $producto){
              $subtotal += $producto-&gt;quantity * $producto-&gt;price;
  
          }
  
  
  
          $order = Order::create([
              'subtotal' =&gt; $subtotal,
              'shipping' =&gt; $shipping,
              'phone_ship' =&gt; $request-&gt;get('phone_ship') ,
  
              //'user_id' =&gt; \Auth::user()-&gt;id
          ]);
  
          foreach($cart as $producto){
              $this-&gt;saveOrderItem($producto, $order-&gt;id);
          }
      }
  
      protected function saveOrderItem($producto, $order_id)
      {
          OrderItem::create([
              'price' =&gt; $producto-&gt;price,
              'quantity' =&gt; $producto-&gt;quantity,
              'product_id' =&gt; $producto-&gt;id,
              'order_id' =&gt; $order_id
          ]);
      }
  }
  </code></pre>
  
  <p>ORDER-DETAIL.PHP</p>
  
  <pre><code>&lt;form class="login" method="post" action="{{url('payment')}}"&gt;
  
   {{csrf_field()}}
  &lt;!--&lt;form action="checkout.html" method="POST" &gt;--&gt;
      &lt;div class="checkout-wrapper"&gt;
          &lt;div class="container"&gt;
  
              &lt;div class="text-alert"&gt;
                  &lt;p&gt;Returning customer? &lt;a href="#"&gt;Click here to login&lt;/a&gt;&lt;/p&gt;
              &lt;/div&gt;&lt;!-- /.text-alert --&gt;
  
              &lt;div class="row"&gt;
                  &lt;div class="col-md-6"&gt;
                      &lt;h2&gt;Fatturazione&lt;/h2&gt;
  
  
                      &lt;fieldset id="billinfo"&gt;
                      &lt;div class="row"&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="first_name_shipping"&gt;Nome &lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="first_name_shipping" placeholder="Nome" &gt;
                              &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="last_name_shipping"&gt;Cognome &lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="last_name_shipping" placeholder="Cognome"&gt;
                              &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="row"&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="address_shipping"&gt;Indirizzo &lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="address_shipping" placeholder="Via/Piazza/Viale" &gt;
                              &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="address2_shipping"&gt;Interno/Scala &lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="address2_shipping" placeholder="ScalaA/Interno:11" &gt;
                              &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="row"&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="province_shipping"&gt;Provincia&lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="province_shipping" placeholder="Roma,Milano,ecc" &gt;
                              &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="country_shipping"&gt;Paese&lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="country_shipping" placeholder="Paese" value="" &gt;
                              &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;div class="row"&gt;
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="email_shipping"&gt;Email&lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="email_shipping" placeholder="Email" value="{{Auth::user()-&gt;email}}" &gt;
                            &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label for="phone_shipping"&gt;Cellulare&lt;sup&gt;*&lt;/sup&gt;&lt;/label&gt;
                                  &lt;input type="text" class="form-control dark" id="phone_ship" placeholder="Telefono/Cellulare" name="phone_ship" &gt;
                              &lt;/div&gt;&lt;!-- /.form-group --&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                      &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>ROUTES.PHP</p>
  
  <p>//paypal routes</p>
  
  <pre><code>Route::post('payment', array(
      'as' =&gt; 'payment',
      'uses' =&gt; 'PaypalController@postPayment',
  
  ));
  
  
  Route::get('payment', array(
      'as' =&gt; 'payment',
      'uses' =&gt; 'PaypalController@getPayment',
  ));
  
  //Route::get('auth/register', 'Auth\AuthController@getRegister');
  //Route::post('auth/register', 'Auth\AuthController@postRegister');
  
  
  
  //paypal redirect alla nostra route
  
  Route::get('payment/status', array(
      'as' =&gt; 'payment.status',
      'uses' =&gt; 'PaypalController@getPaymentStatus',
  ));
  
  // Pagine ordine completato
  
  Route::get('orderComplete','CartController@orderComplete');
  </code></pre>