feat(checkout): troca CPF por e-mail do pagador (PIX sem CPF confirmado no Orders API)
build-image / build-push (push) Successful in 6m39s

This commit is contained in:
jfeng committed 2026-10-22 00:15:31 -03:00
1 parent 8fab1e2ab6
commit 9748c8e9e0
3 files changed
+14 -17

No files matched your search

+6 -15
View File
@@ -505,7 +505,7 @@
<section id="view-payer" class="card hidden" aria-labelledby="payerTitle">
<div class="pay-head">
<h2 id="payerTitle">Seus dados</h2>
<p>Para emissão do PIX, informe nome e CPF</p>
<p>Para emissão do PIX, informe seu nome e e-mail</p>
</div>
<label class="field">
@@ -514,8 +514,8 @@
</label>
<label class="field">
<span>CPF</span>
<input id="payerCpf" type="text" inputmode="numeric" maxlength="14" placeholder="000.000.000-00">
<span>E-mail</span>
<input id="payerEmail" type="email" autocomplete="email" inputmode="email" maxlength="120" placeholder="[email protected]">
</label>
<div class="row">
@@ -624,14 +624,6 @@
return mpDevice || window.MP_DEVICE_SESSION_ID || null;
}
function maskCpf(v) {
const d = v.replace(/\D/g, '').slice(0, 11);
return d
.replace(/^(\d{3})(\d)/, '$1.$2')
.replace(/^(\d{3})\.(\d{3})(\d)/, '$1.$2.$3')
.replace(/\.(\d{3})(\d{1,2})$/, '.$1-$2');
}
function toast(msg) {
const t = $('toast');
t.textContent = msg;
@@ -699,14 +691,14 @@
async function checkout(planId) {
try {
const payerName = $('payerName').value.trim();
const payerCpf = $('payerCpf').value.trim();
const payerEmail = $('payerEmail').value.trim();
if (payerName.length < 3) { toast('Informe seu nome completo'); show('payer'); return; }
if (payerCpf.replace(/\D/g, '').length !== 11) { toast('Informe um CPF com 11 dígitos'); show('payer'); return; }
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(payerEmail)) { toast('Informe um e-mail válido'); show('payer'); return; }
const res = await fetch('/api/checkout', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ planId, mac, payerName, payerCpf, deviceId: deviceId() }),
body: JSON.stringify({ planId, mac, payerName, payerEmail, deviceId: deviceId() }),
});
const data = await res.json();
if (data.error) throw new Error(data.error);
@@ -768,7 +760,6 @@
$('backBtn2').addEventListener('click', (e) => { e.preventDefault(); show('plans'); });
$('payerBack').addEventListener('click', () => show('plans'));
$('payerNext').addEventListener('click', () => checkout(selectedPlanId));
$('payerCpf').addEventListener('input', (e) => { e.target.value = maskCpf(e.target.value); });
// ===== Login no hotspot (voucher) =====
const HS_LOGIN = 'http://10.10.10.1/login';