feat(checkout): troca CPF por e-mail do pagador (PIX sem CPF confirmado no Orders API)
build-image / build-push (push) Successful in 6m39s
build-image / build-push (push) Successful in 6m39s
This commit is contained in:
1 parent
8fab1e2ab6
commit
9748c8e9e0
3 files changed
+14
-17
No files matched your search
@@ -51,9 +51,13 @@ app.get('/api/plans', (req, res) => {
|
||||
|
||||
app.post('/api/checkout', async (req, res) => {
|
||||
try {
|
||||
const { planId, mac, payerName, payerCpf, deviceId } = req.body || {};
|
||||
const { planId, mac, payerName, payerEmail, payerCpf, deviceId } = req.body || {};
|
||||
const plan = getDb().plans.find((p) => p.id === planId && p.active);
|
||||
if (!plan) return res.status(400).json({ error: 'plano invalido' });
|
||||
const email = String(payerEmail || '').trim();
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) {
|
||||
return res.status(400).json({ error: 'email invalido' });
|
||||
}
|
||||
if (payerCpf && !validCpf(payerCpf)) return res.status(400).json({ error: 'CPF invalido' });
|
||||
|
||||
// historico do comprador (primeira compra / ultima compra)
|
||||
@@ -80,6 +84,7 @@ app.post('/api/checkout', async (req, res) => {
|
||||
planId: plan.id,
|
||||
planName: plan.name,
|
||||
payerName,
|
||||
payerEmail: email,
|
||||
payerCpf,
|
||||
firstPurchase,
|
||||
registrationDate,
|
||||
|
||||
Reference in new issue
Block a user