Plugin Directory

Changeset 3422300


Ignore:
Timestamp:
12/17/2025 08:48:50 PM (2 months ago)
Author:
gocardless
Message:

Update to version 2.9.9 from GitHub

Location:
woocommerce-gateway-gocardless
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • woocommerce-gateway-gocardless/tags/2.9.9/changelog.txt

    r3375261 r3422300  
    11*** GoCardless for WooCommerce Changelog ***
     2
     32025-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.
    28
    392025-10-07 - version 2.9.8
  • woocommerce-gateway-gocardless/tags/2.9.9/includes/class-wc-gocardless-gateway-addons.php

    r3339885 r3422300  
    3434            add_action( 'woocommerce_subscription_pending-cancel_' . $this->id, array( $this, 'maybe_cancel_subscription_payment' ) );
    3535            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 );
    3639        }
    3740
    3841        if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
    3942            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            );
    40121        }
    41122    }
  • woocommerce-gateway-gocardless/tags/2.9.9/readme.txt

    r3375261 r3422300  
    22Contributors: gocardless, woocommerce, automattic
    33Tags:         gocardless, woocommerce, direct debit, instant bank pay
    4 Tested up to: 6.8
    5 Stable tag:   2.9.8
     4Tested up to: 6.9
     5Stable tag:   2.9.9
    66License:      GPL-3.0-or-later
    77License URI:  https://spdx.org/licenses/GPL-3.0-or-later.html
     
    140140
    141141== 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.
    142148
    143149= 2.9.8 - 2025-10-07 =
  • woocommerce-gateway-gocardless/tags/2.9.9/woocommerce-gateway-gocardless.php

    r3375261 r3422300  
    44 * Plugin URI:           https://www.woocommerce.com/products/gocardless/
    55 * Description:          Extends both WooCommerce and WooCommerce Subscriptions with the GoCardless Payment Gateway. A GoCardless merchant account is required.
    6  * Version:              2.9.8
     6 * Version:              2.9.9
    77 * Requires at least:    6.7
    88 * Requires PHP:         7.4
     
    1313 * License URI:          https://spdx.org/licenses/GPL-3.0-or-later.html
    1414 * Requires Plugins:     woocommerce
    15  * WC requires at least: 10.0
    16  * WC tested up to:      10.2
     15 * WC requires at least: 10.2
     16 * WC tested up to:      10.4
    1717 *
    1818 * Copyright: © 2023-2025 WooCommerce
     
    3939     * @var string
    4040     */
    41     public $version = '2.9.8'; // WRCS: DEFINED_VERSION.
     41    public $version = '2.9.9'; // WRCS: DEFINED_VERSION.
    4242
    4343    /**
  • woocommerce-gateway-gocardless/trunk/changelog.txt

    r3375261 r3422300  
    11*** GoCardless for WooCommerce Changelog ***
     2
     32025-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.
    28
    392025-10-07 - version 2.9.8
  • woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-gateway-addons.php

    r3339885 r3422300  
    3434            add_action( 'woocommerce_subscription_pending-cancel_' . $this->id, array( $this, 'maybe_cancel_subscription_payment' ) );
    3535            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 );
    3639        }
    3740
    3841        if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
    3942            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            );
    40121        }
    41122    }
  • woocommerce-gateway-gocardless/trunk/readme.txt

    r3375261 r3422300  
    22Contributors: gocardless, woocommerce, automattic
    33Tags:         gocardless, woocommerce, direct debit, instant bank pay
    4 Tested up to: 6.8
    5 Stable tag:   2.9.8
     4Tested up to: 6.9
     5Stable tag:   2.9.9
    66License:      GPL-3.0-or-later
    77License URI:  https://spdx.org/licenses/GPL-3.0-or-later.html
     
    140140
    141141== 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.
    142148
    143149= 2.9.8 - 2025-10-07 =
  • woocommerce-gateway-gocardless/trunk/woocommerce-gateway-gocardless.php

    r3375261 r3422300  
    44 * Plugin URI:           https://www.woocommerce.com/products/gocardless/
    55 * Description:          Extends both WooCommerce and WooCommerce Subscriptions with the GoCardless Payment Gateway. A GoCardless merchant account is required.
    6  * Version:              2.9.8
     6 * Version:              2.9.9
    77 * Requires at least:    6.7
    88 * Requires PHP:         7.4
     
    1313 * License URI:          https://spdx.org/licenses/GPL-3.0-or-later.html
    1414 * Requires Plugins:     woocommerce
    15  * WC requires at least: 10.0
    16  * WC tested up to:      10.2
     15 * WC requires at least: 10.2
     16 * WC tested up to:      10.4
    1717 *
    1818 * Copyright: © 2023-2025 WooCommerce
     
    3939     * @var string
    4040     */
    41     public $version = '2.9.8'; // WRCS: DEFINED_VERSION.
     41    public $version = '2.9.9'; // WRCS: DEFINED_VERSION.
    4242
    4343    /**
Note: See TracChangeset for help on using the changeset viewer.