/** Recibe la peticion del estado de la transaccion realizada * * @return type */ public function getStatus() { // Get the payment ID before session clear $payment_id = \Session::get('paypal_payment_id'); $payment_quantity = Session::get('payment_quantity'); // clear the session payment ID Session::forget('paypal_payment_id'); $payerId = isset($_GET['PayerID']) ? $_GET['PayerID'] : null; $token = isset($_GET['token']) ? $_GET['token'] : null; if (is_null($payerId) || is_null($token)) { return redirect()->back()->with(UI::modalMessage("Pago cancelado", "<div class='text-center'><img width='150px;' src='" . url('assets/images/sad.png') . "'><p style='font-size: 15pt;margin-top:20px;'>Parece ser que has cancelado el pago. ¿Quieres intentarlo de nuevo?</p></div>", "Cerrar")); } $payment = Payment::get($payment_id, $this->_api_context); $execution = new PaymentExecution(); $execution->setPayerId($payerId); $result = $payment->execute($execution, $this->_api_context); if ($result->getState() == 'approved') { PayM::newRecord($token, $payerId, $payment_id, $payment_quantity); $date = new DateUtil(Auth::user()->premium_to); $message = view("ui/msg/contents/muchas-gracias-usuario")->with("date_premium", $date->getDay() . " de " . $date->getMonth() . " del " . $date->getYear())->render(); $email = new Email("¡Gracias " . Auth::user()->name . " por tu aporte!", Auth::user()->email); $email->setDescription($message); $email->setName(Auth::user()->name); //Envia un correo de agredecimiento $email->queue(); return redirect("user/contributions")->with(UI::modalMessage("Pago realizado. ¡Muchas gracias " . Auth::user()->name . "!", $message, "De nada, es un placer")); } return redirect()->back()->with(UI::modalMessage("ERROR", "<div class='text-center'><img width='150px;' src='" . url('assets/images/alert.png') . "'><p style='font-size: 15pt;margin-top:20px;'>Parece que hubo un problema al realizar el pago. ¿No tienes fondos?</p></div>", "Cerrar")); }