Add authentication on payement

This commit is contained in:
2025-12-09 16:20:42 +01:00
parent 6c14c41bbd
commit 64e64373ce
3 changed files with 5 additions and 42 deletions

View File

@@ -100,15 +100,17 @@
btnPay.addEventListener("click", async() => {
let token = document.getElementById("token-input").value;
let dataToken = {
token: token
};
let creds = JSON.parse(localStorage.getItem("creds"));
await fetch("/payment", {
method: "POST",
headers: {
"Content-Type": "application/json"
"Content-Type": "application/json",
"Authorization": `Basic ${creds.username}:${creds.password}`
},
body: JSON.stringify(dataToken)
})

View File

@@ -1,40 +0,0 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MASI 3DSecure</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header, footer {
background: #f4f4f4;
padding: 15px;
text-align: center;
}
main {
padding: 20px;
}
</style>
</head>
<body>
<main>
</main>
<script>
let btn = document.getElementById("btn-back");
console.log("Clicked");
btn.addEventListener("click", () => {
console.log("Clicked");
window.location.href = "/";
});
</script>
</body>
</html>

View File

@@ -41,6 +41,7 @@ public class RequestHandler implements IRequestHandler {
}
}
@OnlyAuthorizedClients
@AllowedVerb(name = "POST")
public void handlePayment(HttpExchange exchange) {
Logger.displayReceived("/payment request");