Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions includes/payment-tokens/class-wc-stripe-payment-tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) {
Comment on lines +483 to +484
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper method should_detach_payment_method_from_customer() includes an additional check for WooCommerce Subscriptions staging mode (is_woocommerce_subscriptions_staging_mode()) that was not present in the original inline logic. This means the behavior will change: payment methods will now also NOT be detached when WooCommerce Subscriptions staging mode is enabled, even if the site is identified as production by wp_get_environment_type(). While this may be intentional for better safety, it represents a behavioral change that should be acknowledged and tested.

Suggested change
// Check if we should detach the payment method from the customer.
if ( ! WC_Stripe_API::should_detach_payment_method_from_customer() ) {
// Only detach payment methods in production environment.
if ( 'production' !== wp_get_environment_type() ) {

Copilot uses AI. Check for mistakes.
return;
}

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Loading