/** * Method to save the form data. * * @param array The form data. * @return boolean True on success. */ public function save($data) { $id = !empty($data['reservationId']) ? $data['reservationId'] : (int) $this->getState('reservation.id'); $isNew = empty($id); $reservationDetails = $this->getReservationDetails($data); //dmp($reservationDetails); //exit; require_once JPATH_COMPONENT_SITE . '/models/confirmation.php'; $confirmationModel = new JHotelReservationModelConfirmation(); $reservaitonId = $confirmationModel->saveConfirmation($reservationDetails); if ($isNew && $reservaitonId != -1) { $reservationDetails->confirmation_id = $reservaitonId; $processor = PaymentService::createPaymentProcessor(PROCESSOR_CASH); $paymentDetails = $processor->processTransaction($reservationDetails); PaymentService::addPayment($paymentDetails); } if ($reservaitonId != -1) { $this->setState('reservation.id', $reservaitonId); } else { $this->setState('reservation.id', $id); $this->setError($confirmationModel->getError()); return false; } // Clean the cache $this->cleanCache(); return true; }
function getPaymentInformation($paymentDetails, $amount, $cost) { $processor = PaymentService::createPaymentProcessor($paymentDetails->processor_type); ob_start(); echo "<ul style='margin:0px;padding-left: 0;list-style:none'>"; echo "<li style='margin-left: 0px'>"; echo $processor->getPaymentDetails($paymentDetails, $amount, $cost); echo "</li>"; echo "</ul>"; $buff = ob_get_contents(); ob_end_clean(); return $buff; }
function processAutomaticResponse() { $this->log->LogDebug("process automatic response"); $data = JRequest::get('post'); $this->log->LogDebug(serialize($data)); $processorType = JRequest::getVar("processor"); $processor = PaymentService::createPaymentProcessor($processorType); $paymentDetails = $processor->processResponse($data); $this->log->LogDebug("Payment Details: " . serialize($paymentDetails)); if (empty($paymentDetails->confirmation_id)) { return; } $intialPaymentDetails = PaymentService::getConfirmationPaymentDetails($paymentDetails->confirmation_id); $this->log->LogDebug("Initial payment details: " . serialize($intialPaymentDetails)); if ($intialPaymentDetails->payment_status == PAYMENT_STATUS_PAID) { return; } //prevent e-mails to be send again to hotels and customers if ($intialPaymentDetails->payment_status == $paymentDetails->payment_status) { header("HTTP/1.1 200 OK"); return; } //check if the response is a reponse for a waiting transaction $sendMailOnlyToAdmin = $intialPaymentDetails->payment_status == PAYMENT_STATUS_WAITING && $paymentDetails->payment_status == PAYMENT_STATUS_PAID; $this->log->LogDebug("Send only to admin " . serialize($sendMailOnlyToAdmin)); PaymentService::updatePayment($paymentDetails); if ($paymentDetails->status == PAYMENT_CANCELED || $paymentDetails->status == PAYMENT_ERROR) { BookingService::cancelReservation($paymentDetails->confirmation_id); } else { $confirmationModel = $this->getModel("Confirmation"); $reservationDetails = $confirmationModel->getReservation($paymentDetails->confirmation_id); EmailService::sendConfirmationEmail($reservationDetails, $sendMailOnlyToAdmin); //check if hotels has more rooms available $hotelId = $reservationDetails->reservationData->userData->hotelId; $startDate = $reservationDetails->reservationData->userData->start_date; $endDate = $reservationDetails->reservationData->userData->end_date; $isHotelAvailable = HotelService::checkAvailability($hotelId, $startDate, $endDate); if (!$isHotelAvailable) { EmailService::sendNoAvailabilityEmail($hotelId, $startDate, $endDate); } } //http_response_code(200); header("HTTP/1.1 200 OK"); }
function processAutomaticResponse() { $this->log->LogDebug("process automatic response"); $data = JRequest::get('post'); $this->log->LogDebug(serialize($data)); $processorType = JRequest::getVar("processor"); $this->log->LogDebug("Processor: " . $processorType); $processor = PaymentService::createPaymentProcessor($processorType); $paymentDetails = $processor->processResponse($data); $this->log->LogDebug("Payment Details: " . serialize($paymentDetails)); if (empty($paymentDetails->order_id)) { $this->log->LogDebug("Empty order Id"); return; } $intialPaymentDetails = PaymentService::getPaymentDetails($paymentDetails->order_id); $this->log->LogDebug("Initial payment details: " . serialize($intialPaymentDetails)); if ($intialPaymentDetails->payment_status == PAYMENT_STATUS_PAID) { $this->log->LogDebug("order has been already paid"); //return; } PaymentService::updatePayment($paymentDetails); if ($paymentDetails->status == PAYMENT_CANCELED || $paymentDetails->status == PAYMENT_ERROR) { } else { $orderModel = $this->getModel("Orders"); $order = $orderModel->updateOrder($paymentDetails, $processor); $paymentModel = $this->getModel("Payment"); $paymentModel->sendPaymentEmail($paymentDetails); } }