Payment Callback
Thin wrapper: release the payment dedup key on ANY processing failure.
_payment_callback_impl sets request.state.payment_dedup_key right
after it wins the Redis SET NX. If the impl raises before its session
commits (FX miss 503, currency mismatch 400, tx-not-found 404 race, DB
outage, …), the key must be deleted — otherwise the provider’s retry
gets {"duplicate": true} for 24h while the deposit stays PENDING and
cashier-source txs can’t be approved manually (DEP-1, money review
2026-06-09). Releasing is always safe: the FOR UPDATE +
status == "APPROVED" check inside is the authoritative double-credit
guard; the Redis key is load-shedding only. Mirrors the release pattern
in routes/payouts.py (E6).
The key is RETAINED on success and on the already-approved short-circuit — both return normally, so no release happens here.
Response
Successful Response