Skip to content

Don't add notices during REST requests#843

Merged
agibson-godaddy merged 1 commit into
release/6.2.2from
mwc-19933
Jun 15, 2026
Merged

Don't add notices during REST requests#843
agibson-godaddy merged 1 commit into
release/6.2.2from
mwc-19933

Conversation

@agibson-godaddy

@agibson-godaddy agibson-godaddy commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

MWC-19933

Summary

On Block Checkout, when an SV-framework gateway transaction fails, mark_order_as_failed() and add_debug_message() push the error into the WC session via wc_add_notice(). The Store API never renders or clears those notices, so CartController::validate_cart() sweeps them on the next request and throws a 409 woocommerce_rest_cart_item_error — blocking any retry, even with a valid card. This PR gates both wc_add_notice() calls on ! SV_WC_Helper::is_rest_api_request(); the message is already returned in the process_payment() result and surfaced via RouteException, so the session notice is redundant in REST.

QA steps

  1. Update Bambora to use this version of the framework via composer.
  2. Save this card number to your account: 4123456789010343
  3. Attempt to purchase an item using that saved card. It will fail.
  4. After getting the error message, try again, this time entering in a new card that's valid.
    • Order completes successfully without errors

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents WooCommerce session notices from being added during Store API / REST requests, avoiding a scenario where checkout failures leave persistent notices in the session that later get surfaced by cart validation as a woocommerce_rest_cart_item_error (409), blocking subsequent payment retries in Block Checkout.

Changes:

  • Gate the wc_add_notice() call in mark_order_as_failed() behind ! SV_WC_Helper::is_rest_api_request().
  • Prevent add_debug_message() from adding WooCommerce notices during REST requests (while still allowing logging earlier in the method).
  • Add a changelog entry describing the Block Checkout retry fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
woocommerce/payment-gateway/class-sv-wc-payment-gateway.php Skips adding session-backed notices during REST/Store API requests in failure/debug paths to prevent notice leakage into subsequent cart validation.
woocommerce/changelog.txt Documents the fix in the upcoming release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread woocommerce/payment-gateway/class-sv-wc-payment-gateway.php
Comment thread woocommerce/payment-gateway/class-sv-wc-payment-gateway.php
@agibson-godaddy agibson-godaddy merged commit b0c626f into release/6.2.2 Jun 15, 2026
6 checks passed
@agibson-godaddy agibson-godaddy deleted the mwc-19933 branch June 15, 2026 14:16
@agibson-godaddy agibson-godaddy mentioned this pull request Jun 15, 2026
2 tasks
agibson-godaddy added a commit that referenced this pull request Jun 15, 2026
* Version 6.2.2

* Don't add notices during REST requests (#843)

* Set release date

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ashley Gibson <[email protected]>
Co-authored-by: Ashley Gibson <[email protected]>
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.

2 participants