Skip to content

Commit a8279a0

Browse files
annemirasoldaledupreez
authored andcommitted
Add logging for when we receive a 401 (#4337)
Co-authored-by: daledupreez <[email protected]>
1 parent 965a67a commit a8279a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

includes/class-wc-stripe-api.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public static function request( $request, $api = 'charges', $method = 'POST', $w
247247
public static function retrieve( $api ) {
248248
// If we have an option flag indicating that the secret key is not valid, we don't attempt the API call and we return an error.
249249
$invalid_api_keys_option_key = WC_Stripe_Mode::is_test() ? self::TEST_MODE_INVALID_API_KEYS_OPTION_KEY : self::LIVE_MODE_INVALID_API_KEYS_OPTION_KEY;
250-
$invalid_api_keys_detected = get_option( $invalid_api_keys_option_key );
250+
$invalid_api_keys_detected = get_option( $invalid_api_keys_option_key );
251251
if ( $invalid_api_keys_detected ) {
252252
return null; // The UI expects this empty response in case of invalid API keys.
253253
}
@@ -272,6 +272,9 @@ public static function retrieve( $api ) {
272272
// We delete the transient for the account data to trigger the not-connected UI in the admin dashboard.
273273
delete_transient( WC_Stripe_Mode::is_test() ? WC_Stripe_Account::TEST_ACCOUNT_OPTION : WC_Stripe_Account::LIVE_ACCOUNT_OPTION );
274274

275+
// Stripe redacts API keys in the response.
276+
WC_Stripe_Logger::log( "Error: GET {$api} returned a 401 " . print_r( $response, true ) );
277+
275278
return null; // The UI expects this empty response in case of invalid API keys.
276279
}
277280

0 commit comments

Comments
 (0)