Changeset 3422300
- Timestamp:
- 12/17/2025 08:48:50 PM (2 months ago)
- Location:
- woocommerce-gateway-gocardless
- Files:
-
- 8 edited
- 1 copied
-
tags/2.9.9 (copied) (copied from woocommerce-gateway-gocardless/trunk)
-
tags/2.9.9/changelog.txt (modified) (1 diff)
-
tags/2.9.9/includes/class-wc-gocardless-gateway-addons.php (modified) (1 diff)
-
tags/2.9.9/readme.txt (modified) (2 diffs)
-
tags/2.9.9/woocommerce-gateway-gocardless.php (modified) (3 diffs)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/includes/class-wc-gocardless-gateway-addons.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woocommerce-gateway-gocardless.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-gateway-gocardless/tags/2.9.9/changelog.txt
r3375261 r3422300 1 1 *** GoCardless for WooCommerce Changelog *** 2 3 2025-12-17 - version 2.9.9 4 * Fix - Inconsistent subscription status after cancellation. 5 * Dev - Bump WordPress "tested up to" version 6.9. 6 * Dev - Bump WooCommerce "tested up to" version 10.4. 7 * Dev - Bump WooCommerce minimum supported version to 10.2. 2 8 3 9 2025-10-07 - version 2.9.8 -
woocommerce-gateway-gocardless/tags/2.9.9/includes/class-wc-gocardless-gateway-addons.php
r3339885 r3422300 34 34 add_action( 'woocommerce_subscription_pending-cancel_' . $this->id, array( $this, 'maybe_cancel_subscription_payment' ) ); 35 35 add_action( 'woocommerce_subscription_cancelled_' . $this->id, array( $this, 'maybe_cancel_subscription_payment' ) ); 36 37 // Status synchronization for parent orders. 38 add_action( 'woocommerce_subscription_status_updated', array( $this, 'sync_parent_order_status' ), 10, 3 ); 36 39 } 37 40 38 41 if ( class_exists( 'WC_Pre_Orders_Order' ) ) { 39 42 add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_payment_for_released_pre_order' ) ); 43 } 44 } 45 46 /** 47 * Synchronize parent order status when all subscriptions are cancelled. 48 * Also intercepts pending-cancel transitions for subscriptions with unconfirmed payments, 49 * checking the most recent order (parent or renewal) to determine if payment is confirmed. 50 * 51 * @since 2.9.9 52 * @param WC_Subscription $subscription The subscription object. 53 * @param string $new_status The new subscription status. 54 * @param string $old_status The old subscription status. 55 */ 56 public function sync_parent_order_status( $subscription, $new_status, $old_status ) { 57 // Only process GoCardless subscriptions and subscription cancellation triggered by the customer. 58 if ( $this->id !== $subscription->get_payment_method() || ! isset( $_GET['change_subscription_to'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended 59 return; 60 } 61 62 // Only process Some status -> 'pending-cancel' transition. 63 if ( 'pending-cancel' !== $new_status || 'pending-cancel' === $old_status ) { 64 return; 65 } 66 67 /* 68 * Handle transition to pending-cancel status for unconfirmed payments. 69 * This checks the most recent order's payment status (parent or latest renewal) from the 70 * GoCardless API to avoid edge cases with webhook delays. 71 */ 72 73 // Get the most recent order of the subscription. 74 $last_order = is_callable( array( $subscription, 'get_last_order' ) ) 75 ? $subscription->get_last_order( 'all' ) 76 : $subscription->get_parent(); 77 78 // If the last order is not a valid order, return. 79 if ( ! $last_order || ! is_a( $last_order, 'WC_Abstract_Order' ) ) { 80 return; 81 } 82 83 // Get payment status from GoCardless. 84 $payment_id = $this->get_order_resource( $last_order->get_id(), 'payment', 'id' ); 85 $payment_status = ''; 86 87 if ( $payment_id ) { 88 $payment = WC_GoCardless_API::get_payment( $payment_id ); 89 90 if ( is_wp_error( $payment ) || empty( $payment['payments'] ) ) { 91 wc_gocardless()->log( 92 sprintf( 93 '%s - Failed to retrieve payment for order #%s', 94 __METHOD__, 95 $last_order->get_id() 96 ) 97 ); 98 } else { 99 $payment_status = $payment['payments']['status'] ?? ''; 100 } 101 } 102 103 // Payment confirmed statuses that indicate payment has gone through. 104 $confirmed_statuses = array( 'confirmed', 'paid_out' ); 105 106 // If payment is not confirmed, cancel immediately. 107 if ( ! in_array( $payment_status, $confirmed_statuses, true ) ) { 108 wc_gocardless()->log( 109 sprintf( 110 '%s - Cancelling subscription #%s immediately (order #%s has unconfirmed payment status: %s)', 111 __METHOD__, 112 $subscription->get_id(), 113 $last_order->get_id(), 114 $payment_status ? $payment_status : 'none' 115 ) 116 ); 117 $subscription->update_status( 118 'cancelled', 119 __( 'Subscription cancelled immediately as payment not confirmed for the last order.', 'woocommerce-gateway-gocardless' ) 120 ); 40 121 } 41 122 } -
woocommerce-gateway-gocardless/tags/2.9.9/readme.txt
r3375261 r3422300 2 2 Contributors: gocardless, woocommerce, automattic 3 3 Tags: gocardless, woocommerce, direct debit, instant bank pay 4 Tested up to: 6. 85 Stable tag: 2.9. 84 Tested up to: 6.9 5 Stable tag: 2.9.9 6 6 License: GPL-3.0-or-later 7 7 License URI: https://spdx.org/licenses/GPL-3.0-or-later.html … … 140 140 141 141 == Changelog == 142 143 = 2.9.9 - 2025-12-17 = 144 * Fix - Inconsistent subscription status after cancellation. 145 * Dev - Bump WordPress "tested up to" version 6.9. 146 * Dev - Bump WooCommerce "tested up to" version 10.4. 147 * Dev - Bump WooCommerce minimum supported version to 10.2. 142 148 143 149 = 2.9.8 - 2025-10-07 = -
woocommerce-gateway-gocardless/tags/2.9.9/woocommerce-gateway-gocardless.php
r3375261 r3422300 4 4 * Plugin URI: https://www.woocommerce.com/products/gocardless/ 5 5 * Description: Extends both WooCommerce and WooCommerce Subscriptions with the GoCardless Payment Gateway. A GoCardless merchant account is required. 6 * Version: 2.9. 86 * Version: 2.9.9 7 7 * Requires at least: 6.7 8 8 * Requires PHP: 7.4 … … 13 13 * License URI: https://spdx.org/licenses/GPL-3.0-or-later.html 14 14 * Requires Plugins: woocommerce 15 * WC requires at least: 10. 016 * WC tested up to: 10. 215 * WC requires at least: 10.2 16 * WC tested up to: 10.4 17 17 * 18 18 * Copyright: © 2023-2025 WooCommerce … … 39 39 * @var string 40 40 */ 41 public $version = '2.9. 8'; // WRCS: DEFINED_VERSION.41 public $version = '2.9.9'; // WRCS: DEFINED_VERSION. 42 42 43 43 /** -
woocommerce-gateway-gocardless/trunk/changelog.txt
r3375261 r3422300 1 1 *** GoCardless for WooCommerce Changelog *** 2 3 2025-12-17 - version 2.9.9 4 * Fix - Inconsistent subscription status after cancellation. 5 * Dev - Bump WordPress "tested up to" version 6.9. 6 * Dev - Bump WooCommerce "tested up to" version 10.4. 7 * Dev - Bump WooCommerce minimum supported version to 10.2. 2 8 3 9 2025-10-07 - version 2.9.8 -
woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-gateway-addons.php
r3339885 r3422300 34 34 add_action( 'woocommerce_subscription_pending-cancel_' . $this->id, array( $this, 'maybe_cancel_subscription_payment' ) ); 35 35 add_action( 'woocommerce_subscription_cancelled_' . $this->id, array( $this, 'maybe_cancel_subscription_payment' ) ); 36 37 // Status synchronization for parent orders. 38 add_action( 'woocommerce_subscription_status_updated', array( $this, 'sync_parent_order_status' ), 10, 3 ); 36 39 } 37 40 38 41 if ( class_exists( 'WC_Pre_Orders_Order' ) ) { 39 42 add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_payment_for_released_pre_order' ) ); 43 } 44 } 45 46 /** 47 * Synchronize parent order status when all subscriptions are cancelled. 48 * Also intercepts pending-cancel transitions for subscriptions with unconfirmed payments, 49 * checking the most recent order (parent or renewal) to determine if payment is confirmed. 50 * 51 * @since 2.9.9 52 * @param WC_Subscription $subscription The subscription object. 53 * @param string $new_status The new subscription status. 54 * @param string $old_status The old subscription status. 55 */ 56 public function sync_parent_order_status( $subscription, $new_status, $old_status ) { 57 // Only process GoCardless subscriptions and subscription cancellation triggered by the customer. 58 if ( $this->id !== $subscription->get_payment_method() || ! isset( $_GET['change_subscription_to'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended 59 return; 60 } 61 62 // Only process Some status -> 'pending-cancel' transition. 63 if ( 'pending-cancel' !== $new_status || 'pending-cancel' === $old_status ) { 64 return; 65 } 66 67 /* 68 * Handle transition to pending-cancel status for unconfirmed payments. 69 * This checks the most recent order's payment status (parent or latest renewal) from the 70 * GoCardless API to avoid edge cases with webhook delays. 71 */ 72 73 // Get the most recent order of the subscription. 74 $last_order = is_callable( array( $subscription, 'get_last_order' ) ) 75 ? $subscription->get_last_order( 'all' ) 76 : $subscription->get_parent(); 77 78 // If the last order is not a valid order, return. 79 if ( ! $last_order || ! is_a( $last_order, 'WC_Abstract_Order' ) ) { 80 return; 81 } 82 83 // Get payment status from GoCardless. 84 $payment_id = $this->get_order_resource( $last_order->get_id(), 'payment', 'id' ); 85 $payment_status = ''; 86 87 if ( $payment_id ) { 88 $payment = WC_GoCardless_API::get_payment( $payment_id ); 89 90 if ( is_wp_error( $payment ) || empty( $payment['payments'] ) ) { 91 wc_gocardless()->log( 92 sprintf( 93 '%s - Failed to retrieve payment for order #%s', 94 __METHOD__, 95 $last_order->get_id() 96 ) 97 ); 98 } else { 99 $payment_status = $payment['payments']['status'] ?? ''; 100 } 101 } 102 103 // Payment confirmed statuses that indicate payment has gone through. 104 $confirmed_statuses = array( 'confirmed', 'paid_out' ); 105 106 // If payment is not confirmed, cancel immediately. 107 if ( ! in_array( $payment_status, $confirmed_statuses, true ) ) { 108 wc_gocardless()->log( 109 sprintf( 110 '%s - Cancelling subscription #%s immediately (order #%s has unconfirmed payment status: %s)', 111 __METHOD__, 112 $subscription->get_id(), 113 $last_order->get_id(), 114 $payment_status ? $payment_status : 'none' 115 ) 116 ); 117 $subscription->update_status( 118 'cancelled', 119 __( 'Subscription cancelled immediately as payment not confirmed for the last order.', 'woocommerce-gateway-gocardless' ) 120 ); 40 121 } 41 122 } -
woocommerce-gateway-gocardless/trunk/readme.txt
r3375261 r3422300 2 2 Contributors: gocardless, woocommerce, automattic 3 3 Tags: gocardless, woocommerce, direct debit, instant bank pay 4 Tested up to: 6. 85 Stable tag: 2.9. 84 Tested up to: 6.9 5 Stable tag: 2.9.9 6 6 License: GPL-3.0-or-later 7 7 License URI: https://spdx.org/licenses/GPL-3.0-or-later.html … … 140 140 141 141 == Changelog == 142 143 = 2.9.9 - 2025-12-17 = 144 * Fix - Inconsistent subscription status after cancellation. 145 * Dev - Bump WordPress "tested up to" version 6.9. 146 * Dev - Bump WooCommerce "tested up to" version 10.4. 147 * Dev - Bump WooCommerce minimum supported version to 10.2. 142 148 143 149 = 2.9.8 - 2025-10-07 = -
woocommerce-gateway-gocardless/trunk/woocommerce-gateway-gocardless.php
r3375261 r3422300 4 4 * Plugin URI: https://www.woocommerce.com/products/gocardless/ 5 5 * Description: Extends both WooCommerce and WooCommerce Subscriptions with the GoCardless Payment Gateway. A GoCardless merchant account is required. 6 * Version: 2.9. 86 * Version: 2.9.9 7 7 * Requires at least: 6.7 8 8 * Requires PHP: 7.4 … … 13 13 * License URI: https://spdx.org/licenses/GPL-3.0-or-later.html 14 14 * Requires Plugins: woocommerce 15 * WC requires at least: 10. 016 * WC tested up to: 10. 215 * WC requires at least: 10.2 16 * WC tested up to: 10.4 17 17 * 18 18 * Copyright: © 2023-2025 WooCommerce … … 39 39 * @var string 40 40 */ 41 public $version = '2.9. 8'; // WRCS: DEFINED_VERSION.41 public $version = '2.9.9'; // WRCS: DEFINED_VERSION. 42 42 43 43 /**
Note: See TracChangeset
for help on using the changeset viewer.