fix: a payment started in time is the order when approved late, a second payment is listed for a refund, a coupon's limit is checked at payment
All checks were successful
Build and deploy / Validate source (push) Successful in 13s
Build and deploy / Integration suite on a real stack (push) Successful in 8m10s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m17s
All checks were successful
Build and deploy / Validate source (push) Successful in 13s
Build and deploy / Integration suite on a real stack (push) Successful in 8m10s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m17s
- A PIX paid in its last minutes after the quote's 24 h, or a card approved
after Mercado Pago's review, was refused ("quote expired before payment"):
money in, no order. A payment whose attempt began while the quote was
valid is now honoured; a card in review keeps its quote, files and the
reconciliation for 72 h.
- A second approved payment of the same cart (a PIX and a card) was taken
for a re-sent approval and logged only. It is now listed on the Kanban as
attention, with the order, for a refund.
- A coupon's uses were counted only when the cart was made, so carts made
before it ran out, or before it was paused or ended, still paid with the
discount. The intent checks it again and asks for a new cart without it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,21 @@ def run():
|
||||
assert quote_id in {q['id'] for q in page['quotes']}
|
||||
print('PASS: a live payment attempt keeps an approved quote and its files')
|
||||
|
||||
# A card in review (Mercado Pago "em análise") tried 30 h ago is still
|
||||
# live: it may be approved days later (payments.CARD_REVIEW_HOURS).
|
||||
with db.connect() as c:
|
||||
c.execute('''UPDATE dtf_local.payment_intents SET status='expired', created_at=now()-interval '31 hours'
|
||||
WHERE quote_id=%s''', (quote_id,))
|
||||
c.execute('''INSERT INTO dtf_local.payment_intents(id,quote_id,provider,provider_payment_id,method,status,
|
||||
amount_cents,response,created_at) VALUES(%s,%s,'fake',%s,'card','pending',%s,'{}',now()-interval '30 hours')''',
|
||||
(uuid4(), quote_id, 'unpaid-card-' + uuid4().hex, approved['total_cents']))
|
||||
c.execute("UPDATE dtf_local.quotes SET approved_at=now()-interval '31 hours' WHERE id=%s", (quote_id,))
|
||||
with db.connect() as c:
|
||||
unpaid.expire(c, ORIGIN)
|
||||
assert c.execute('SELECT expired_at FROM dtf_local.quotes WHERE id=%s',
|
||||
(quote_id,)).fetchone()['expired_at'] is None
|
||||
print('PASS: a card in review keeps its quote and files past the 24 h')
|
||||
|
||||
# The attempt is final now: the quote expires, its files are freed and the
|
||||
# customer is told once.
|
||||
with db.connect() as c:
|
||||
|
||||
Reference in New Issue
Block a user