-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcashfree-response.php
122 lines (116 loc) · 4.16 KB
/
cashfree-response.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
require 'includes/functions.php';
$page = "Thank you!";
$paymentstts = "EXPIRED";
$paymentmsg = "Request time out, Try again!";
if (isset($_GET['order_id']) || isset($_GET['order_token'])) {
$order_id = $_GET['order_id'];
$order_token = $_GET['order_token'];
$selectThisOrd = select("orders","order_id='$order_id' ORDER BY id DESC LIMIT 1");
if (howMany($selectThisOrd)>0) {
$fetchThisOrd = fetch($selectThisOrd);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/pg/orders/".$order_id,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-version: 2022-01-01",
"x-client-id: 17814226bf91d39ab958ad1482241871",
"x-client-secret: 1e7c6c04ab1d0a98aaba80ce82c57bd74724f9fa"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
// var_dump($response);
// exit();
if ($err) {
$paymentmsg = "cURL Error #:" . $err;
} else {
$res = json_decode($response);
if ($res->order_status=="PAID") {
$paymentstts = "Paid Successfully.";
$paymentmsg = "Thank you for purchasing from ".site_name.".";
update("tbl_payment",["status" => "Success"],"order_id='".$fetchThisOrd['id']."'");
}else{
$page = "Try again!";
deleteRow("tbl_payment","order_id='".$fetchThisOrd['id']."'");
deleteRow("orderitems","orderid='".$fetchThisOrd['id']."'");
deleteRow("orders","id='".$fetchThisOrd['id']."'");
$paymentmsg = "This order is aborted. If payment deducted from your account then request for Refund or Contact us for more details.";
}
}
}
}?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Place favicon.ico in the root directory -->
<?php include 'includes/style.php';?>
</head>
<body>
<div class="wrapper">
<!--Header Area Start-->
<?php include 'includes/header.php';?>
<!--Header Area End-->
<!--Page Banner2 Area Start-->
<div class="page-banner2-area">
<div class="container">
<div class="row">
<div class="col-12">
<div class="page-banner2-title">
<h2><?=$page?></h2>
</div>
</div>
</div>
</div>
</div>
<!--Page Banner Area End-->
<!--Breadcrumb Start-->
<div class="breadcrumb-Area">
<div class="container">
<div class="row">
<div class="col-12">
<div class="breadcrumb-content">
<ul>
<li><a href="index.php">Home</a></li>
<li class="active"><a href="#"><?=$page?></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!--Breadcrumb End-->
<div class="jumbotron text-xs-center">
<h1 class="display-3"><?=$page?></h1>
<h4 class="display-3"><?=$paymentstts?></h4>
<p class="lead"><?=$paymentmsg?></p>
<hr>
<p class="lead"><?php echo ($paymentstts == "Paid Successfully.") ? 'Your Order id #'.$order_id:'';?></p>
<h4>You will be redirecting in 1 min.</h4>
<p class="lead">
<a class="btn btn-primary btn-sm" href="index.php" role="button">Continue Shopping</a>
</p>
</div>
<?php include 'includes/footer.php';
include 'includes/script.php';?>
<script>
$(function(){
$("#cartData").attr('action', 'index.php');
setTimeout(function(){
$("#checkout-my-cart").click(); }, 60000);
});
</script>
</body>
</html>