From 57b8fe8a84d6b88e8fdc5566d8515fbd626d42f6 Mon Sep 17 00:00:00 2001 From: Francesco Date: Fri, 5 Apr 2024 11:44:09 +0200 Subject: [PATCH] refactor: `*_checkout_process_payment_error` to return 400 error code (#45979) Co-authored-by: github-actions --- plugins/woocommerce/changelog/45979-frosso-patch-1 | 4 ++++ plugins/woocommerce/src/StoreApi/Utilities/CheckoutTrait.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/45979-frosso-patch-1 diff --git a/plugins/woocommerce/changelog/45979-frosso-patch-1 b/plugins/woocommerce/changelog/45979-frosso-patch-1 new file mode 100644 index 00000000000..a85211a9220 --- /dev/null +++ b/plugins/woocommerce/changelog/45979-frosso-patch-1 @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak + +refactor: `woocommerce_rest_checkout_process_payment_error` returns a `400` response code, instead of `402`. \ No newline at end of file diff --git a/plugins/woocommerce/src/StoreApi/Utilities/CheckoutTrait.php b/plugins/woocommerce/src/StoreApi/Utilities/CheckoutTrait.php index 865ee511f8b..d811207d54b 100644 --- a/plugins/woocommerce/src/StoreApi/Utilities/CheckoutTrait.php +++ b/plugins/woocommerce/src/StoreApi/Utilities/CheckoutTrait.php @@ -85,7 +85,7 @@ trait CheckoutTrait { throw new RouteException( 'woocommerce_rest_checkout_invalid_payment_result', __( 'Invalid payment result received from payment method.', 'woocommerce' ), 500 ); } } catch ( \Exception $e ) { - throw new RouteException( 'woocommerce_rest_checkout_process_payment_error', $e->getMessage(), 402 ); + throw new RouteException( 'woocommerce_rest_checkout_process_payment_error', esc_html( $e->getMessage() ), 400 ); } }