$logger->LogFatal("Error saving booking!"); $logger->LogFatal($booking->errors); die("Error: " . $booking->errors[0]); } $logger->LogInfo("Save is successful."); // Send email to client that txn was processed $logger->LogInfo("Getting confirmation email contents ..."); $confirmationEmailContents = EmailContents::fetchFromDbForCode("Confirmation Email"); if ($confirmationEmailContents == null) { $logger->LogError("Cannot find confirmation email contents!"); $logger->LogError(EmailContents::$staticErrors); } $client = $booking->getClient(); $clientEmail = $client->email; $logger->LogInfo("Personalizing email ..."); $emailPersonalizer = new EmailPersonalizer($booking); $emailBody = $emailPersonalizer->customizeEmailContents($confirmationEmailContents->emailText->getText($booking->languageCode)); $logger->LogDebug("Email body:"); $logger->LogDebug($emailBody); $logger->LogInfo("Sending email to client..."); if (!$emailSender->sendEmail($clientEmail, $confirmationEmailContents->emailSubject->getText($booking->languageCode), $emailBody)) { $logger->LogError("Failed to send confirmation email to client."); } /* Notify Email for Hotel about Booking */ $notifyEmailSubject = "Booking no." . $bookingId . " - Notification of Room Booking by " . $client->firstName . " " . $client->lastName; $logger->LogInfo("Sending email to hotel admin..."); if (!$emailSender->sendEmail($systemConfiguration->getHotelDetails()->getHotelEmail(), $notifyEmailSubject, $invoiceHtml)) { $logger->LogError("Failed to send email to the hotel admin."); } } else { $logger->LogWarn("IPN was not processed successfully!");
function processPayOnArrival() { global $bookingDetails; global $systemConfiguration; global $logger; global $language_selected; $logger->LogInfo("Processing payment on arrival ..."); $transactionId = "N/A"; $booking = $bookingDetails->booking; $paymentGateway = $bookingDetails->paymentGateway; $logger->LogInfo("Creating bottom portion of invoice ..."); $logger->LogInfo("Compposing invoice ..."); $invoiceHtml = '<br />' . "\n"; $invoiceHtml .= '<table style="font-family:Verdana, Geneva, sans-serif; font-size: 12px; background:#999999; width:700px; border:none;" cellpadding="4" cellspacing="1">' . "\n"; $invoiceHtml .= ' <tr>' . "\n"; $invoiceHtml .= ' <td align="left" colspan="2" style="font-weight:bold; font-variant:small-caps; background:#eeeeee;">' . "\n"; $invoiceHtml .= ' ' . BOOKING_DETAILS_BILLING . "\n"; $invoiceHtml .= ' </td>' . "\n"; $invoiceHtml .= ' </tr>' . "\n"; $invoiceHtml .= ' <tr>' . "\n"; $invoiceHtml .= ' <td align="left" width="30%" style="font-weight:bold; font-variant:small-caps;background:#ffffff;" width="33%">' . "\n"; $invoiceHtml .= ' ' . BOOKING_DETAILS_PAYMENT_OPTION . "\n"; $invoiceHtml .= ' </td>' . "\n"; $invoiceHtml .= ' <td align="left" style="background:#ffffff;">' . "\n"; $invoiceHtml .= ' ' . $paymentGateway->gatewayName->getText($language_selected) . "\n"; $invoiceHtml .= ' </td>' . "\n"; $invoiceHtml .= ' </tr>' . "\n"; $invoiceHtml .= ' <tr>' . "\n"; $invoiceHtml .= ' <td align="left" width="30%" style="font-weight:bold; font-variant:small-caps; background:#ffffff;" width="33%">' . "\n"; $invoiceHtml .= ' ' . BOOKING_DETAILS_TRANSACTION . "\n"; $invoiceHtml .= ' </td>' . "\n"; $invoiceHtml .= ' <td align="left" style="background:#ffffff;">' . "\n"; $invoiceHtml .= ' ' . $transactionId . "\n"; $invoiceHtml .= ' </td>' . "\n"; $invoiceHtml .= ' </tr>' . "\n"; $invoiceHtml .= '</table>' . "\n"; $booking->invoice .= $invoiceHtml; $booking->paymentTransactionId = $transactionId; $booking->paypalEmail = ""; $booking->isPaymentSuccessful = true; $logger->LogInfo("Saving booking ..."); if (!$booking->save(true)) { $logger->LogFatal("Error saving booking!"); $logger->LogFatal($booking->errors); die("Error: " . $booking->errors[0]); } $logger->LogInfo("Save is successful."); // Send email to client that txn was processed $logger->LogInfo("Getting confirmation email contents ..."); $confirmationEmailContents = EmailContents::fetchFromDbForCode("Confirmation Email"); if ($confirmationEmailContents == null) { $logger->LogFatal("Could not find confirmation email contents."); die("Cannot find confirmation email details"); } $client = $booking->getClient(); $clientEmail = $client->email; $logger->LogInfo("Personalizing email ..."); $emailPersonalizer = new EmailPersonalizer($booking); $emailBody = $emailPersonalizer->customizeEmailContents($confirmationEmailContents->emailText->getText($booking->languageCode)); $logger->LogDebug("Email body:"); $logger->LogDebug($emailBody); $logger->LogInfo("Sending email to client at " . $clientEmail . " ..."); $emailSender = new EmailSender(); if (!$emailSender->sendEmail($clientEmail, $confirmationEmailContents->emailSubject->getText($booking->languageCode), $emailBody)) { $logger->LogError("Failed to send confirmation email to client."); } /* Notify Email for Hotel about Booking */ $notifyEmailSubject = "Booking no." . $booking->id . " - Notification of Room Booking by " . $client->firstName . " " . $client->lastName; $logger->LogInfo("Sending email to hotel admin..."); if (!$emailSender->sendEmail($systemConfiguration->getHotelDetails()->getHotelEmail(), $notifyEmailSubject, $invoiceHtml)) { $logger->LogError("Failed to send email to the hotel admin."); } header('Location: booking-confirm.php'); }