feat: an approved payment becomes the order by asking Mercado Pago, not only by its notice
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 3m14s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 55s
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 3m14s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 55s
Production approved a test card while every notification was refused by signature, and the order never appeared. payments.reconcile() asks the provider about the payments of open quotes and applies its answer through the same path as the webhook: the amount must match the reviewed quote, and the event id (payment id and status) makes a notice and a lookup one delivery, applied once. The payment page's polling checks an approved card at once; the worker checks every minute for the rest, such as a PIX paid after the page was closed. The webhook stays; it is no longer the only way in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@ if os.environ.get('TINY_ADAPTER') == 'tiny':
|
||||
adapters['tiny'] = TinyOrders()
|
||||
last_tick = 0.0
|
||||
last_cleanup = 0.0
|
||||
last_reconcile = 0.0
|
||||
last_tiny_keepalive = 0.0
|
||||
storage = LocalS3Storage()
|
||||
scan_thread = None
|
||||
@@ -75,6 +76,17 @@ def tiny_keepalive():
|
||||
except Exception:
|
||||
logging.exception('Tiny connection refresh failed')
|
||||
|
||||
def reconcile_payments():
|
||||
"""Every minute: the payments of open quotes, asked of the provider, so an
|
||||
approval becomes the order even when its notification never arrives."""
|
||||
global last_reconcile
|
||||
if time.monotonic()-last_reconcile < 60:
|
||||
return
|
||||
last_reconcile = time.monotonic()
|
||||
from . import payments
|
||||
from .runtime import payment
|
||||
payments.reconcile(connect, payment)
|
||||
|
||||
def loop():
|
||||
global last_cleanup
|
||||
while True:
|
||||
@@ -84,6 +96,7 @@ def loop():
|
||||
cleanup()
|
||||
last_cleanup = time.monotonic()
|
||||
tiny_keepalive()
|
||||
reconcile_payments()
|
||||
except Exception:
|
||||
logging.exception('Local worker tick failed')
|
||||
time.sleep(1)
|
||||
|
||||
Reference in New Issue
Block a user