<?php
declare(strict_types=1);
require_once '../../private/db.php';
require_once '../../private/auth.php';
require_login();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>WisePOS E Test</title>
<style>
body{font-family:Arial;background:#111827;color:#fff;padding:30px;}
.form-box{background:#1f2937;padding:25px;border-radius:12px;max-width:500px;}
input{width:100%;padding:12px;margin-bottom:12px;border:none;border-radius:6px;}
button{padding:14px;background:#2563eb;color:#fff;border:none;border-radius:8px;cursor:pointer;width:100%;}
#result{margin-top:20px;background:#0f172a;padding:20px;border-radius:8px;white-space:pre-wrap;}
</style>
</head>
<body>

<h1>WisePOS E Reader Test</h1>

<div class="form-box">

<input type="email" id="customer_email" placeholder="Customer Email">

<input type="text" id="customer_phone" placeholder="Customer Phone">

<input type="number" id="amount" step="0.01" value="1.00" placeholder="Amount">

<button onclick="startPayment()">
Process WisePOS E Payment
</button>

<div id="result"></div>

</div>

<script>

async function startPayment(){

const result = document.getElementById('result');

result.innerHTML = 'Creating Stripe Terminal payment...';

const response = await fetch(
'api/process_wisepos_payment.php',
{
method:'POST',
headers:{
'Content-Type':'application/json'
},
body:JSON.stringify({
customer_email:document.getElementById('customer_email').value,
customer_phone:document.getElementById('customer_phone').value,
amount:document.getElementById('amount').value
})
}
);

const data = await response.json();

result.innerHTML = JSON.stringify(data,null,2);

}

</script>

</body>
</html>
