-
Notifications
You must be signed in to change notification settings - Fork 1
/
flw.php
73 lines (69 loc) · 3.2 KB
/
flw.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
<?php
//these sessions were created from another file
$course_title = $_SESSION['course_title'];
$tuition = $_SESSION['tuition'];
$duration = $this_course['duration'];
$user_phone = $_SESSION['phone'];
$user_email = $_SESSION['email'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Make Payment</title>
</head>
<body>
<div class="card pay">
<div class="card-header">
<h5>Course: <?php echo $course_title; ?></h5>
<h6>Duration: <?php echo $duration; ?> weeks</h6>
<h6>Course fee: ₦<?php echo $tuition; ?></h6>
</div>
<div class="card-body">
<!-- //// begins flutterwave payment code //// -->
<small>Pay online with your debit card</small>
<input type="submit" class="btn btn-success btn-lg w-100" style="cursor:pointer;" value="Pay Now" id="submit" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- using flutterwave inline payment method -->
<script type="text/javascript" src="https://api.ravepay.co/flwv3-pug/getpaidx/api/flwpbf-inline.js"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById('submit').addEventListener('click', function () {
//change to your API public key
var flw_ref = "", chargeResponse = "", trxref = "FDKHGK"+ Math.random(), API_publicKey = "FLWPUBK-3-------------------------X";
//json_encode convert a PHP data/variable to a JavaScript format
var total_ea = <?php echo $tuition;?>;
var email_ea = <?php echo (json_encode($user_email)); ?>;
var phone_ea = <?php echo (json_encode($user_phone)); ?>;
var ref_ea = <?php echo(json_encode($trnref)); ?>;
getpaidSetup(
{
PBFPubKey: API_publicKey,
customer_email: email_ea,
amount: total_ea,
customer_phone: phone_ea,
currency: "NGN",
txref: ref_ea,
meta: [{metaname:"EA-NG", metavalue: "NG"}],
onclose:function(response) {
},
callback:function(response) {
txref = response.data.txRef, chargeResponse = response.data.chargeResponseCode;
if (chargeResponse == "00" || chargeResponse == "0") {
//send user to a failure page if payment fails
window.location = "payment-failed.html";
} else {
//send user to a success page
window.location = "thank-you.html";
}
}
});
});
});
</script>
</div>
</div>
</body>
</html>