Skip to content

Register capture notification moves order out of Payment Review (#35382) - #41165

Open
lbajsarowicz wants to merge 4 commits into
magento:2.4-developfrom
lbajsarowicz:fix/35382-payment-review-state
Open

Register capture notification moves order out of Payment Review (#35382)#41165
lbajsarowicz wants to merge 4 commits into
magento:2.4-developfrom
lbajsarowicz:fix/35382-payment-review-state

Conversation

@lbajsarowicz

Copy link
Copy Markdown
Contributor

Description

An order left in the Payment Review state never returned to Processing when a capture notification arrived, so orders held for payment review stayed stuck even after the payment was captured.

Magento\Sales\Model\Order\Payment\State\RegisterCaptureNotificationCommand::execute() promotes an order to STATE_PROCESSING only when the current state is empty, STATE_NEW or STATE_PENDING_PAYMENT. STATE_PAYMENT_REVIEW was not in that list, so the capture notification updated the payment but left the order state untouched.

This adds STATE_PAYMENT_REVIEW to that condition.

This does not weaken payment review. The getIsTransactionPending() and getIsFraudDetected() checks further down the same method run after the promotion and set the state back to STATE_PAYMENT_REVIEW (with STATUS_FRAUD in the fraud case). So a payment that is still pending at the gateway, or flagged as fraudulent, cannot be promoted — only a clean capture notification results in Processing.

This PR continues #35383 by @itmsenior, rebased onto current 2.4-develop, with the integration coverage that was missing. The original commits and authorship are preserved; @engcom-Charlie's static-test fix from that PR is included as well.

Related Pull Requests

Continues #35383

Fixed Issues

Fixes #35382

Manual testing scenarios

  1. Configure a payment method that places orders into Payment Review (for example PayPal with a pending/under-review result), or set an existing order's state to payment_review.
  2. Trigger the capture notification for that order, e.g. via the gateway IPN, or by calling Magento\Sales\Model\Order\Payment::registerCaptureNotification() with the amount due.
  3. Before: the order remains in Payment Review.
    After: the order moves to Processing with the configured default status for that state.
  4. Repeat with the payment flagged as fraudulent (setIsFraudDetected(true)) or still pending (setIsTransactionPending(true)) and confirm the order stays in Payment Review in both cases.

Questions or comments

Gates run locally on 2.4-develop:

  • Unit: pass.
  • Integration: Magento/Sales/ shows the same 1 error and 4 failures on this branch as on a clean 2.4-develop checkout (all pre-existing: three abstract-class warnings, GridTest::testRefreshBySchedule timing, and unrelated cases). The new test passes.
  • PHPCS Magento2: 0 errors. One pre-existing warning on the @deprecated tag of setOrderStateAndStatus(), untouched by this change.
  • PHPStan level 1: no errors.
  • Negative check on the new test: red without the fix (order stays payment_review), green with it.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

itmsenior and others added 3 commits August 30, 2026 03:07
…gento#35382)

Covers the RegisterCaptureNotificationCommand fix that promotes an order
stuck in Payment Review to Processing once a capture notification arrives.
No such test existed; this closes that gap using the real
Payment::registerCaptureNotification() entry point against a placed order.
@m2-assistant

m2-assistant Bot commented Aug 30, 2026

Copy link
Copy Markdown

Hi @lbajsarowicz. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run all tests

The upstream Static Tests build fails on PHPCS warnings in any file the PR
touches, and setOrderStateAndStatus() carried a @deprecated without the
required @see.
@lbajsarowicz

Copy link
Copy Markdown
Contributor Author

@magento run Static Tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Order state stuck in 'Payment_review' after IPN update from PayPal

3 participants