PK

ADDRLIN : /home/anibklip/aelogifts.com/
FLL :
Current File : //home/anibklip/aelogifts.com/charge.php

<?php
include "conn.php";
check_login();

/* echo "<pre>"; print_r($_POST); print_r($_SESSION);echo "</pre>";
if($_POST['razorpay_payment_id']){
	$order_id=$_SESSION['order_id'];

	$query = "SELECT * from orders as o where o.order_id= '$order_id' ";
	$query = mysqli_query($conn, $query) or die(mysqli_error($conn));
	if ($order = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
		// echo "<pre>";print_r($order); echo "</pre>";
	}
	
	$keyId = 'rzp_live_ZzlSSwkpCRmlHp';
	$keySecret = 'EAwdD4CyPtfeMxaZZSK5JehO';

	// $api = new Api($keyId, $keySecret);
	// $post_json = "{\n  \"amount\": \"109\",\n  \"currency\": \"INR\"\n}";
	$order['total']=$order['total']*100;
	$post_json = "{\n  \"amount\": \"".$order['total']."\",\n  \"currency\": \"INR\"\n}";
	echo ($post_json);
	// die;

	// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
	$ch = curl_init();

	// curl_setopt($ch, CURLOPT_URL, 'https://api.razorpay.com/v1/payments/'.$_POST['razorpay_payment_id']);
	curl_setopt($ch, CURLOPT_URL, 'https://api.razorpay.com/v1/payments/'.$_POST['razorpay_payment_id'].'/capture');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

	curl_setopt($ch, CURLOPT_HTTPHEADER, [
		'content-type: application/json',
	]);
	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

	curl_setopt($ch, CURLOPT_USERPWD, $keyId . ':' . $keySecret);
	// curl_setopt($ch, CURLOPT_POSTFIELDS, "{'amount': ".$order['total'].", 'currency': 'INR'}");
	// curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n  \"amount\": ".$order['total'].",\n  \"currency\": \"INR\"\n}");
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);

	$result_string = curl_exec($ch);

	$result=json_decode($result_string);
	// echo "<pre>";print_r($result);echo "</pre>";
	// echo $result->error->code;

	if (curl_errno($ch)) {
		echo 'Error:' . curl_error($ch);
	}
	curl_close($ch);

	$q="UPDATE orders SET razorpay_payment_id = '".$_POST['razorpay_payment_id']."', payment_response='".$result_string."' where order_id = '".$_SESSION['order_id']."' "; 
	mysqli_query($conn, $q);

	//////////////////////////////// SEND MAIL N SMS START //////////////////////////////////////
	send_order_email_sms($order_id);
	//////////////////////////////// SEND MAIL N SMS END //////////////////////////////////////
	
	$_SESSION['cart']="";
	$_SESSION['coupon']="";
	$_SESSION['coupon_msg']="";

	/*$qi="SELECT * from orders where order_id='$order_id'";
	$qi=mysqli_query($GLOBALS["conn"], $qi) or die(mysqli_error($GLOBALS["conn"]));
	if($r=mysqli_fetch_array($qi)){
		$sql = "SELECT * FROM order_details WHERE order_id='$r[order_id]'";
		$sql=mysqli_query($GLOBALS["conn"], $sql) or die(mysqli_error($GLOBALS["conn"]));
		while($prd=mysqli_fetch_array($sql)){
			$q="UPDATE prd set stock_qty=stock_qty-$qty where pid='$prd[pid]'";
			mysqli_query($GLOBALS["conn"], $q) or die(mysqli_error($GLOBALS["conn"]));
		}
	}* /
} */

/* if($_GET['rand_order_id']){
	$query = "SELECT * from orders as o where rand_order_id = '".base64_decode(base64_decode($_GET['order_id']))."'  ";
}else{
	$query = "SELECT * from orders as o where razorpay_payment_id = '".$_POST['razorpay_payment_id']."'  ";
	
	// 	curl --location 'https://api.razorpay.com/v1/payments/pay_PW0EIaz83pLA0o' \
	// --header 'Authorization: Basic cnpwX2xpdmVfWnpsU1N3a3BDUm1sSHA6RUF3ZEQ0Q3lQdGZlTXhhWlpTSzVKZWhP'
} */

$query = "SELECT * from orders as o where order_id = '".$_GET['order_id']."'  ";
$query = mysqli_query($conn, $query) or die(mysqli_error($conn));
if ($order = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
	// var_dump($order);
}

include "header.php";

?>
<section class="section-b-space light-layout">
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<div class="success-text">
					<div class="checkmark">
						<svg class="star" height="19" viewBox="0 0 19 19" width="19" xmlns="http://www.w3.org/2000/svg">
							<path d="M8.296.747c.532-.972 1.393-.973 1.925 0l2.665 4.872 4.876 2.66c.974.532.975 1.393 0 1.926l-4.875 2.666-2.664 4.876c-.53.972-1.39.973-1.924 0l-2.664-4.876L.76 10.206c-.972-.532-.973-1.393 0-1.925l4.872-2.66L8.296.746z">
							</path>
						</svg>
						<svg class="star" height="19" viewBox="0 0 19 19" width="19" xmlns="http://www.w3.org/2000/svg">
							<path d="M8.296.747c.532-.972 1.393-.973 1.925 0l2.665 4.872 4.876 2.66c.974.532.975 1.393 0 1.926l-4.875 2.666-2.664 4.876c-.53.972-1.39.973-1.924 0l-2.664-4.876L.76 10.206c-.972-.532-.973-1.393 0-1.925l4.872-2.66L8.296.746z">
							</path>
						</svg>
						<svg class="star" height="19" viewBox="0 0 19 19" width="19" xmlns="http://www.w3.org/2000/svg">
							<path d="M8.296.747c.532-.972 1.393-.973 1.925 0l2.665 4.872 4.876 2.66c.974.532.975 1.393 0 1.926l-4.875 2.666-2.664 4.876c-.53.972-1.39.973-1.924 0l-2.664-4.876L.76 10.206c-.972-.532-.973-1.393 0-1.925l4.872-2.66L8.296.746z">
							</path>
						</svg>
						<svg class="star" height="19" viewBox="0 0 19 19" width="19" xmlns="http://www.w3.org/2000/svg">
							<path d="M8.296.747c.532-.972 1.393-.973 1.925 0l2.665 4.872 4.876 2.66c.974.532.975 1.393 0 1.926l-4.875 2.666-2.664 4.876c-.53.972-1.39.973-1.924 0l-2.664-4.876L.76 10.206c-.972-.532-.973-1.393 0-1.925l4.872-2.66L8.296.746z">
							</path>
						</svg>
						<svg class="star" height="19" viewBox="0 0 19 19" width="19" xmlns="http://www.w3.org/2000/svg">
							<path d="M8.296.747c.532-.972 1.393-.973 1.925 0l2.665 4.872 4.876 2.66c.974.532.975 1.393 0 1.926l-4.875 2.666-2.664 4.876c-.53.972-1.39.973-1.924 0l-2.664-4.876L.76 10.206c-.972-.532-.973-1.393 0-1.925l4.872-2.66L8.296.746z">
							</path>
						</svg>
						<svg class="star" height="19" viewBox="0 0 19 19" width="19" xmlns="http://www.w3.org/2000/svg">
							<path d="M8.296.747c.532-.972 1.393-.973 1.925 0l2.665 4.872 4.876 2.66c.974.532.975 1.393 0 1.926l-4.875 2.666-2.664 4.876c-.53.972-1.39.973-1.924 0l-2.664-4.876L.76 10.206c-.972-.532-.973-1.393 0-1.925l4.872-2.66L8.296.746z">
							</path>
						</svg>
						<svg class="checkmark__check" height="36" viewBox="0 0 48 36" width="48" xmlns="http://www.w3.org/2000/svg">
							<path d="M47.248 3.9L43.906.667a2.428 2.428 0 0 0-3.344 0l-23.63 23.09-9.554-9.338a2.432 2.432 0 0 0-3.345 0L.692 17.654a2.236 2.236 0 0 0 .002 3.233l14.567 14.175c.926.894 2.42.894 3.342.01L47.248 7.128c.922-.89.922-2.34 0-3.23">
							</path>
						</svg>
						<svg class="checkmark__background" height="115" viewBox="0 0 120 115" width="120" xmlns="http://www.w3.org/2000/svg">
							<path d="M107.332 72.938c-1.798 5.557 4.564 15.334 1.21 19.96-3.387 4.674-14.646 1.605-19.298 5.003-4.61 3.368-5.163 15.074-10.695 16.878-5.344 1.743-12.628-7.35-18.545-7.35-5.922 0-13.206 9.088-18.543 7.345-5.538-1.804-6.09-13.515-10.696-16.877-4.657-3.398-15.91-.334-19.297-5.002-3.356-4.627 3.006-14.404 1.208-19.962C10.93 67.576 0 63.442 0 57.5c0-5.943 10.93-10.076 12.668-15.438 1.798-5.557-4.564-15.334-1.21-19.96 3.387-4.674 14.646-1.605 19.298-5.003C35.366 13.73 35.92 2.025 41.45.22c5.344-1.743 12.628 7.35 18.545 7.35 5.922 0 13.206-9.088 18.543-7.345 5.538 1.804 6.09 13.515 10.696 16.877 4.657 3.398 15.91.334 19.297 5.002 3.356 4.627-3.006 14.404-1.208 19.962C109.07 47.424 120 51.562 120 57.5c0 5.943-10.93 10.076-12.668 15.438z">
							</path>
						</svg>
					</div>
					<h2>thank you</h2>
					<p>Your order is successfully processsed.</p>
					<?php
					if($_POST['razorpay_payment_id']){
						?>
						<p class="font-weight-bold">Transaction ID: <?php echo $_POST['razorpay_payment_id'];?></p>
						<?php
					}
					?>
				</div>
			</div>
		</div>
	</div>
</section>

<section class="section-b-space">
	<div class="container">
		<div class="row">
			<div class="col-lg-12">
				<div class="order-success-sec">
					<div class="row">
						<div class="col-sm-6">
							<h4>summary</h4>
							<ul class="order-detail">
								<li>order ID: &nbsp;<strong><?php echo $order['order_id'];?></strong></li>
								<li>Order Date: &nbsp;<strong><?php echo date("M d, Y", strtotime($order['dt']));?></strong></li>
								<li>Order Total: &nbsp;<strong><?php echo number_format($order['total'], 2);?>/-</strong></li>
							</ul>
						</div>
						<div class="col-sm-6">
							<h4>shipping address</h4>
							<ul class="order-detail">
								<li><?php echo $order['address'];?> <?php echo $order['address1'];?></strong></li>
								<li><?php echo $order['state'];?></strong></li>
								<li><?php echo $order['city'];?> <?php echo $order['postcode'];?></strong></li>
								<li>Contact No. <?php echo $order['mobile'];?></strong></li>
							</ul>
						</div>
						<div class="col-sm-12 payment-mode">
							<h4>payment method</h4>
							<p style="font-weight: 600;"><?php echo strtoupper($order['payment_method']);?></p>
						</div>
						<div class="col-md-12">
							<div class="delivery-sec">
								<h3>expected date of delivery: <span>within 7 days</span></h3>
								<!-- <a href="order-tracking.html">track order</a> -->
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<?php
include "footer.php";
?>


PK 99