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.
This commit is contained in:
Danae Millan 2021-10-09 11:46:35 -03:00 committed by GitHub
parent ad50a0e7d2
commit 494df12859
1 changed files with 2 additions and 3 deletions

View File

@ -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' );