-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (25 loc) · 932 Bytes
/
index.js
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
const customerDetail = document.getElementById("customerDetail");
const paymentForm = document.getElementById("paymentForm");
const detailHandler = (e) => {
e.preventDefault();
paymentForm.classList.remove("hidden");
customerDetail.classList.add("hidden");
};
const payWithPaystack = (e) => {
e.preventDefault();
let handler = PaystackPop.setup({
key: "pk_live_866c805918628ba828bc4c262244193647d49d98", // Replace with your public key
email: document.getElementById("email-address").value,
amount: document.getElementById("amount").value * 100,
onClose: function () {
alert("Window closed.");
},
callback: function (response) {
let message = "Payment complete! Reference: " + response.reference;
alert(message);
},
});
handler.openIframe();
};
customerDetail.addEventListener("submit", detailHandler);
paymentForm.addEventListener("submit", payWithPaystack, false);