Changeset 3375261
- Timestamp:
- 10/08/2025 05:45:38 PM (5 months ago)
- Location:
- woocommerce-gateway-gocardless
- Files:
-
- 12 edited
- 1 copied
-
tags/2.9.8 (copied) (copied from woocommerce-gateway-gocardless/trunk)
-
tags/2.9.8/changelog.txt (modified) (1 diff)
-
tags/2.9.8/includes/class-wc-gocardless-api.php (modified) (2 diffs)
-
tags/2.9.8/includes/class-wc-gocardless-gateway.php (modified) (1 diff)
-
tags/2.9.8/includes/class-wc-gocardless-order-admin.php (modified) (2 diffs)
-
tags/2.9.8/readme.txt (modified) (2 diffs)
-
tags/2.9.8/woocommerce-gateway-gocardless.php (modified) (3 diffs)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/includes/class-wc-gocardless-api.php (modified) (2 diffs)
-
trunk/includes/class-wc-gocardless-gateway.php (modified) (1 diff)
-
trunk/includes/class-wc-gocardless-order-admin.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woocommerce-gateway-gocardless.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-gateway-gocardless/tags/2.9.8/changelog.txt
r3339885 r3375261 1 1 *** GoCardless for WooCommerce Changelog *** 2 3 2025-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. 2 7 3 8 2025-08-05 - version 2.9.7 -
woocommerce-gateway-gocardless/tags/2.9.8/includes/class-wc-gocardless-api.php
r3339885 r3375261 175 175 } 176 176 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 ); 178 179 if ( is_null( $parsed_resp ) ) { 179 180 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 … … 199 200 } 200 201 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 201 229 $new_mandate = null; 202 230 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 159 159 // Clear the available scheme transient. 160 160 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' ); 161 164 162 165 // 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 26 26 27 27 add_action( 'admin_notices', array( $this, 'display_connection_notices' ) ); 28 add_action( 'admin_notices', array( $this, 'display_access_token_unauthorized_notice' ) ); 28 29 29 30 // GoCardless Connect/Disconnect actions. … … 577 578 return $notice; 578 579 } 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 } 579 621 } -
woocommerce-gateway-gocardless/tags/2.9.8/readme.txt
r3339885 r3375261 3 3 Tags: gocardless, woocommerce, direct debit, instant bank pay 4 4 Tested up to: 6.8 5 Stable tag: 2.9. 75 Stable tag: 2.9.8 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.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. 142 147 143 148 = 2.9.7 - 2025-08-05 = -
woocommerce-gateway-gocardless/tags/2.9.8/woocommerce-gateway-gocardless.php
r3339885 r3375261 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. 76 * Version: 2.9.8 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: 9.916 * WC tested up to: 10. 115 * WC requires at least: 10.0 16 * WC tested up to: 10.2 17 17 * 18 18 * Copyright: © 2023-2025 WooCommerce … … 39 39 * @var string 40 40 */ 41 public $version = '2.9. 7'; // WRCS: DEFINED_VERSION.41 public $version = '2.9.8'; // WRCS: DEFINED_VERSION. 42 42 43 43 /** -
woocommerce-gateway-gocardless/trunk/changelog.txt
r3339885 r3375261 1 1 *** GoCardless for WooCommerce Changelog *** 2 3 2025-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. 2 7 3 8 2025-08-05 - version 2.9.7 -
woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-api.php
r3339885 r3375261 175 175 } 176 176 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 ); 178 179 if ( is_null( $parsed_resp ) ) { 179 180 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 … … 199 200 } 200 201 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 201 229 $new_mandate = null; 202 230 if ( ! empty( $parsed_resp['error']['errors'] ) && is_array( $parsed_resp['error']['errors'] ) ) { -
woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-gateway.php
r3339885 r3375261 159 159 // Clear the available scheme transient. 160 160 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' ); 161 164 162 165 // Delete notice that informs merchant to connect with GoCardless. -
woocommerce-gateway-gocardless/trunk/includes/class-wc-gocardless-order-admin.php
r3239558 r3375261 26 26 27 27 add_action( 'admin_notices', array( $this, 'display_connection_notices' ) ); 28 add_action( 'admin_notices', array( $this, 'display_access_token_unauthorized_notice' ) ); 28 29 29 30 // GoCardless Connect/Disconnect actions. … … 577 578 return $notice; 578 579 } 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 } 579 621 } -
woocommerce-gateway-gocardless/trunk/readme.txt
r3339885 r3375261 3 3 Tags: gocardless, woocommerce, direct debit, instant bank pay 4 4 Tested up to: 6.8 5 Stable tag: 2.9. 75 Stable tag: 2.9.8 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.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. 142 147 143 148 = 2.9.7 - 2025-08-05 = -
woocommerce-gateway-gocardless/trunk/woocommerce-gateway-gocardless.php
r3339885 r3375261 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. 76 * Version: 2.9.8 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: 9.916 * WC tested up to: 10. 115 * WC requires at least: 10.0 16 * WC tested up to: 10.2 17 17 * 18 18 * Copyright: © 2023-2025 WooCommerce … … 39 39 * @var string 40 40 */ 41 public $version = '2.9. 7'; // WRCS: DEFINED_VERSION.41 public $version = '2.9.8'; // WRCS: DEFINED_VERSION. 42 42 43 43 /**
Note: See TracChangeset
for help on using the changeset viewer.