-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout.php
109 lines (96 loc) · 4.08 KB
/
checkout.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
<?php
include('./dbConnection.php');
session_start();
if(!isset($_SESSION['stuLogEmail'])) {
echo "<script> location.href='loginorsignup.php'; </script>";
} else {
$stuEmail = $_SESSION['stuLogEmail'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Bootstrap CSS -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<!-- Font Awesome CSS -->
<link rel="stylesheet" type="text/css" href="css/all.min.css">
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<!-- Custom Style CSS -->
<link rel="stylesheet" type="text/css" href="./css/style.css" />
<title>Checkout</title>
</head>
<body>
<div class="container mt-5">
<div class="row">
<div class="col-sm-6 offset-sm-3 jumbotron">
<h3 class="mb-5">Welcome to E-Learning Payment Page</h3>
<form method="post" action="./paymentdone.php" id="myform">
<div class="form-group row">
<label for="ORDER_ID" class="col-sm-4 col-form-label">Order ID</label>
<div class="col-sm-8">
<input id="ORDER_ID" class="form-control" tabindex="1" maxlength="20" size="20" name="ORDER_ID" autocomplete="off"
value="<?php echo "ORDS" . rand(10000,99999999)?>" readonly>
</div>
</div>
<div class="form-group row">
<label for="CUST_ID" class="col-sm-4 col-form-label">Student Email</label>
<div class="col-sm-8">
<input id="CUST_ID" class="form-control" tabindex="2" maxlength="12" size="12" name="CUST_ID" autocomplete="off" value="<?php if(isset($stuEmail)){echo $stuEmail; }?>" readonly>
</div>
</div>
<div class="form-group row">
<label for="TXN_AMOUNT" class="col-sm-4 col-form-label">Amount</label>
<div class="col-sm-8">
<input title="TXN_AMOUNT" class="form-control" tabindex="10"
type="text" name="TXN_AMOUNT" value="<?php if(isset($_POST['id'])){echo $_POST['id']; }?>" readonly>
</div>
</div>
<div class="text-center">
<!-- Set up a container element for the button -->
<div id="paypal-button-container"></div>
<a href="./courses.php" class="btn btn-secondary">Cancel</a>
</div>
</form>
<small class="form-text text-muted">Note: Complete Payment by Clicking Checkout Button</small>
</div>
</div>
</div>
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=sb¤cy=USD"></script>
<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '<?php if(isset($_POST['id'])){echo $_POST['id']; }?>'
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
document.getElementById("myform").submit()
});
}
}).render('#paypal-button-container');
</script>
<!-- Jquery and Boostrap JavaScript -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!-- Font Awesome JS -->
<script type="text/javascript" src="js/all.min.js"></script>
<!-- Custom JavaScript -->
<script type="text/javascript" src="js/custom.js"></script>
</body>
</html>
<?php } ?>