-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
146 lines (126 loc) · 4.48 KB
/
index.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
require_once('Mpesa.php');
$hasQr = false;
if ($_GET['getqr']) {
Mpesa::send(
'10',
1
);
$resp = json_decode(Mpesa::$response);
$success = 00;
$error = 401;
if ($success == $resp->ResponseCode) {
$hassuccess = true;
echo "<script>alert ('$resp->ResponseDescription') </script>";
}
if (isset($resp->QRCode)) {
$hasQr = true;
$qrImage = "data:image/jpeg;base64, {$resp->QRCode}";
}
elseif ($success == $resp->ResponseCode) {
$hassuccess = true;
echo "<script>alert ('$resp->ResponseDescription') </script>";
}
elseif ($error == $resp->errorCode) {
$haserror = true;
echo "<script>alert ('$resp->errorMessage') </script>";
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v4.1.1">
<title>M-pesa QR Checkout example ¡¤ Host Pro</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.5/examples/checkout/">
<!-- Bootstrap core CSS -->
<link href="./assets/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link href="form-validation.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container">
<div class="py-5 text-center">
<img class="d-block mx-auto mb-1" src="./assets/brand/mpesa.png" alt="" width="172">
<h2>QR Checkout</h2>
<p class="lead">Below is an M-PESA QR Checkout example.</p>
</div>
<div class="row">
<div class="col-md-5 order-md-2 mb-2 mx-auto">
<h4 class="d-flex justify-content-between align-items-center mb-3">
<span class="text-muted">Your cart</span>
<span class="badge badge-secondary badge-pill">3</span>
</h4>
<ul class="list-group mb-3">
<li class="list-group-item d-flex justify-content-between lh-condensed">
<div>
<h6 class="my-0">Product name</h6>
<small class="text-muted">Brief description</small>
</div>
<span class="text-muted">KES 39</span>
</li>
<li class="list-group-item d-flex justify-content-between bg-light">
<div class="text-success">
<h6 class="my-0">Promo code</h6>
<small>EXAMPLECODE</small>
</div>
<span class="text-success">-KES 15</span>
</li>
<li class="list-group-item d-flex justify-content-between">
<span>Total (KES)</span>
<strong>KES 20</strong>
</li>
</ul>
<?php if ($hasQr) : ?>
<form class="card p-2">
<img src="<?= $qrImage ?>" alt="" srcset="">
</form>
<?php endif; ?>
<form class="p-2">
<div class="input-group">
<input type="number" hidden class="form-control" value="1">
<input type="text" name="getqr" hidden class="form-control" value="1">
<?php if ($hasQr) : ?>
<button type="submit" class="btn btn-success btn-block">Refresh QR Code</button>
<?php else : ?>
<button type="submit" class="btn btn-success btn-block">Get QR Code</button>
<?php endif ?>
</div>
</form>
</div>
</div>
<footer class="my-5 pt-5 text-muted text-center text-small">
<p class="mb-1">© 2022 Host Pro</p>
<ul class="list-inline">
<li class="list-inline-item"><a href="#">Privacy</a></li>
<li class="list-inline-item"><a href="#">Terms</a></li>
<li class="list-inline-item"><a href="#">Support</a></li>
</ul>
</footer>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script>
window.jQuery || document.write('<script src="./assets/js/vendor/jquery.slim.min.js"><\/script>')
</script>
<script src="./assets/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>