feat: an order paid on the Site says how: "pago com Pix" or "pago com cartão" on its paid line
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 8m35s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m16s

The board carries paid_with, the method of the quote's approved payment
attempt (the one Tiny is told about). Until now a paid Site order only said
"pago em", so a Tiny refusal (DTF-API-C, #196) could not be traced to Pix
or card from the Kanban.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-01 10:58:31 -03:00
parent b18f6e1312
commit fc9e6d2681
4 changed files with 25 additions and 1 deletions

View File

@@ -142,6 +142,21 @@ def run():
assert [e['provider'] for e in paid] == ['tiny'], paid
print('PASS: exactly one Tiny notification for the order')
# The order's paid line says how it was paid: nothing while no attempt is
# approved, then the approved one (the card attempt above).
def paid_with():
orders = board.call('/operator/board', operator=True)['orders']
return next(o for o in orders if o['id'] == order['id'])['paid_with']
assert paid_with() is None
with db.connect() as c:
c.execute("UPDATE dtf_local.payment_intents SET status='approved' WHERE quote_id=%s AND method='card'", (quote_id,))
try:
assert paid_with() == 'card'
finally:
with db.connect() as c:
c.execute("UPDATE dtf_local.payment_intents SET status='pending' WHERE quote_id=%s AND method='card'", (quote_id,))
print('PASS: the board says the order was paid with the approved attempt, card')
# A payment that was never reviewed, and one for something that is not a quote.
deliver({'event_id': 'nonsense-' + uuid4().hex, 'reference': 'not-a-uuid',
'status': 'approved', 'amount_cents': 100})