Skip to content

Commit c778297

Browse files
authored
Fix/632 show generic error to customers when invalid keys (#4536)
* Update Invalid API key error message during checkout
1 parent 812becb commit c778297

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Fix - 3DS authentication modal not shown when using Google Pay
1717
* Update - Improve Stripe API connector logging to include request/response context
1818
* Fix - Require credit cards to be enabled before Apple Pay and Google Pay can be enabled in PMC
19+
* Tweak - Update checkout error message for invalid API key to be more generic and user-friendly
1920

2021
= 9.7.1 - 2025-07-28 =
2122
* Add - Add state mapping for Lithuania in express checkout

includes/payment-methods/class-wc-stripe-upe-payment-gateway.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,13 @@ private function handle_process_payment_error( WC_Stripe_Exception $e, $order )
12831283
$e->getLocalizedMessage()
12841284
);
12851285

1286+
// If the error message is 'Invalid API Key...', we want to show a more generic error message,
1287+
// as the user won't be able to do anything about it.
1288+
// The log and the order note will still show the full error message for debugging purposes.
1289+
if ( 0 === strpos( $e->getLocalizedMessage(), 'Invalid API Key' ) ) {
1290+
$error_message = __( "We're not able to process this payment. This may be an error on our side. Please contact us if you need any help placing your order.", 'woocommerce-gateway-stripe' );
1291+
}
1292+
12861293
wc_add_notice( $error_message, 'error' );
12871294

12881295
WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() );

readme.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
125125
* Fix - 3DS authentication modal not shown when using Google Pay
126126
* Update - Improve Stripe API connector logging to include request/response context
127127
* Fix - Require credit cards to be enabled before Apple Pay and Google Pay can be enabled in PMC
128+
* Tweak - Update checkout error message for invalid API key to be more generic and user-friendly
129+
128130

129131
[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

0 commit comments

Comments
 (0)