-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtop-up.html
118 lines (112 loc) · 3.74 KB
/
top-up.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wallet Top Up</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
#walletContainer {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
#walletContainer h2 {
margin-bottom: 20px;
color: #333;
}
#walletContainer p {
margin-bottom: 20px;
color: #666;
}
#walletBalance {
font-size: 24px;
margin-bottom: 20px;
}
input {
width: 100px;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
font-weight: bold;
text-transform: uppercase;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
@media (max-width: 500px) {
#walletContainer {
width: 90%;
padding: 15px;
}
button {
font-size: 14px;
}
}
</style>
</head>
<body>
<div id="walletContainer">
<h2>Top Up Your Wallet</h2>
<p>Quickly and securely top up your wallet using Paystack. Enter your details below to get started.</p>
<div id="walletBalance">Balance: GHC 0.00</div>
<form id="topUpForm">
<input type="email" id="email" placeholder="Email" required />
<input type="number" id="amount" placeholder="Amount (GHS)" required />
<button type="submit">Top Up</button>
</form>
</div>
<script src="https://js.paystack.co/v2/inline.js"></script>
<script>
const topUpForm = document.getElementById('topUpForm');
const walletBalance = document.getElementById('walletBalance');
topUpForm.addEventListener('submit', topUpWithPaystack, false);
function topUpWithPaystack(e) {
e.preventDefault();
let handler = PaystackPop.setup({
key: 'pk_test_10779c145f832a67310f9831d6be320c868e7070',
email: document.getElementById('email').value,
amount: document.getElementById('amount').value * 100,
currency: 'GHS',
callback: function(response) {
alert('Top-up successful. Transaction reference: ' + response.reference);
// Update customer's balance on your server
updateWalletBalance(document.getElementById('amount').value);
},
onClose: function() {
alert('Transaction was not completed, window closed.');
}
});
handler.openIframe();
}
function updateWalletBalance(amount) {
let currentBalance = parseFloat(walletBalance.textContent.replace('Balance: GHC ', ''));
let newBalance = currentBalance + parseFloat(amount);
walletBalance.textContent = 'Balance: GHC ' + newBalance.toFixed(2);
}
</script>
</body>
</html>