Booking-Payment.php

mail@pastecode.io avatar
unknown
php
a month ago
13 kB
0
Indexable
Never
<?php  
include("../../../wp-config.php");
require_once("paypal_pro.inc.php");
session_start();
global $wpdb;
global $woocommerce;
$tbl = $wpdb->prefix."booking";
$table_name = $wpdb->prefix."email_setting";
$payment_setting = $wpdb->prefix."payment_setting";
$paymentSetting = $wpdb->get_results("SELECT * FROM ".$payment_setting." WHERE id = 1");
if(count(WC()->cart->get_cart())>0){
if(isset($_SESSION['date']) && !empty($_SESSION['date']) && isset($_SESSION["location"]) && !empty($_SESSION["location"]) && isset($_SESSION["fname"]) && $_SESSION["fname"]!='' && isset($_SESSION["lname"]) && $_SESSION["lname"]!='' && isset($_SESSION["email"]) && $_SESSION["email"]!=''){

$firstName =urlencode($_SESSION['fname']);
$lastName =urlencode($_SESSION['lname']);
$creditCardType = urlencode($_REQUEST['card_type']);
$creditCardNumber = urlencode($_REQUEST['card_no']);
$expDateMonth = urlencode($_REQUEST['card_month']);
$padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
$expDateYear = urlencode($_REQUEST['card_year']);
$cvv2Number = urlencode($_REQUEST['card_cvv']);
$address1 = urlencode($_SESSION['location']);
$address2 = '';
$city = '';
$state = '';
$zip = '';
$amount = urlencode($_SESSION["total_charge"]);
$currencyCode="USD";
$paymentAction = urlencode("Sale");
$methodToCall = 'doDirectPayment';
$currency_symbol = get_woocommerce_currency_symbol(); 
$product_description = strip_tags(trim($_SESSION["product_description"]));
if($product_description){
	$product_description = '('.$product_description.')';
}else{
	$product_description = '';
}

$nvpstr='&PAYMENTACTION='.$paymentAction.'&AMT='.$amount.'&CREDITCARDTYPE='.$creditCardType.'&ACCT='.$creditCardNumber.'&EXPDATE='.$padDateMonth.$expDateYear.'&CVV2='.$cvv2Number.'&FIRSTNAME='.$firstName.'&LASTNAME='.$lastName.'&STREET='.$address1.'&CITY='.$city.'&STATE='.$state.'&ZIP='.$zip.'&COUNTRYCODE=US&CURRENCYCODE='.$currencyCode;

$paypalPro = new paypal_pro($paymentSetting[0]->paypal_user, $paymentSetting[0]->paypal_password, $paymentSetting[0]->paypal_sign, '', '', FALSE, FALSE );
$resArray = $paypalPro->hash_call($methodToCall,$nvpstr);
$ack = strtoupper($resArray["ACK"]);
if($ack=="SUCCESS")
{
	$wpdb->query("INSERT $tbl SET date = '".$_SESSION["date"]."', location = '".$_SESSION["location"]."', product_id = '".$_SESSION["product_id"]."', product_name = '".$_SESSION["product_name"]."', product_description = '".$_SESSION["product_description"]."', pickup_piont = '".$_SESSION["pickup_piont"]."', pickup_point_name = '".$_SESSION["pickup_point_name"]."', adult_qty = '".$_SESSION["adult_qty"]."', student_qty = '".$_SESSION["student_qty"]."', child_qty = '".$_SESSION["child_qty"]."', add_ons_qty = '".$_SESSION["add_ons_qty"]."', adult_price = '".$_SESSION["adult_price"]."', student_price = '".$_SESSION["student_price"]."', child_price = '".$_SESSION["child_price"]."', add_ons_price = '".$_SESSION["add_price"]."', total_charge = '".$_SESSION["total_charge"]."',
	add_ons_text = '".$_SESSION["add-ons_text"]."', fname = '".$_SESSION["fname"]."',  lname = '".$_SESSION["lname"]."', citizenship = '".$_SESSION["citizenship"]."', email = '".$_SESSION["email"]."', phone = '".$_SESSION["phone"]."', notes = '".$_SESSION["notes"]."', agree ='".$_SESSION["agree"]."', currency_symbol ='".$currency_symbol."', card_type = '".$creditCardType."' , payment_status = '".$resArray["ACK"]."', currency_code = '".$resArray["CURRENCYCODE"]."', transaction_id = '".$resArray["TRANSACTIONID"]."'");
    $result = $wpdb->get_results("SELECT * FROM ".$table_name." WHERE id = 1");
	$to = $result[0]->admin_email;
	$from = $_SESSION["email"];
	$subject = $result[0]->admin_subject;
	$subject_1 = $result[0]->user_subject;
	$email_message = "<html xmlns='https://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <title>Booking Datails</title> <style>body{font-family: Tahoma, sans-serif; padding: 0; margin: 0;}a{color: #9b790f; text-decoration: none;}a:hover{color: #fcc904;}</style> </head> <body> <div style='width:100%;' align='center'> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td align='center' valign='top' style='background-color:#ffffff; padding: 10px;' bgcolor='#ffffff;'> <table width='600' border='0' cellspacing='0' cellpadding='0' bgcolor='#ffffff' style='background-color:#ffffff;border:solid 1px #484848;'> <tr> <td align='center' valign='top' style='color:#000; font-family: Tahoma; font-size:16px;padding: 25px 15px 15px;'> <table width='100%' border='0' cellspacing='0' cellpadding='0' style='border-bottom: solid 6px #026db3;'> <tr> <td align='left' valign='middle' style='padding-bottom: 28px;'> <a href='".site_url()."'><img src='".site_url()."/wp-content/uploads/2020/08/logo.png' style='display:block;'></a> </td><td align='right' valign='middle' style='color: #000;font-size: 12.75px;font-family: Tahoma;padding-bottom: 28px;'></td></tr></table> <table width='100%' border='0' cellspacing='0' cellpadding='0' style='margin-top: 30px; margin-bottom: 30px;'><tr><td align='left' valign='middle' style='color: #000;font-size: 12.75px;font-family: Tahoma;'><b>Israel Transport - Booking Details</b><br/><br/><strong>Product Name: </strong>".$_SESSION["product_name"]."<br/><strong>Date Of Tour: </strong>".$_SESSION["date"]."<br/><strong>Location: </strong>".$_SESSION["location"]."<br/><strong>Pickup Point: </strong>".$_SESSION["pickup_point_name"].' '.$product_description."<br/><strong>Name: </strong>".$_SESSION["fname"].' '.$_SESSION["lname"]."<br/><strong>Email: </strong>".$_SESSION["email"]."<br/><strong>Citizenship: </strong>".$_SESSION["citizenship"]."<br/><strong>Phone: </strong>".$_SESSION["phone"]."<br/><strong>Notes: </strong>".$_SESSION["notes"]."<br/><strong>Payment Status: </strong>".$resArray["ACK"]."<br/><strong>Transaction Id: </strong>".$resArray["TRANSACTIONID"]."<br/><h4 style='margin-bottom: 6px;'>Number of People</h4><table width='100%' border='1' cellspacing='0' cellpadding='0'><tbody><tr><td width='33%' style='padding:4px'>Adults from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["adult_qty"]."</td><td width='34%' style='padding:4px'>".$currency_symbol.$_SESSION["adult_price"]."</td></tr><tr><td width='33%' style='padding:4px'>Students from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["student_qty"]."</td><td width='34%' style='padding:4px'>".$currency_symbol.$_SESSION["student_price"]."</td></tr><tr><td width='33%' style='padding:4px'>Child from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["child_qty"]."</td><td width='34%' style='padding:4px'>".$currency_symbol.$_SESSION["child_price"]."</td></tr><tr><td width='33%' style='padding:4px'><b>".$_SESSION["add-ons_text"]."</b> from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["add_ons_qty"]."</td><td width='34%' style='padding:4px'><label>".$currency_symbol.$_SESSION["add_price"]."</label></td></tr><tr><th></th><th style='padding:4px;text-align:left'><label>Total Price</label></th><th style='padding:4px;text-align:left'>".$currency_symbol.$_SESSION["total_charge"]."</th></tr></tbody></table><br/></td></tr></table> <table width='100%' border='0' cellspacing='0' cellpadding='0' style='padding-top: 15px;'> <tr> <td align='center' valign='middle' style='color: #fff;font-size: 12.75px;font-family: Tahoma; background: #484848; padding: 10px 20px;'>".$result[0]->user_copyright."</td></tr></table></td></tr></table> </td></tr></table> </div></body></html>";
			$headers = "MIME-Version: 1.0\n";
			@$headers .= "Content-type: text/html; charset=iso-8859-1\n";
			@$headers .= "X-Priority: 3\n";
			@$headers .= "X-MSMail-Priority: Normal\n";
			@$headers .= "X-Mailer: php\n";
			@$headers .= "From: ".$subject." <" .$from. ">\r\n";
			@mail($to, $subject, $email_message, $headers); 
	$email_message_1 = "<html xmlns='https://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <title>Booking Datails</title> <style>body{font-family: Tahoma, sans-serif; padding: 0; margin: 0;}a{color: #9b790f; text-decoration: none;}a:hover{color: #fcc904;}</style> </head> <body> <div style='width:100%;' align='center'> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td align='center' valign='top' style='background-color:#ffffff; padding: 10px;' bgcolor='#ffffff;'> <table width='600' border='0' cellspacing='0' cellpadding='0' bgcolor='#ffffff' style='background-color:#ffffff;border:solid 1px #484848;'> <tr> <td align='center' valign='top' style='color:#000; font-family: Tahoma; font-size:16px;padding: 25px 15px 15px;'> <table width='100%' border='0' cellspacing='0' cellpadding='0' style='border-bottom: solid 6px #026db3;'> <tr> <td align='left' valign='middle' style='padding-bottom: 28px;'> <a href='".site_url()."'><img src='".site_url()."/wp-content/uploads/2020/08/logo.png' style='display:block;'></a> </td><td align='right' valign='middle' style='color: #000;font-size: 12.75px;font-family: Tahoma;padding-bottom: 28px;'></td></tr></table> <table width='100%' border='0' cellspacing='0' cellpadding='0' style='margin-top: 30px; margin-bottom: 30px;'><tr><td align='left' valign='middle' style='color: #000;font-size: 12.75px;font-family: Tahoma;'><p>Hello ".$_SESSION["fname"].' '.$_SESSION["lname"].".</p><p>".$result[0]->user_message."</p><p><b>Israel Transport - Booking Details</b></p><strong>Product Name: </strong>".$_SESSION["product_name"]."<br/><strong>Date Of Tour: </strong>".$_SESSION["date"]."<br/><strong>Location: </strong>".$_SESSION["location"]."<br/><strong>Pickup Point: </strong>".$_SESSION["pickup_point_name"].' '.$product_description."<br/><strong>Name: </strong>".$_SESSION["fname"].' '.$_SESSION["lname"]."<br/><strong>Email: </strong>".$_SESSION["email"]."<br/><strong>Citizenship: </strong>".$_SESSION["citizenship"]."<br/><strong>Phone: </strong>".$_SESSION["phone"]."<br/><strong>Notes: </strong>".$_SESSION["notes"]."<br/><strong>Payment Status: </strong>".$resArray["ACK"]."<br/><strong>Transaction Id: </strong>".$resArray["TRANSACTIONID"]."<br/><h4 style='margin-bottom: 6px;'>Number of People</h4><table width='100%' border='1' cellspacing='0' cellpadding='0'><tbody><tr><td width='33%' style='padding:4px'>Adults from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["adult_qty"]."</td><td width='34%' style='padding:4px'>".$currency_symbol.$_SESSION["adult_price"]."</td></tr><tr><td width='33%' style='padding:4px'>Students from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["student_qty"]."</td><td width='34%' style='padding:4px'>".$currency_symbol.$_SESSION["student_price"]."</td></tr><tr><td width='33%' style='padding:4px'>Child from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["child_qty"]."</td><td width='34%' style='padding:4px'>".$currency_symbol.$_SESSION["child_price"]."</td></tr><tr><td width='33%' style='padding:4px'><b>".$_SESSION["add-ons_text"]."</b> from ".$_SESSION["pickup_point_name"]."</td><td width='33%' style='padding:4px'>".$_SESSION["add_ons_qty"]."</td><td width='34%' style='padding:4px'><label>".$currency_symbol.$_SESSION["add_price"]."</label></td></tr><tr><th></th><th style='padding:4px;text-align:left'><label>Total Price</label></th><th style='padding:4px;text-align:left'>".$currency_symbol.$_SESSION["total_charge"]."</th></tr></tbody></table><br/></td></tr></table> <table width='100%' border='0' cellspacing='0' cellpadding='0' style='padding-top: 15px;'> <tr> <td align='center' valign='middle' style='color: #fff;font-size: 12.75px;font-family: Tahoma; background: #484848; padding: 10px 20px;'>".$result[0]->user_copyright."</td></tr></table></td></tr></table> </td></tr></table> </div></body></html>";
			$headers = "MIME-Version: 1.0\n";
			@$headers .= "Content-type: text/html; charset=iso-8859-1\n";
			@$headers .= "X-Priority: 3\n";
			@$headers .= "X-MSMail-Priority: Normal\n";
			@$headers .= "X-Mailer: php\n";
			@$headers .= "From: ".$subject_1." <" .$to. ">\r\n";
			@mail($from, $subject_1, $email_message_1, $headers); 
	unset($_SESSION["date"]);
	unset($_SESSION["location"]);
	unset($_SESSION["fname"]);
	unset($_SESSION["lname"]);
	unset($_SESSION["citizenship"]);
	unset($_SESSION["email"]);
	unset($_SESSION["phone"]);
	unset($_SESSION["notes"]);
	unset($_SESSION["agree"]);
	unset($_SESSION["pickup_piont"]);
	unset($_SESSION["pickup_point_name"]);
	unset($_SESSION["adult_qty"]);
	unset($_SESSION["adult_price"]);
	unset($_SESSION["student_qty"]);
	unset($_SESSION["student_price"]);
	unset($_SESSION["child_qty"]);
	unset($_SESSION["child_price"]);
	unset($_SESSION["add_ons_qty"]);
	unset($_SESSION["add_price"]);
	unset($_SESSION["add-ons_text"]);
	unset($_SESSION["product_name"]);
	unset($_SESSION["product_description"]);
	unset($_SESSION["product_id"]);
	unset($_SESSION["image"]);
	unset($_SESSION['vid']);
	$woocommerce->cart->empty_cart();  
echo "<script type='text/javascript'>window.location='".get_permalink(485)."?key=".base64_encode($resArray["TRANSACTIONID"])."'</script>";
}
else
{
	echo $resArray['L_LONGMESSAGE0'];exit;
} 
}else{
echo 0;
}
}
?>
Leave a Comment