public function getDone(Request $request) { $id = $request->get('paymentId'); $token = $request->get('token'); $payer_id = $request->get('PayerID'); $payment = PayPal::getById($id, $this->_apiContext); $paymentExecution = PayPal::PaymentExecution(); $paymentExecution->setPayerId($payer_id); $executePayment = $payment->execute($paymentExecution, $this->_apiContext); $order = Order::whereUserId(Auth::id())->orderBy('created_at', 'desc')->first(); if (!is_null($order)) { $order->payment = $id; $order->save(); } $log = Log::whereUserId(Auth::id())->whereReason('purchase')->orderBy('created_at', 'desc')->first(); if (!is_null($log)) { $log->flag = true; $log->save(); } return view('checkout.done'); }