forked from PaystackHQ/sample-paystack-pop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
58 lines (55 loc) · 1.73 KB
/
index.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
<html>
<head>
<script src="https://js.paystack.co/v2/inline.js"></script>
</head>
<body>
<form id="paymentForm">
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" id="email-address" required />
<br>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="tel" id="amount" required />
<br>
</div>
<div class="form-group">
<label for="first-name">First Name</label>
<input type="text" id="first-name" />
<br>
</div>
<div class="form-group">
<label for="last-name">Last Name</label>
<input type="text" id="last-name" />
<br>
</div>
<div class="form-submit">
<button type="submit"> Pay </button>
</div>
</form>
<script>
var paymentForm = document.getElementById('paymentForm');
paymentForm.addEventListener("submit", payWithPaystack, false);
function payWithPaystack(e) {
e.preventDefault();
var handler = PaystackPop.setup({
key: PUBLIC_KEY, // Replace with your public key
email: document.getElementById("email-address").value,
amount: document.getElementById("amount").value * 100,
firstname: document.getElementById("first-name").value,
lastname: document.getElementById("first-name").value,
ref: ''+Math.floor((Math.random() * 1000000000) + 1), // generates a pseudo-unique reference. Please replace with a reference you generated. Or remove the line entirely so our API will generate one for you
// label: "Optional string that replaces customer email"
onClose: function(){
alert('Window closed.');
},
callback: function(response){
window.location = "verify.php?reference=" + response.reference;
}
});
handler.openIframe();
}
</script>
</body>
</html>