Repository navigation
Refuse to queue a capture/refund/cancel while one is still in flight - #80
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #80 +/- ##
============================================
+ Coverage 98.44% 98.52% +0.07%
- Complexity 208 215 +7
============================================
Files 19 20 +1
Lines 516 542 +26
============================================
+ Hits 508 534 +26
Misses 8 8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
loevgaard
force-pushed
the
fix/rejected-auto-capture
branch
from
August 17, 2026 09:39
0d477cd to
5180cfb
Compare
loevgaard
force-pushed
the
fix/pending-operation-guard
branch
from
August 17, 2026 09:39
62d3b7c to
a9ab040
Compare
loevgaard
force-pushed
the
fix/rejected-auto-capture
branch
from
August 17, 2026 09:46
5180cfb to
fc4976d
Compare
loevgaard
force-pushed
the
fix/pending-operation-guard
branch
from
August 17, 2026 09:46
a9ab040 to
415053a
Compare
This was referenced Aug 17, 2026
loevgaard
force-pushed
the
fix/pending-operation-guard
branch
from
August 17, 2026 11:06
415053a to
bcf698e
Compare
Operations run asynchronously by default: Quickpay queues them and answers before the acquirer has, and until the callback (or a Sync/GetStatus) reports the outcome the payment's balance and state are the pre-operation ones. A second operation issued meanwhile races the first — a Capture retried after a timeout takes the money twice, a Refund refunds the stale balance again, a Cancel races a capture. AuthorizeAction already refused to act on a pending capture; the money operations did not look. CaptureAction (plain-link path), RefundAction and CancelAction now fetch the payment first — Cancel and an explicit-amount Refund did not before, one GET each — and OperationPendingException::assertNoneInFlight() throws while a capture, refund or cancel is pending, before anything is sent, so a capture_amount/refund_amount instruction survives. The exception is a Payum RuntimeException carrying the payment id and the pending operation, the sibling of OperationRejectedException. The `synchronized` option has no in-flight window and is unaffected. Refs #71 (R3).
loevgaard
force-pushed
the
fix/pending-operation-guard
branch
from
August 17, 2026 11:07
bcf698e to
fecbcb5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements R3 of #71 — flagged there as a policy call, so this is the proposal in mergeable form; say no and it goes away. Stacked on #73 (which is stacked on #72); retarget to
2.xbefore merging its base.What
Operations run asynchronously by default: Quickpay queues them and answers before the acquirer has, and until the callback (or a
Sync/GetStatus) reports the outcome the payment'sbalance/stateare the pre-operation ones. A second operation issued meanwhile races the first — aCaptureretried after a timeout takes the money twice, aRefundrefunds the stale balance again, aCancelraces a capture.AuthorizeActionalready refuses to act on a pending capture; the money operations did not look.Now
CaptureAction(plain-link path),RefundActionandCancelActionfetch the payment first and, while a capture, refund or cancel is pending, throwException\OperationPendingException(a PayumRuntimeExceptionwithgetPaymentId()and the pendinggetOperation()— the sibling of #72'sOperationRejectedException) before anything is sent; acapture_amount/refund_amountinstruction survives. Rule: one money operation at a time on a payment.synchronizedhas no in-flight window and is unaffected.The trade-offs (why it's a policy call)
GETthey did not make before (Capture and default Refund already fetched). The README/UPGRADE promise "an explicitrefund_amountskips the fetch entirely" is reversed; thebalancethe fetch brings is written into the details like everywhere else.The zero-cost alternative — guard only where the payment is already in hand (Capture, default-path Refund) — is inconsistent to document ("a pending refund is refused… unless you passed
refund_amount"), so I went for the consistent rule and put the cost on the table.Tests / docs
Guard tests for all three actions (pending capture / refund / cancel), the existing Cancel and explicit-Refund tests updated for fetch-first; README (partial operations),
docs/UPGRADE-2.0.md(new section), CLAUDE.md.composer alland the dependency analyser green (335 tests).