diff --git a/changelog.txt b/changelog.txt index d56beec2bd..d988474573 100644 --- a/changelog.txt +++ b/changelog.txt @@ -18,6 +18,7 @@ * Fix - Don't allow WP-Cron jobs to detach payment methods on staging sites * Update - Add minimum transaction amounts for BRL, INR, NZD, THB, CZK, HUF, AED, MYR, PLN, RON * Dev - Add additional context data to the OAuth connect flow verbose debug logging mode +* Fix - Make token detachment checks use shared logic for detaching payment methods = 10.1.0 - 2025-11-11 = * Dev - Remove unused `shouldShowPaymentRequestButton` parameter and calculations from backend diff --git a/includes/payment-tokens/class-wc-stripe-payment-tokens.php b/includes/payment-tokens/class-wc-stripe-payment-tokens.php index f9134d5e9f..09042bde67 100644 --- a/includes/payment-tokens/class-wc-stripe-payment-tokens.php +++ b/includes/payment-tokens/class-wc-stripe-payment-tokens.php @@ -480,18 +480,8 @@ public function woocommerce_payment_token_deleted( $token_id, $token ) { return; } - /** - * 1. Check if it's live mode. - * 2. Check if it's admin. - * 3. Check if it's not production environment. - * When all conditions are met, we don't want to delete the payment method from Stripe. - * This is to avoid detaching the payment method from the live stripe account on non production environments. - */ - if ( - WC_Stripe_Mode::is_live() && - is_admin() && - 'production' !== wp_get_environment_type() - ) { + // Check if we should detach the payment method from the customer. + if ( ! WC_Stripe_API::should_detach_payment_method_from_customer() ) { return; } diff --git a/readme.txt b/readme.txt index 566b62af33..7b03b81188 100644 --- a/readme.txt +++ b/readme.txt @@ -128,5 +128,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o * Fix - Don't allow WP-Cron jobs to detach payment methods on staging sites * Update - Add minimum transaction amounts for BRL, INR, NZD, THB, CZK, HUF, AED, MYR, PLN, RON * Dev - Add additional context data to the OAuth connect flow verbose debug logging mode +* Fix - Make token detachment checks use shared logic for detaching payment methods [See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).