fix(payments): a console refund that its own notification beat is not a repeat
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 22s
CI / ui (pull_request) Successful in 1m16s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 1s
CI / deploy (pull_request) Successful in 2m28s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 22s
CI / ui (pull_request) Successful in 1m16s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 1s
CI / deploy (pull_request) Successful in 2m28s
Refunding from /_gm reported "Already refunded" for a refund that had just succeeded, which reads as "you clicked twice". The two recording paths race. YooKassa fires refund.succeeded the moment POST /v3/refunds returns, so the notification handler often writes the reversal before the console's own write lands. Both name the same refund id, so the ledger's idempotency index rejects the second — which is the mechanism working exactly as intended: on the contour the money moved once, one refund row was written, the balance is right and no abuse flag was raised. Only the message was wrong about why. The console now reports success on that path, and the notification's log line no longer claims the refund was "issued outside the console" when it may well have come from it. Covered by an integration test that lands the notification first and then refunds from the console, asserting the operator is told it succeeded and that exactly one refund row exists.
This commit is contained in:
@@ -333,6 +333,11 @@ nothing twice. The engine is **full-refund-only** by design (it revokes exactly
|
||||
and rejects any other amount), so a **partial** refund is recorded as nothing at all and logged
|
||||
loudly for an operator: there is no non-arbitrary way to decide how many chips a part-refund costs.
|
||||
|
||||
The two recording paths race, benignly: YooKassa fires `refund.succeeded` the moment the refund is
|
||||
created, so the notification often writes the reversal before the console's own write lands. Both
|
||||
name the same refund id, so the second is caught by the idempotency index and nothing is revoked
|
||||
twice; the console reports the refund as successful rather than as a repeated click.
|
||||
|
||||
VK refunds are still handled by support and Telegram Stars refunds issued with `refundStarPayment`,
|
||||
both recorded by hand afterwards. All of them converge on one engine —
|
||||
the `Refund` method (`internal/payments`): it matches the paid order, appends a **refund** ledger
|
||||
|
||||
Reference in New Issue
Block a user