feat: report Mercado Pago's notifications in the account check
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 2m16s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 45s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 2m16s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 45s
Without access to the Mercado Pago panel, "Verificar conta" now also says how many payment notifications arrived and passed the signature in the last 24 hours, how many were refused by it, and the last one received: the PIX payments created in test mode notify the webhook, so this shows whether Mercado Pago reaches the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -310,7 +310,18 @@ def mercadopago_check(user=Depends(operator)):
|
||||
raise HTTPException(409, 'Mercado Pago não está configurado')
|
||||
from ..mercadopago_probe import check
|
||||
audit('mercadopago_check', operator=user)
|
||||
return check(payment.access_token)
|
||||
result = check(payment.access_token)
|
||||
# Whether Mercado Pago's notifications reach this server and pass the
|
||||
# signature: every accepted one is recorded, a refused one is audited.
|
||||
with db.connect() as c:
|
||||
received = c.execute('''SELECT count(*) AS n, max(received_at) AS last FROM dtf_local.payment_events
|
||||
WHERE provider='mercadopago' AND received_at > now()-interval '24 hours' ''').fetchone()
|
||||
last = c.execute('''SELECT received_at,status,outcome FROM dtf_local.payment_events
|
||||
WHERE provider='mercadopago' ORDER BY received_at DESC LIMIT 1''').fetchone()
|
||||
refused = c.execute('''SELECT count(*) AS n FROM dtf_local.security_events
|
||||
WHERE event='payment_webhook_rejected' AND created_at > now()-interval '24 hours' ''').fetchone()
|
||||
result['webhooks'] = {'accepted_24h': received['n'], 'refused_24h': refused['n'], 'last': last}
|
||||
return result
|
||||
|
||||
|
||||
@router.get('/api/operator/tiny/callback')
|
||||
|
||||
Reference in New Issue
Block a user