コード例 #1
0
 /**
  * checkoutinner- Action for the middle content of the checkout page as this is opening up in iframe
  * @return \Zend\View\Model\ViewModel
  * @author Manu Garg
  */
 public function checkoutinnerAction()
 {
     $viewModel = new ViewModel();
     $this->layout()->pageTitle = " Checkout";
     $user_session = new Container('user');
     $userId = $user_session->userId;
     $request = $this->getRequest();
     if (empty($userId)) {
         /* if not logged in redirect the user to login page */
         //return $this->redirect()->toRoute('home');
         die('Please login to continue.');
     } else {
         $checkoutContainer = new Container("eventcheckout");
         //echo "<pre>"; print_r($checkoutContainer->pdata);die;
         $postedData = $checkoutContainer->pdata;
         //$checkoutContainer->setExpirationSeconds(60);
         $em = $this->getEntityManager();
         //print_r($postedData);
         $eventObj = $em->getRepository('\\Admin\\Entity\\Event')->getEvent($postedData['eventId']);
         $userObj = $em->getRepository('Admin\\Entity\\Users')->findOneBy(array('status' => 1, 'userType' => 'N', 'id' => $userId));
         if (empty($userObj)) {
             die('User not found.');
         }
         $userCardDetails = $em->getRepository('Admin\\Entity\\UserCardDetails')->findBy(array('user' => $userObj));
         $billingObj = $em->getRepository('Admin\\Entity\\BillingAddress')->findBy(array('user' => $userObj));
         if (!empty($billingObj)) {
             $billingObj = $billingObj[0];
             $country = $billingObj->getCountry();
         } else {
             $country = "";
         }
         $commonPlugin = $this->Common();
         $basePath = $commonPlugin->getBasePathOfProj();
         $form = new Forms\CheckoutForm($userCardDetails, $em, $country, $basePath);
         $form->get('email')->setValue($userObj->getEmail());
         $form->get('phoneno')->setValue($userObj->getPhone());
         if (!empty($billingObj)) {
             $fname = $billingObj->getFirstName();
             $lname = $billingObj->getLastName();
             $street_addr = $billingObj->getAddress();
             $country = $billingObj->getCountry();
             $city = $billingObj->getCity();
             $form->get('firstname')->setValue($fname);
             $form->get('lastname')->setValue($lname);
             $form->get('streetaddress')->setValue($street_addr);
             if ($country != "") {
                 $form->get('country')->setValue($country);
             }
             if ($city != "") {
                 $form->get('city')->setValue($city);
             }
         }
         $eventData = array();
         if (!empty($eventObj)) {
             $eventData['id'] = $eventObj->getId();
             $eventData['eventName'] = $eventObj->getEventName();
             $eventData['eventArtist'] = $eventObj->getEventArtist();
             $eventData['eventDesc'] = $eventObj->getEventDesc();
             $eventData['eventVenueTitle'] = $eventObj->getEventVenueTitle();
             $eventData['eventVenueIcon'] = $eventObj->getEventVenueIcon();
             $eventData['eventImageBig'] = $eventObj->getEventImageBig();
             $eventData['eventLink'] = $eventObj->getEventLink();
             $eventData['eventCity'] = $eventObj->getEventCity()->getCityName();
             $eventData['eventCountry'] = $eventObj->getEventCountry()->getCountryName();
             $eventData['eventAddress'] = $eventObj->getEventAddress();
             $eventOption = $eventObj->getEventOption();
             $eventData['eventOption'] = array();
             $dataArr = array();
             if (!empty($eventOption)) {
                 $i = 0;
                 foreach ($eventOption as $option) {
                     $dataArr[$i++] = $option->getOption()->getId();
                 }
             }
             $eventData['eventOption'] = $dataArr;
             $eventData['eventSchedule'] = $eventObj->getEventSchedule();
             $eventData['latitude'] = $eventObj->getLatitude();
             $eventData['longitude'] = $eventObj->getLongitude();
             //$eventData['eventSeat'] = $eventObj->getEventSeat();
             $eventData['eventSeat'] = $em->getRepository('Admin\\Entity\\EventSeat')->findBy(array('event' => $eventObj, 'isDeleted' => 0));
             $ticketTypeArr = array();
             $id = 0;
             foreach ($eventData['eventSeat'] as $eventSeat) {
                 $ticketTypeArr[$id]['name'] = str_replace(" ", "_", $eventSeat->getTicketType());
                 $ticketTypeArr[$id]['price'] = $eventSeat->getSeatPrice();
                 $ticketTypeArr[$id]['currency'] = $eventSeat->getCurrency();
                 $id++;
             }
             $totalQty = 0;
             $bookedTickets = array();
             foreach ($ticketTypeArr as $ticket) {
                 $totalQty += $postedData[$ticket['name']];
                 if ($postedData[$ticket['name']] > 0) {
                     $bookedTickets[] = $ticket['name'];
                 }
             }
         }
         $form->get('quantity')->setValue($totalQty);
         $viewModel->setVariables(array('userId' => $userId, 'eventData' => $eventData, 'checkoutContainer' => $checkoutContainer->pdata, 'totalQty' => $totalQty, 'bookedTickets' => $bookedTickets, 'ticketTypeArr' => $ticketTypeArr, 'form' => $form))->setTerminal(true);
         return $viewModel;
     }
 }
コード例 #2
0
 public function checkoutAction()
 {
     $auth = new FrontEndAuth();
     if (!$auth->hasIdentity(3)) {
         return $this->redirect()->toUrl('/login');
     }
     $id = $this->params()->fromRoute('id');
     if ($id == '') {
         $this->redirect()->toRoute('membership');
     }
     $subscriptionsession = new Container('subscriptionsession');
     $session = new Container('frontend');
     $api = new Api();
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     $model_practitioner = new Practitioners();
     $common = new Common();
     $selected_subscription = $model_practitioner->getSubscription($api_url, $id);
     $ongoing_subscription = $common->getSubscriptiondetails($api_url);
     //echo "<pre>";print_r($ongoing_subscription);die;
     /* check if there is a saved card : start */
     $savedCard_details = $common->getUserCardDetails($api_url, array('user_id' => $session->userid));
     /* check if there is a saved card : end */
     $subscription_id = $this->getSubscriptionid($api_url);
     if ($id == '1') {
         if ($common->addSubscription($api_url, array('user_id' => $session->userid, 'id' => $ongoing_subscription[0]['id']))) {
             $this->flashMessenger()->addSuccessMessage("Basic subscription activated on your account..!!");
             return $this->redirect()->toRoute('practitioner', array('action' => 'dashboard'));
         } else {
             $this->flashMessenger()->addErrorMessage("Failed to activate basic subscription..!!");
             return $this->redirect()->toRoute('membership');
         }
     }
     $ongoingSubs_endDate = 'NA';
     $ongoingsubs_name = 'NA';
     $total_amount = 'NA';
     $new_expireDate = 'NA';
     $selectedSubs_name = 'NA';
     $subscription_duration_id = 'NA';
     $selectedCurrency = $model_practitioner->getcurrency($api_url, $this->getRequest()->getServer('REMOTE_ADDR'));
     if ($id == $subscription_id) {
         /* same subscription now renew */
         $checkout_type = "renew";
         if (count($selected_subscription) > 0) {
             if (count($ongoing_subscription) > 0) {
                 !empty($ongoing_subscription[0]['subscription_end_date']) ? $ongoingSubs_endDate = $ongoing_subscription[0]['subscription_end_date'] : '';
                 $ongoing_duration = json_decode($ongoing_subscription[0]['subscription_duration'], true);
                 if (count($ongoing_duration) > 0) {
                     $ongoingsubs_name = $ongoing_duration['subscription_name'];
                 }
             } else {
                 $ongoingSubs_endDate = date('Y-m-d');
             }
             $selected = json_decode($selected_subscription['duration'][0], true);
             if (count($selected) > 0) {
                 $total_amount = $selected['price'];
                 $selectedSubs_name = $selected['subscription_name'];
                 $subscription_duration_id = $selected['id'];
                 if (isset($selected['duration_in'])) {
                     if ($selected['duration_in'] == "1") {
                         // move subs date $selected['duration'] year ahed
                         $new_expireDate = date('Y-m-d', strtotime("+" . $selected['duration'] . " year", strtotime($ongoingSubs_endDate)));
                     } else {
                         if ($selected['duration_in'] == "2") {
                             // move subs date $selected['duration'] month ahed
                             $new_expireDate = date('Y-m-d', strtotime("+" . $selected['duration'] . " month", strtotime($ongoingSubs_endDate)));
                         } else {
                             if ($selected['duration_in'] == "3") {
                                 // move subs date $selected['duration'] month ahed
                                 $new_expireDate = date('Y-m-d', strtotime("+" . $selected['duration'] . " days", strtotime($ongoingSubs_endDate)));
                             } else {
                                 // do nothing
                             }
                         }
                     }
                 }
             }
         }
     } else {
         /* new subscription */
         $checkout_type = "new";
         if (count($selected_subscription) > 0) {
             if (count($ongoing_subscription) > 0) {
                 !empty($ongoing_subscription[0]['subscription_end_date']) ? $ongoingSubs_endDate = $ongoing_subscription[0]['subscription_end_date'] : '';
                 $ongoing_duration = json_decode($ongoing_subscription[0]['subscription_duration'], true);
                 if (count($ongoing_duration) > 0) {
                     $ongoingsubs_name = $ongoing_duration['subscription_name'];
                 }
             }
             $selected = json_decode($selected_subscription['duration'][0], true);
             if (count($selected) > 0) {
                 $total_amount = $selected['price'];
                 $selectedSubs_name = $selected['subscription_name'];
                 $subscription_duration_id = $selected['id'];
                 if (isset($selected['duration_in'])) {
                     if ($selected['duration_in'] == "1") {
                         // move subs date $selected['duration'] year ahed
                         $new_expireDate = date('Y-m-d', strtotime("+" . $selected['duration'] . " year", strtotime(date('Y-m-d'))));
                     } else {
                         if ($selected['duration_in'] == "2") {
                             // move subs date $selected['duration'] month ahed
                             $new_expireDate = date('Y-m-d', strtotime("+" . $selected['duration'] . " month", strtotime(date('Y-m-d'))));
                         } else {
                             if ($selected['duration_in'] == "3") {
                                 // move subs date $selected['duration'] month ahed
                                 $new_expireDate = date('Y-m-d', strtotime("+" . $selected['duration'] . " days", strtotime(date('Y-m-d'))));
                             } else {
                                 // do nothing
                             }
                         }
                     }
                 }
             }
         }
     }
     //echo $new_expireDate;die;
     $subscriptionsession->serviceprice = $total_amount;
     $subscriptionsession->subscription_duration_id = $subscription_duration_id;
     $subscriptionsession->currency = $selectedCurrency;
     $subscriptionsession->subscription_end_date = $new_expireDate;
     $form = new CheckoutForm($this->getServiceLocator()->get('config')['payment_methods']);
     $session = new Container('frontend');
     $form->get('name_on_card')->setValue($session->first_name . ' ' . $session->last_name);
     $form->get('emailid')->setValue($session->email);
     $banners = $common->getBanner($api_url, 14);
     return new ViewModel(array('form' => $form, 'errorMsgs' => $this->flashMessenger()->getCurrentErrorMessages(), 'checkout_type' => $checkout_type, 'ongoingSubs_endDate' => $ongoingSubs_endDate, 'ongoingsubs_name' => $ongoingsubs_name, 'total_amount' => $total_amount, 'new_expireDate' => $new_expireDate, 'selectedSubs_name' => $selectedSubs_name, 'selectedCurrency' => $selectedCurrency, 'banners' => $banners, 'savedCard_details' => end($savedCard_details), 'merchant_id' => $this->getServiceLocator()->get('Config')['payment_gateway']['merchant_id']));
 }
コード例 #3
0
 public function checkoutAction()
 {
     $bookingsession = new Container('bookingsession');
     if (isset($bookingsession->locationid) && !empty($bookingsession->locationid) && (isset($bookingsession->serviceid) && !empty($bookingsession->serviceid)) && (isset($bookingsession->durationid) && !empty($bookingsession->durationid)) && (isset($bookingsession->servicedate) && !empty($bookingsession->servicedate))) {
         // getting banner for this page
         $common = new Common();
         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
         $banners = $common->getBanner($api_url, 14);
         $form = new CheckoutForm($this->getServiceLocator()->get('config')['payment_methods']);
         $session = new Container('frontend');
         $form->get('name_on_card')->setValue($session->first_name . ' ' . $session->last_name);
         $form->get('emailid')->setValue($session->email);
         $bookingsession = new Container('bookingsession');
         $bookingamount = $bookingsession->price;
         return new ViewModel(array('form' => $form, 'errorMsgs' => $this->flashMessenger()->getCurrentErrorMessages(), 'banners' => $banners, 'bookingamount' => $bookingamount, 'merchant_id' => $this->getServiceLocator()->get('Config')['payment_gateway']['merchant_id']));
     } else {
         return $this->redirect()->toRoute('practitioner', array('action' => 'list'));
     }
 }