From 494df1285920a4a2c24debae549323356b82179f Mon Sep 17 00:00:00 2001 From: Danae Millan <41606954+a-danae@users.noreply.github.com> Date: Sat, 9 Oct 2021 11:46:35 -0300 Subject: [PATCH] Display the notices registered by the payment gateway's process_payment() method (https://github.com/woocommerce/woocommerce-blocks/pull/4871) We were displaying a generic error and clearing the notices before. Now we convert them to exceptions so they're actually displayed. --- plugins/woocommerce-blocks/src/Payments/Api.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce-blocks/src/Payments/Api.php b/plugins/woocommerce-blocks/src/Payments/Api.php index 348d84760b4..ae312f853ab 100644 --- a/plugins/woocommerce-blocks/src/Payments/Api.php +++ b/plugins/woocommerce-blocks/src/Payments/Api.php @@ -164,9 +164,8 @@ class Api { // Restore $_POST data. $_POST = $post_data; - // If `process_payment` added notices, clear them. Notices are not displayed from the API -- payment should fail, - // and a generic notice will be shown instead if payment failed. - wc_clear_notices(); + // Display the notices added by `process_payment` and abort. + NoticeHandler::convert_notices_to_exceptions( 'woocommerce_rest_payment_error' ); // Handle result. $result->set_status( isset( $gateway_result['result'] ) && 'success' === $gateway_result['result'] ? 'success' : 'failure' );