Example #1
0
 /**
  * Get the booking force reload
  */
 public function getNotification()
 {
     // check notification source
     $booking_id = 0;
     // check paypal first
     if ($this->config->confirm_paypal) {
         list($booking_id, $confirmation) = $this->checkNotificationPaypal();
         $method = 'Paypal';
     }
     // check payment platform second
     if ($this->config->confirm_payment && !$booking_id) {
         list($booking_id, $confirmation) = $this->checkNotificationPlugin();
         $method = 'Plugin';
     }
     // could not retrieve booking id
     if (!$booking_id) {
         CHLib::log(json_encode(['CHClientModelNotify::getNotification - invalid notification', CHLib::input()->get->getArray(), CHLib::input()->post->getArray()], JSON_PRETTY_PRINT), 'warning', 'com_chclient');
         throw new Exception('An error occurred', 400);
     }
     // get the booking
     $booking = $this->getBooking($booking_id);
     if (!$booking) {
         CHLib::log(json_encode(['CHClientModelNotify::getNotification - notification received, could not retrieve the booking', CHLib::input()->get->getArray(), CHLib::input()->post->getArray()], JSON_PRETTY_PRINT), 'warning', 'com_chclient');
         $this->{'exitApp' . $method . 'Ko'}($confirmation, $booking);
     }
     // check booking status
     if ($booking->booking_status >= 50 || $booking->booking_status < 40) {
         CHLib::log(json_encode(['CHClientModelNotify::getNotification - notification received, booking status incorrect', CHLib::input()->get->getArray(), CHLib::input()->post->getArray()], JSON_PRETTY_PRINT), 'warning', 'com_chclient');
         $this->{'exitApp' . $method . 'Ko'}($confirmation, $booking);
     }
     // confirm the booking
     $api_request = $this->apiRequest('booking_confirm', (object) ['booking_id' => (int) $booking_id, 'booking_status' => 11, 'confirmation' => $confirmation]);
     if (!$api_request || !$api_request->response) {
         CHLib::log(json_encode(['CHClientModelNotify::getNotification - could not update the booking status', CHLib::input()->get->getArray(), CHLib::input()->post->getArray()], JSON_PRETTY_PRINT), 'warning', 'com_chclient');
         $this->{'exitApp' . $method . 'Ko'}($confirmation, $booking);
     }
     // send email notifications
     CHClientBooking::emailNotification($api_request->response);
     // exit app OK
     $this->{'exitApp' . $method . 'Ok'}($confirmation, $booking);
 }
 /**
  * Asyncronous email notification
  * 
  * @todo check sign
  */
 public function asyncNotification()
 {
     // get the booking id
     $booking_id = CHLib::input()->getInt('booking_id');
     // load the booking
     $booking = $this->getBooking($booking_id);
     // send notification
     CHClientBooking::emailNotification($booking);
     // return
     return 'notification sent';
 }