Plugin Directory

Changeset 3375261


Ignore:
Timestamp:
10/08/2025 05:45:38 PM (5 months ago)
Author:
gocardless
Message:

Update to version 2.9.8 from GitHub

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

Legend:

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

    r3339885 r3375261  
    11*** GoCardless for WooCommerce Changelog ***
     2
     32025-10-07 - version 2.9.8
     4* Fix - Automatically disconnect the GoCardless account and display a reconnect notice when the token becomes invalid or inactive.
     5* Dev - Bump WooCommerce "tested up to" version 10.2.
     6* Dev - Bump WooCommerce minimum supported version to 10.0.
    27
    382025-08-05 - version 2.9.7
  • woocommerce-gateway-gocardless/tags/2.9.8/includes/class-wc-gocardless-api.php

    r3339885 r3375261  
    175175        }
    176176
    177         $parsed_resp = json_decode( wp_remote_retrieve_body( $resp ), true );
     177        $response_code = wp_remote_retrieve_response_code( $resp );
     178        $parsed_resp   = json_decode( wp_remote_retrieve_body( $resp ), true );
    178179        if ( is_null( $parsed_resp ) ) {
    179180            wc_gocardless()->log( sprintf( '%s - Failed to decode JSON resp %s', __METHOD__, print_r( wp_remote_retrieve_body( $resp ), true ) ) ); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
     
    199200            }
    200201
     202            /*
     203             * Error Handling for 401 unauthorized response code.
     204             *
     205             * If API respond with 401 unauthorized response code, it means:
     206             *
     207             * - `access_token_not_found` (the access token was not recognised); or
     208             * - `access_token_revoked` (the user has revoked your access to their account); or
     209             * - `access_token_not_active` (the access token is inactive for another reason)
     210             *
     211             * We need to disconnect from GoCardless and display a notice to the user to connect again.
     212             */
     213            if ( 401 === $response_code && 'invalid_api_usage' === $parsed_resp['error']['type'] ) {
     214                // Unauthorized response code, disconnect from GoCardless.
     215                wc_gocardless()->log( sprintf( '%s - Unauthorized response code, disconnecting from GoCardless', __METHOD__ ) );
     216                $settings                 = get_option( 'woocommerce_gocardless_settings', array() );
     217                $settings['access_token'] = '';
     218                update_option( 'woocommerce_gocardless_settings', $settings );
     219
     220                // Clear the available scheme transient.
     221                delete_transient( 'wc_gocardless_available_scheme_identifiers' );
     222
     223                wc_gocardless()->log( sprintf( '%s - Disconnected from GoCardless', __METHOD__ ) );
     224
     225                // Add option to display notice to connect GoCardless again.
     226                update_option( 'wc_gocardless_access_token_unauthorized', true );
     227            }
     228
    201229            $new_mandate = null;
    202230            if ( ! empty( $parsed_resp['error']['errors'] ) && is_array( $parsed_resp['error']['errors'] ) ) {
  • woocommerce-gateway-gocardless/tags/2.9.8/includes/class-wc-gocardless-gateway.php

    r3339885 r3375261  
    159159        // Clear the available scheme transient.
    160160        delete_transient( 'wc_gocardless_available_scheme_identifiers' );
     161
     162        // Clear option which displays notice to connect GoCardless.
     163        delete_option( 'wc_gocardless_access_token_unauthorized' );
    161164
    162165        // Delete notice that informs merchant to connect with GoCardless.
  • woocommerce-gateway-gocardless/tags/2.9.8/includes/class-wc-gocardless-order-admin.php

    r3239558 r3375261  
    2626
    2727        add_action( 'admin_notices', array( $this, 'display_connection_notices' ) );
     28        add_action( 'admin_notices', array( $this, 'display_access_token_unauthorized_notice' ) );
    2829
    2930        // GoCardless Connect/Disconnect actions.
     
    577578        return $notice;
    578579    }
     580
     581    /**
     582     * Display notice for access token unauthorized.
     583     *
     584     * @since 2.9.8
     585     */
     586    public function display_access_token_unauthorized_notice() {
     587        // Check if option is set to display notice.
     588        if ( ! get_option( 'wc_gocardless_access_token_unauthorized' ) ) {
     589            return;
     590        }
     591
     592        // Check if access token is there.
     593        $settings = get_option( 'woocommerce_gocardless_settings', array() );
     594        if ( ! empty( $settings['access_token'] ) ) {
     595            // Remove the option to display notice, as we have an access token now (in case it missed to remove while connect to GoCardless).
     596            delete_option( 'wc_gocardless_access_token_unauthorized' );
     597            return;
     598        }
     599        ?>
     600        <div class="notice notice-warning">
     601            <p>
     602            <?php
     603            echo wp_kses(
     604                sprintf(
     605                    /* translators: %s: settings URL */
     606                    __( 'The connection to your <strong>GoCardless</strong> account has been disconnected because the access token is no longer active or valid. Please <a href="%s">connect</a> your GoCardless account to continue accepting payments.', 'woocommerce-gateway-gocardless' ),
     607                    wc_gocardless()->get_setting_url()
     608                ),
     609                array(
     610                    'a'      => array(
     611                        'href' => array(),
     612                    ),
     613                    'strong' => array(),
     614                )
     615            );
     616            ?>
     617            </p>
     618        </div>
     619        <?php
     620    }
    579621}
  • woocommerce-gateway-gocardless/tags/2.9.8/readme.txt

    r3339885 r3375261  
    33Tags:         gocardless, woocommerce, direct debit, instant bank pay
    44Tested up to: 6.8
    5 Stable tag:   2.9.7
     5Stable tag:   2.9.8
    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.8 - 2025-10-07 =
     144* Fix - Automatically disconnect the GoCardless account and display a reconnect notice when the token becomes invalid or inactive.
     145* Dev - Bump WooCommerce "tested up to" version 10.2.
     146* Dev - Bump WooCommerce minimum supported version to 10.0.
    142147
    143148= 2.9.7 - 2025-08-05 =
  • woocommerce-gateway-gocardless/tags/2.9.8/woocommerce-gateway-gocardless.php

    r3339885 r3375261  
    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.7
     6 * Version:              2.9.8
    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: 9.9
    16  * WC tested up to:      10.1
     15 * WC requires at least: 10.0
     16 * WC tested up to:      10.2
    1717 *
    1818 * Copyright: © 2023-2025 WooCommerce
     
    3939     * @var string
    4040     */
    41     public $version = '2.9.7'; // WRCS: DEFINED_VERSION.
     41    public $version = '2.9.8'; // WRCS: DEFINED_VERSION.
    4242
    4343    /**
  • woocommerce-gateway-gocardless/trunk/changelog.txt

    r3339885 r3375261  
    11*** GoCardless for WooCommerce Changelog ***
     2
     32025-10-07 - version 2.9.8
     4* Fix - Automatically disconnect the GoCardless account and display a reconnect notice when the token becomes invalid or inactive.
     5* Dev - Bump WooCommerce "tested up to" version 10.2.
     6* Dev - Bump WooCommerce minimum supported version to 10.0.
    27
    382025-08-05 - version 2.9.7
  • woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-api.php

    r3339885 r3375261  
    175175        }
    176176
    177         $parsed_resp = json_decode( wp_remote_retrieve_body( $resp ), true );
     177        $response_code = wp_remote_retrieve_response_code( $resp );
     178        $parsed_resp   = json_decode( wp_remote_retrieve_body( $resp ), true );
    178179        if ( is_null( $parsed_resp ) ) {
    179180            wc_gocardless()->log( sprintf( '%s - Failed to decode JSON resp %s', __METHOD__, print_r( wp_remote_retrieve_body( $resp ), true ) ) ); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
     
    199200            }
    200201
     202            /*
     203             * Error Handling for 401 unauthorized response code.
     204             *
     205             * If API respond with 401 unauthorized response code, it means:
     206             *
     207             * - `access_token_not_found` (the access token was not recognised); or
     208             * - `access_token_revoked` (the user has revoked your access to their account); or
     209             * - `access_token_not_active` (the access token is inactive for another reason)
     210             *
     211             * We need to disconnect from GoCardless and display a notice to the user to connect again.
     212             */
     213            if ( 401 === $response_code && 'invalid_api_usage' === $parsed_resp['error']['type'] ) {
     214                // Unauthorized response code, disconnect from GoCardless.
     215                wc_gocardless()->log( sprintf( '%s - Unauthorized response code, disconnecting from GoCardless', __METHOD__ ) );
     216                $settings                 = get_option( 'woocommerce_gocardless_settings', array() );
     217                $settings['access_token'] = '';
     218                update_option( 'woocommerce_gocardless_settings', $settings );
     219
     220                // Clear the available scheme transient.
     221                delete_transient( 'wc_gocardless_available_scheme_identifiers' );
     222
     223                wc_gocardless()->log( sprintf( '%s - Disconnected from GoCardless', __METHOD__ ) );
     224
     225                // Add option to display notice to connect GoCardless again.
     226                update_option( 'wc_gocardless_access_token_unauthorized', true );
     227            }
     228
    201229            $new_mandate = null;
    202230            if ( ! empty( $parsed_resp['error']['errors'] ) && is_array( $parsed_resp['error']['errors'] ) ) {
  • woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-gateway.php

    r3339885 r3375261  
    159159        // Clear the available scheme transient.
    160160        delete_transient( 'wc_gocardless_available_scheme_identifiers' );
     161
     162        // Clear option which displays notice to connect GoCardless.
     163        delete_option( 'wc_gocardless_access_token_unauthorized' );
    161164
    162165        // Delete notice that informs merchant to connect with GoCardless.
  • woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-order-admin.php

    r3239558 r3375261  
    2626
    2727        add_action( 'admin_notices', array( $this, 'display_connection_notices' ) );
     28        add_action( 'admin_notices', array( $this, 'display_access_token_unauthorized_notice' ) );
    2829
    2930        // GoCardless Connect/Disconnect actions.
     
    577578        return $notice;
    578579    }
     580
     581    /**
     582     * Display notice for access token unauthorized.
     583     *
     584     * @since 2.9.8
     585     */
     586    public function display_access_token_unauthorized_notice() {
     587        // Check if option is set to display notice.
     588        if ( ! get_option( 'wc_gocardless_access_token_unauthorized' ) ) {
     589            return;
     590        }
     591
     592        // Check if access token is there.
     593        $settings = get_option( 'woocommerce_gocardless_settings', array() );
     594        if ( ! empty( $settings['access_token'] ) ) {
     595            // Remove the option to display notice, as we have an access token now (in case it missed to remove while connect to GoCardless).
     596            delete_option( 'wc_gocardless_access_token_unauthorized' );
     597            return;
     598        }
     599        ?>
     600        <div class="notice notice-warning">
     601            <p>
     602            <?php
     603            echo wp_kses(
     604                sprintf(
     605                    /* translators: %s: settings URL */
     606                    __( 'The connection to your <strong>GoCardless</strong> account has been disconnected because the access token is no longer active or valid. Please <a href="%s">connect</a> your GoCardless account to continue accepting payments.', 'woocommerce-gateway-gocardless' ),
     607                    wc_gocardless()->get_setting_url()
     608                ),
     609                array(
     610                    'a'      => array(
     611                        'href' => array(),
     612                    ),
     613                    'strong' => array(),
     614                )
     615            );
     616            ?>
     617            </p>
     618        </div>
     619        <?php
     620    }
    579621}
  • woocommerce-gateway-gocardless/trunk/readme.txt

    r3339885 r3375261  
    33Tags:         gocardless, woocommerce, direct debit, instant bank pay
    44Tested up to: 6.8
    5 Stable tag:   2.9.7
     5Stable tag:   2.9.8
    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.8 - 2025-10-07 =
     144* Fix - Automatically disconnect the GoCardless account and display a reconnect notice when the token becomes invalid or inactive.
     145* Dev - Bump WooCommerce "tested up to" version 10.2.
     146* Dev - Bump WooCommerce minimum supported version to 10.0.
    142147
    143148= 2.9.7 - 2025-08-05 =
  • woocommerce-gateway-gocardless/trunk/woocommerce-gateway-gocardless.php

    r3339885 r3375261  
    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.7
     6 * Version:              2.9.8
    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: 9.9
    16  * WC tested up to:      10.1
     15 * WC requires at least: 10.0
     16 * WC tested up to:      10.2
    1717 *
    1818 * Copyright: © 2023-2025 WooCommerce
     
    3939     * @var string
    4040     */
    41     public $version = '2.9.7'; // WRCS: DEFINED_VERSION.
     41    public $version = '2.9.8'; // WRCS: DEFINED_VERSION.
    4242
    4343    /**
Note: See TracChangeset for help on using the changeset viewer.