Only auto-capture an approved authorize in ConfirmPaymentAction - #58
Merged
Conversation
The auto-capture gate checked only the operation type, so the callback for a rejected authorize (a declined card is routine in the payment window) or a still-pending one fell through to the amount check, found an authorized amount of 0 and threw a LogicException. That 500s the notify endpoint and has Quickpay retry a callback that can never succeed. A not-approved authorize is now simply nothing to confirm: the callback completes quietly (still persisting the balance) and no capture is issued.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #58 +/- ##
=========================================
Coverage 97.43% 97.43%
Complexity 126 126
=========================================
Files 14 14
Lines 351 351
=========================================
Hits 342 342
Misses 9 9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Aug 10, 2026
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.
Fixes robustness finding R1 of #57.
Problem
ConfirmPaymentActiongated its auto-capture onOperationType::Authorize === $latestOperation->type()— the operation type alone. A rejected authorize (declined card — a routine event in the payment window, and Quickpay sends a callback for it) and a still-pending authorize both have that type, so they fell through to the amount check, whereOperations::authorizedAmount()returns 0, the comparison failed, and the action threwLogicException.Thrown from the notify path, that 500s the endpoint — and Quickpay then retries a callback that can never succeed.
Fix
Gate on
Operations::isApprovedOfType($latestOperation, OperationType::Authorize): a not-approved authorize is nothing to confirm, so the callback completes quietly (the balance is still persisted). The amount-mismatch throw for an approved authorize is kept — that is a genuine anomaly worth surfacing.Tests
ConfirmPaymentActionTest: rejected authorize → no capture, no throw; pending authorize → no capture, no throw.NotifyActionTest: full callback flow for a declined payment withauto_captureon completes without error.ApiTestTrait::operation()now supportspending/null status-code fixtures — the shape every asynchronous operation has until Quickpay finishes it, previously absent from the whole suite.