$values[] = $_POST['flight']; $values[] = $_POST['parking_points']; $values[] = $_POST['discount_type']; $types = 'ssssssssssssssiissi'; if ($db->insert('bookings', $keys, $values, $types)) { $error = "Booking added successfully!"; } else { $error = "Booking added unsuccessfully - Query failed!"; } $_POST['payment_type'] = 'Online payment'; $data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email_address'], 'telephone' => $_POST['telephone'], 'departDate' => $_POST['departDate'], 'departTime' => $_POST['departTime'], 'arriveDate' => $_POST['arrivaDate'], 'arriveTime' => $_POST['arriveTime'], 'model' => $_POST['vehicleModel'], 'color' => $_POST['vehicleColor'], 'registration' => $_POST['vehicleRegistration'], 'discountType' => $_POST['discountType'], 'discount' => $_POST['discountPercent'], 'payment_type' => $_POST['payment_type'], 'meetup_time' => $_POST['meet'], 'points' => $_POST['parking_points'], 'flight' => $_POST['code'], 'cost' => $_POST['cost']); $booking_id = $db->insertID(); //user email $emailer->OnlinePaymentEmail($data); //Request email $emailer->OnlinePaymentRequestEmail($data); if ($_POST['discountType'] == 'Voucher') { $db->delete('vouchers', 'code = "' . $_POST['code'] . '"'); } //confirmation email //$emailer->OnlinePaymentEmail($data); $current_url = str_replace("ajax_emailer.php", "", $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]); $string = "merchant_id=10501735&merchant_key=qybq1xly1ph0v&return_url=" . urlencode(trim('http://' . $current_url . 'index.php?result=success&id=' . $booking_id)) . "&cancel_url=" . urlencode(trim('http://www.' . $current_url . 'index.php?result=cancel')) . "¬ify_url=" . urlencode(trim('http://www.' . $current_url . 'index.php?result=notify')) . "&name_first=" . urlencode(trim($_POST['firstname'])) . "&name_last=" . urlencode(trim($_POST['lastname'])) . "&email_address=" . urlencode(trim($_POST['email_address'])) . "&m_payment_id=" . urlencode(trim($_POST['vehicleRegistration'])) . "&amount=" . urlencode(trim($_POST['cost'])) . "&item_name=Parking&email_confirmation=1&confirmation_address=" . urlencode(trim('*****@*****.**')); //$string = "merchant_id=10501735&merchant_key=qybq1xly1ph0v&return_url=".urlencode(trim('http://www.'.$current_url.'index.php?result=success'))."&cancel_url=".urlencode(trim('http://www.'.$current_url.'payment_results.php?index=cancel'))."&name_first=".$_POST['firstname']."&name_last=".$_POST['lastname']."&email_address=".urlencode(trim($_POST['email_address']))."&m_payment_id=".$_POST['vehicleRegistration']."&amount=".$_POST['cost']."&item_name=Parking&email_confirmation=1&confirmation_address=".urlencode(trim('*****@*****.**')); $signature = md5($string); $response = array('signature' => $signature, 'return_url' => 'http://' . $current_url . 'index.php?result=success&id=' . $booking_id); echo json_encode($response); break; case 'transfer': //$db->addBooking($_POST); $keys = array();