public function confirmorderAction() { $this->layout('layout/eventlayout'); $this->layout()->pageTitle = "Confirm Order"; $request = $this->getRequest(); $user_session = new Container('user'); $userId = $user_session->userId; //$id = $this->params('cardid'); $em = $this->getEntityManager(); $viewModel = new ViewModel(); $viewModel->setTerminal(true); if ($request->isPost()) { $checkoutContainer = new Container("eventcheckout"); $data = $checkoutContainer->pdata; if (empty($data)) { die("Requested Data not found."); } else { //print_r($data); $postedData = $request->getPost(); // print_r($postedData); $eventObj = $em->getRepository('Admin\\Entity\\Event')->findOneBy(array('id' => $data['eventId'], 'status' => 1)); $userObj = $em->getRepository('Admin\\Entity\\Users')->find($userId); $eventSeatData = $em->getRepository('Admin\\Entity\\EventSeat')->findBy(array('event' => $eventObj, 'isDeleted' => 0)); $commonPlugin = $this->Common(); $userBookingObj = new Entities\UserBooking(); $userBookingObj->setUser($userObj); $userBookingObj->setEvent($eventObj); $userBookingObj->setEventDate(date_create(date("Y-m-d", strtotime($data['eventDate'])))); $userBookingObj->setEventTime(date_create(date("H:i:s", strtotime($data['eventTime'])))); $userBookingObj->setBookingSeatCount($postedData['quantity']); $userBookingObj->setBookingTotalPrice($data['totalAmount']); $userBookingObj->setEmail($postedData['email']); $userBookingObj->setPhoneNo($postedData['phoneno']); /* $userBookingObj->setCardType($postedData['card_type']); $userBookingObj->setCardNo($postedData['cardno']); $userBookingObj->setExpiryMonth($postedData['month']); $userBookingObj->setExpiryYear($postedData['year']); */ $userBookingObj->setFirstName($postedData['firstname']); $userBookingObj->setLastName($postedData['lastname']); $userBookingObj->setStreetAddress($postedData['streetaddress']); $userBookingObj->setBookingOrderNo(""); $userBookingObj->setCity($postedData['city']); $userBookingObj->setCountry($postedData['country']); $userBookingObj->setStatus(2); $userBookingObj->setBookingMadeDate(date_create(date('Y-m-d H:i:s'))); $em->persist($userBookingObj); $em->flush(); $orderId = $userBookingObj->getId(); // $schemeHost = $commonPlugin->getSchemeHostOfProj(); $htpconfirmatinPath = $this->url()->fromRoute('htpconfirmation'); $acceptUrl = $schemeHost . $htpconfirmatinPath; $conf = array(); $securityKey = "tapetickets123#"; $conf['accountPspId'] = "testclassic"; $conf['parametersAcceptUrl'] = $acceptUrl; $conf['parametersExceptionUrl'] = $acceptUrl; $conf['paymentMethod'] = "CreditCard"; $conf['layoutLanguage'] = "en_EN"; $conf['aliasId'] = ""; $conf["aliasOrderId"] = $orderId; $conf["aliasStorePermanently"] = "N"; if ($conf["aliasId"] == "") { $paramString = "ACCOUNT.PSPID=" . $conf['accountPspId'] . $securityKey . "ALIAS.ORDERID=" . $conf['aliasOrderId'] . $securityKey . "ALIAS.STOREPERMANENTLY=" . $conf["aliasStorePermanently"] . $securityKey . "CARD.PAYMENTMETHOD=" . $conf['paymentMethod'] . $securityKey . "LAYOUT.LANGUAGE=" . $conf['layoutLanguage'] . $securityKey . "PARAMETERS.ACCEPTURL=" . $conf['parametersAcceptUrl'] . $securityKey . "PARAMETERS.EXCEPTIONURL=" . $conf['parametersExceptionUrl'] . $securityKey; } else { //$paramstring = "ACCOUNT.PSPID=testclassicclassicinformatics123#ALIAS.ALIASID=C2BCA5D2-35DF-4BBD-A68E-E924F4BD5515classicinformatics123#ALIAS.ORDERID=1459classicinformatics123#CARD.PAYMENTMETHOD=CreditCardclassicinformatics123#LAYOUT.LANGUAGE=en_ENclassicinformatics123#PARAMETERS.ACCEPTURL=http://tapetickets.demos.classicinformatics.com/tmp/index.phpclassicinformatics123#PARAMETERS.EXCEPTIONURL=http://tapetickets.demos.classicinformatics.com/tmp/index.phpclassicinformatics123#"; $paramString = "ACCOUNT.PSPID=" . $conf['accountPspId'] . $securityKey . "ALIAS.ALIASID=" . $conf['aliasId'] . $securityKey . "ALIAS.ORDERID=" . $conf['aliasOrderId'] . $securityKey . "ALIAS.STOREPERMANENTLY=" . $conf["aliasStorePermanently"] . $securityKey . "CARD.PAYMENTMETHOD=" . $conf['paymentMethod'] . $securityKey . "LAYOUT.LANGUAGE=" . $conf['layoutLanguage'] . $securityKey . "PARAMETERS.ACCEPTURL=" . $conf['parametersAcceptUrl'] . $securityKey . "PARAMETERS.EXCEPTIONURL=" . $conf['parametersExceptionUrl'] . $securityKey; } $conf['sha1'] = sha1($paramString); $conf['sha1'] = strtoupper($conf['sha1']); } } return new ViewModel(array('orderId' => $orderId, 'postedData' => $postedData, 'userObj' => $userObj, 'data' => $data, 'conf' => $conf)); }
public function confirmorderAction() { //$this->layout('layout/eventlayout'); //$this->layout()->pageTitle = "Confirm Order"; $request = $this->getRequest(); $user_session = new Container('user'); $userId = $user_session->userId; //$id = $this->params('cardid'); $em = $this->getEntityManager(); $viewModel = new ViewModel(); $viewModel->setTerminal(true); if ($request->isPost()) { $checkoutContainer = new Container("eventcheckout"); $data = $checkoutContainer->pdata; if (empty($data)) { die("Requested Data not found."); } else { //print_r($data); $postedData = $request->getPost(); // print_r($postedData); $eventObj = $em->getRepository('Admin\\Entity\\Event')->findOneBy(array('id' => $data['eventId'], 'status' => 1)); $userObj = $em->getRepository('Admin\\Entity\\Users')->find($userId); $eventSeatData = $em->getRepository('Admin\\Entity\\EventSeat')->findBy(array('event' => $eventObj, 'isDeleted' => 0)); $commonPlugin = $this->Common(); /* Checking if booked seats are available */ $bookedTickets = array(); $i = 0; foreach ($eventSeatData as $eventSeat) { $ticketType = str_replace(" ", "_", $eventSeat->getTicketType()); if (isset($data[$ticketType])) { if ($data[$ticketType] > 0) { $bookedTickets[$i]['ticketId'] = $eventSeat->getId(); $bookedTickets[$i]['type'] = $eventSeat->getTicketType(); $bookedTickets[$i]['quantity'] = $data[$ticketType]; $bookedTickets[$i]['seats'] = $eventSeat->getNumberOfSeats(); $bookedTickets[$i]['price'] = $eventSeat->getSeatPrice(); $bookedTickets[$i]['entrance'] = $eventSeat->getSeatEntrance(); $bookedTickets[$i]['redeemOn'] = $eventSeat->getRedeemOn(); $i++; } } } //print_r($bookedTickets); if (empty($bookedTickets)) { die("Some Error Occured."); } foreach ($bookedTickets as $eventSeat) { $userSeatCount = $commonPlugin->getUserSeatCount($data['eventId'], $eventSeat['ticketId'], $data['eventDate'], $data['eventTime']); $availableSeats = $eventSeat['seats'] - $userSeatCount; if ($availableSeats < $eventSeat['quantity']) { die("Tickets not available."); } } $userBookingObj = new Entities\UserBooking(); $userBookingObj->setUser($userObj); $userBookingObj->setEvent($eventObj); $userBookingObj->setEventDate(date_create(date("Y-m-d", strtotime($data['eventDate'])))); $userBookingObj->setEventTime(date_create(date("H:i:s", strtotime($data['eventTime'])))); $userBookingObj->setBookingSeatCount($postedData['quantity']); $userBookingObj->setBookingTotalPrice($data['totalAmount']); $userBookingObj->setEmail($postedData['email']); $userBookingObj->setPhoneNo($postedData['phoneno']); /* $userBookingObj->setCardType($postedData['card_type']); $userBookingObj->setCardNo($postedData['cardno']); $userBookingObj->setExpiryMonth($postedData['month']); $userBookingObj->setExpiryYear($postedData['year']); */ $userBookingObj->setFirstName($postedData['firstname']); $userBookingObj->setLastName($postedData['lastname']); $userBookingObj->setStreetAddress($postedData['streetaddress']); $userBookingObj->setBookingOrderNo(""); $userBookingObj->setCity($postedData['city']); $userBookingObj->setCountry($postedData['country']); $userBookingObj->setStatus(2); $userBookingObj->setBookingMadeDate(date_create(date('Y-m-d H:i:s'))); $em->persist($userBookingObj); $em->flush(); $orderId = $userBookingObj->getId(); foreach ($bookedTickets as $ticket) { $qty = $ticket['quantity']; for ($qty; $qty >= 1; $qty--) { $noOfseatOrder = $commonPlugin->getTotalSeatCount($data['eventId'], $ticket['ticketId'], $data['eventDate'], $data['eventTime']); $eventSeatObj = $em->getRepository("Admin\\Entity\\EventSeat")->find($ticket['ticketId']); $seatNo = $noOfseatOrder + 1; $seatOrderObj = new Entities\SeatOrder(); $seatOrderObj->setBooking($userBookingObj); $seatOrderObj->setCreatedDate(date_create(date('Y-m-d H:i:s'))); $seatOrderObj->setEntrance($ticket['entrance']); $seatOrderObj->setTicketType($ticket['type']); $seatOrderObj->setRedeemOn($ticket['redeemOn']); $seatOrderObj->setPrice($ticket['price']); $seatOrderObj->setSeatNo($seatNo); $seatOrderObj->setBarCodeNumber(""); $seatOrderObj->setEventSeat($eventSeatObj); $em->persist($seatOrderObj); $em->flush(); } } $schemeHost = $commonPlugin->getSchemeHostOfProj(); $htpconfirmatinPath = $this->url()->fromRoute('htpconfirmation'); $acceptUrl = $schemeHost . $htpconfirmatinPath; $conf = array(); $securityKey = "classicinformatics123#"; $conf['accountPspId'] = "testclassic"; $conf['parametersAcceptUrl'] = $acceptUrl; $conf['parametersExceptionUrl'] = $acceptUrl; $conf['paymentMethod'] = "CreditCard"; $conf['layoutLanguage'] = "en_EN"; $conf['aliasId'] = ""; $conf["aliasOrderId"] = $orderId; $conf["aliasStorePermanently"] = "N"; if ($conf["aliasId"] == "") { $paramString = "ACCOUNT.PSPID=" . $conf['accountPspId'] . $securityKey . "ALIAS.ORDERID=" . $conf['aliasOrderId'] . $securityKey . "ALIAS.STOREPERMANENTLY=" . $conf["aliasStorePermanently"] . $securityKey . "CARD.PAYMENTMETHOD=" . $conf['paymentMethod'] . $securityKey . "LAYOUT.LANGUAGE=" . $conf['layoutLanguage'] . $securityKey . "PARAMETERS.ACCEPTURL=" . $conf['parametersAcceptUrl'] . $securityKey . "PARAMETERS.EXCEPTIONURL=" . $conf['parametersExceptionUrl'] . $securityKey; } else { //$paramstring = "ACCOUNT.PSPID=testclassicclassicinformatics123#ALIAS.ALIASID=C2BCA5D2-35DF-4BBD-A68E-E924F4BD5515classicinformatics123#ALIAS.ORDERID=1459classicinformatics123#CARD.PAYMENTMETHOD=CreditCardclassicinformatics123#LAYOUT.LANGUAGE=en_ENclassicinformatics123#PARAMETERS.ACCEPTURL=http://tapetickets.demos.classicinformatics.com/tmp/index.phpclassicinformatics123#PARAMETERS.EXCEPTIONURL=http://tapetickets.demos.classicinformatics.com/tmp/index.phpclassicinformatics123#"; $paramString = "ACCOUNT.PSPID=" . $conf['accountPspId'] . $securityKey . "ALIAS.ALIASID=" . $conf['aliasId'] . $securityKey . "ALIAS.ORDERID=" . $conf['aliasOrderId'] . $securityKey . "ALIAS.STOREPERMANENTLY=" . $conf["aliasStorePermanently"] . $securityKey . "CARD.PAYMENTMETHOD=" . $conf['paymentMethod'] . $securityKey . "LAYOUT.LANGUAGE=" . $conf['layoutLanguage'] . $securityKey . "PARAMETERS.ACCEPTURL=" . $conf['parametersAcceptUrl'] . $securityKey . "PARAMETERS.EXCEPTIONURL=" . $conf['parametersExceptionUrl'] . $securityKey; } $conf['sha1'] = sha1($paramString); $conf['sha1'] = strtoupper($conf['sha1']); //echo $paramString; //print_r($conf); //die('111'); } //print_r($postedData); //die('12121'); } //echo json_encode(array()); //die; // return new ViewModel(array('orderId'=>$orderId,'postedData'=>$postedData,'userObj'=>$userObj,'data'=>$data,'conf'=>$conf)); $viewModel->setVariables(array('orderId' => $orderId, 'postedData' => $postedData, 'userObj' => $userObj, 'data' => $data, 'conf' => $conf)); return $viewModel; }