-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpayment.html
More file actions
67 lines (60 loc) · 2.17 KB
/
payment.html
File metadata and controls
67 lines (60 loc) · 2.17 KB
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
<!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>Document</title>
</head>
<script>
function payWithPaystack() {
var handler = PaystackPop.setup({
key: 'pk_test_5e5b0d12c065cecf27c7439a85f805676bf6e3f6', // Replace with your public key
email: document.getElementById('email-address').value,
amount: document.getElementById('amount').value, // the amount value is multiplied by 100 to convert to the lowest currency unit
currency: 'NGN', // Use GHS for Ghana Cedis or USD for US Dollars
// ref: 'YOUR_REFERENCE', // Replace with a reference you generated
callback: function(response) {
//this happens after the payment is completed successfully
var reference = response.reference;
alert('Payment complete! Reference: ' + reference);
// Make an AJAX call to your server with the reference to verify the transaction
},
onClose: function() {
alert('Transaction was not completed, window closed.');
},
});
handler.openIframe();
}
var paymentForm = document.getElementById('paymentForm');
if(paymentForm){
paymentForm.addEventListener('submit', payWithPaystack, false);
}else{
console.log(paymentForm)
}
</script>
<body>
<form id="paymentForm">
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" id="email-address" required />
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="tel" id="amount" required />
</div>
<div class="form-group">
<label for="first-name">First Name</label>
<input type="text" id="first-name" />
</div>
<div class="form-group">
<label for="last-name">Last Name</label>
<input type="text" id="last-name" />
</div>
<div class="form-submit">
<button type="button" onclick="payWithPaystack()"> Pay </button>
</div>
</form>
</body>
</html>
<script src="https://js.paystack.co/v1/inline.js"></script>