$bookingDetails->client->id = $client->id; } if (!$bookingDetails->client->save()) { $logger->LogError("Saving client failed!"); $logger->LogError($client->errors); $_SESSION['errors'] = $bookingDetails->client->errors; header('Location: error.php'); } // Validate booking info if (!$bookingDetails->isValid()) { $logger->LogError("BookingDetails are not valid!"); $logger->LogError($bookingDetails->errors); $_SESSION['errors'] = $bookingDetails->errors; header('Location: error.php'); } $paymentGateway = PaymentGateway::fetchFromDbForCode("ha"); if ($paymentGateway == null) { $logger->LogError("Payment gateway code: ha not in database!"); header('Location: error.php'); } $bookingDetails->paymentGateway = $paymentGateway; // Check for concurent booking if (!$bookingDetails->isBookingStillAvailable()) { $_SESSION['errors'] = array(); $_SESSION['errors'][] = "Another customer already booked the room in time requested"; header('Location: error.php'); } $bookingDetails->generateBooking($language_selected); // Generate invoice $invoiceHtml = $bookingDetails->generateInvoice($language_selected); $invoiceHtml .= '<br />' . "\n";
<?php // Setup class include_once "includes/SystemConfiguration.class.php"; include "includes/language.php"; global $systemConfiguration; global $logger; $logger->LogInfo(__FILE__); $systemConfiguration->assertReferer(); $logger->LogInfo("Loading payment gateway for code 'pp' ..."); $paypalPaymentGateway = PaymentGateway::fetchFromDbForCode("pp"); if ($paypalPaymentGateway == null) { $logger->LogError("Payment gateway could not be found!"); header('Location: booking-failure.php?error_code=9'); } $emailSender = new EmailSender(); require_once 'paypal.class.php'; $p = new paypal_class(); $p->paypal_url = $paypalPaymentGateway->getUrl(); // 'https://www.sandbox.paypal.com/cgi-bin/webscr'; // testing paypal url // 'https://www.paypal.com/cgi-bin/webscr'; // paypal url // setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php') $this_script = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; // if there is not action variable, set the default action of 'process' if (empty($_GET['action'])) { $_GET['action'] = 'process'; } switch ($_GET['action']) { case 'process': // Process and order... $logger->LogInfo("Procesisng request for payment to PayPal ...");
// Validate booking info $logger->LogInfo("Checking if booking details object is valid ..."); if (!$bookingDetails->isValid()) { $logger->LogError("BookingDetails are not valid!"); $logger->LogError($bookingDetails->errors); $_SESSION['errors'] = $bookingDetails->errors; header('Location: booking-failure.php'); } // Get payment gateway $logger->LogInfo("Looking up payment gateway ..."); if (!isset($_POST['payment_gateway_code'])) { $logger->LogError("Payment gateway code not in POST!"); header('Location: booking-failure.php?error_code=9'); } $logger->LogInfo("Fetching payment gateway for code: " . $_POST['payment_gateway_code'] . "..."); $paymentGateway = PaymentGateway::fetchFromDbForCode($_POST['payment_gateway_code']); if ($paymentGateway == null) { $logger->LogError("Payment gateway code: " . $_POST['payment_gateway_code'] . " not in database!"); header('Location: booking-failure.php?error_code=9'); } $bookingDetails->paymentGateway = $paymentGateway; // Check for concurent booking $logger->LogInfo("Checking for concurrent booking ..."); if (!$bookingDetails->isBookingStillAvailable()) { $logger->LogWarn("Concurrent booking found!"); header('Location: booking-failure.php?error_code=13'); } // Save booking $logger->LogInfo("Saving booking ..."); if (!$bookingDetails->saveBooking($language_selected)) { $logger->LogError("Saving booking failed!");