Ejemplo n.º 1
0
 static function newRecord($token, $payer_id, $transaction_id, $quantity)
 {
     $current_time = DateUtil::getCurrentTime();
     $user = Auth::user();
     $pay = new Payment();
     $pay->user_id = $user->id;
     $pay->method = Payment::METHOD_PAYPAL;
     $pay->mount = Payment::PAY_PRICE_PER_DAY * $quantity;
     $pay->quantity = $quantity;
     $pay->transaction_id = $transaction_id;
     $pay->ip = Util::getIP();
     $pay->user_agent = $_SERVER['HTTP_USER_AGENT'];
     $pay->date = $current_time;
     $pay->token = $token;
     $pay->payer_id = $payer_id;
     $pay->save();
     $user->role = User::ROLE_SUSCRIPTOR_PREMIUM;
     $user->premium_to = is_null($user->premium_to) ? (new DateUtil($current_time))->addDays($quantity) : (new DateUtil($user->premium_to))->addDays($quantity);
     $user->save();
 }
 function index()
 {
     /*
               $queue = QueueProductions::where(QueueProductions::ATTR_DATE_PROCESSED, null)->orderBy(QueueProductions::ATTR_ID, "ASC")->take(1)->get();
     
               foreach ($queue as $production) {
               $provider = new ProductionProvider($production->name, $production->link);
               $provider->save();
               //Indica el registro como procesado. Esto ocasiona que la produccion ya no se vuelva a actualizar, hasta una nueva cola.
               $production->date_processed = DateUtil::getCurrentTime();
               $production->save();
               return $production->name . " Agregado";
               }
               return; */
     $users_state = array(User::where(User::ATTR_STATE, User::STATE_UNCONFIRMED_ACCOUNT)->whereNotIn(User::ATTR_ROLE, [User::ROLE_ADMIN])->count(), User::where(User::ATTR_STATE, User::STATE_ACTIVED_ACCOUNT)->whereNotIn(User::ATTR_ROLE, [User::ROLE_ADMIN])->count());
     $users_role = array(User::all()->where(User::ATTR_ROLE, User::ROLE_SUSCRIPTOR)->count(), User::all()->where(User::ATTR_ROLE, User::ROLE_SUSCRIPTOR_PREMIUM)->count());
     $productions = array(Production::all()->where(Production::ATTR_STATE, Production::STATE_ACTIVE)->count(), Production::whereNotIn(Production::ATTR_STATE, array(Production::STATE_ACTIVE))->count());
     $total_playbacks = DB::table("playbacks")->where(User::ATTR_PLAYBACKS_PIVOT_PARENT, 0)->where(User::ATTR_PLAYBACKS_PIVOT_VALIDATE, 2)->count();
     $total_ratings = DB::table("production_ratings")->count();
     $total_comments = DB::table("comments")->count();
     $total_payments = Payment::all()->sum(Payment::ATTR_MOUNT);
     return view("manager/contents/dashboard")->with("users_state", $users_state)->with("users_role", $users_role)->with("productions", $productions)->with("total_playbacks", $total_playbacks)->with("total_ratings", $total_ratings)->with("total_comments", $total_comments)->with("total_payments", $total_payments);
 }
Ejemplo n.º 3
0
 /** 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"));
 }