From e313357219bbcd55870d796de0d3e881ec4d88c1 Mon Sep 17 00:00:00 2001 From: Louise-Krokedil <129946914+Louise-Krokedil@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:19:28 +0200 Subject: [PATCH 01/15] Bumped WC version --- truelayer-for-woocommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truelayer-for-woocommerce.php b/truelayer-for-woocommerce.php index e4a3bec..c371f78 100644 --- a/truelayer-for-woocommerce.php +++ b/truelayer-for-woocommerce.php @@ -10,7 +10,7 @@ * Domain Path: /languages * * WC requires at least: 6.0.0 - * WC tested up to: 7.6.1 + * WC tested up to: 7.8.1 * * Copyright (c) 2022-2023 Krokedil * From 53db60370364b1dc5dde8bce08a0f900edfab4ad Mon Sep 17 00:00:00 2001 From: Louise-Krokedil <129946914+Louise-Krokedil@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:20:12 +0200 Subject: [PATCH 02/15] Bumped WC/WP versions --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index f7349d7..7beb769 100644 --- a/readme.txt +++ b/readme.txt @@ -2,10 +2,10 @@ Contributors: krokedil, danilokrlovic Tags: ecommerce, e-commerce, woocommerce, truelayer, payments, instant payments, refunds, open banking Requires at least: 5.0 -Tested up to: 6.2.0 +Tested up to: 6.2.2 Requires PHP: 7.4 WC requires at least: 6.0.0 -WC tested up to: 7.6.1 +WC tested up to: 7.8.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html Stable tag: 1.2.0 From f0ac88ad9e4415688ef8adec50d808b2a4a83e61 Mon Sep 17 00:00:00 2001 From: Louise-Krokedil <129946914+Louise-Krokedil@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:29:54 +0200 Subject: [PATCH 03/15] Bumped WC/WP versions --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 7beb769..86da0b0 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Requires at least: 5.0 Tested up to: 6.2.2 Requires PHP: 7.4 WC requires at least: 6.0.0 -WC tested up to: 7.8.1 +WC tested up to: 7.8.2 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html Stable tag: 1.2.0 From 4505a6f3cd9b3021aeea0549f145b73907a08625 Mon Sep 17 00:00:00 2001 From: Louise-Krokedil <129946914+Louise-Krokedil@users.noreply.github.com> Date: Wed, 12 Jul 2023 11:30:16 +0200 Subject: [PATCH 04/15] Bumped WC version --- truelayer-for-woocommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truelayer-for-woocommerce.php b/truelayer-for-woocommerce.php index c371f78..bf7e888 100644 --- a/truelayer-for-woocommerce.php +++ b/truelayer-for-woocommerce.php @@ -10,7 +10,7 @@ * Domain Path: /languages * * WC requires at least: 6.0.0 - * WC tested up to: 7.8.1 + * WC tested up to: 7.8.2 * * Copyright (c) 2022-2023 Krokedil * From 6b08a4ba2dc6d3124e338afcd5b0ac39fb56193f Mon Sep 17 00:00:00 2001 From: Louise-Krokedil <129946914+Louise-Krokedil@users.noreply.github.com> Date: Thu, 17 Aug 2023 14:42:52 +0200 Subject: [PATCH 05/15] Bumped WC version --- truelayer-for-woocommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/truelayer-for-woocommerce.php b/truelayer-for-woocommerce.php index bf7e888..f5d0ebe 100644 --- a/truelayer-for-woocommerce.php +++ b/truelayer-for-woocommerce.php @@ -10,7 +10,7 @@ * Domain Path: /languages * * WC requires at least: 6.0.0 - * WC tested up to: 7.8.2 + * WC tested up to: 8.0.2 * * Copyright (c) 2022-2023 Krokedil * From bbf862799c94986b24ff77f035ab6db55c5122fc Mon Sep 17 00:00:00 2001 From: Louise-Krokedil <129946914+Louise-Krokedil@users.noreply.github.com> Date: Thu, 17 Aug 2023 14:43:25 +0200 Subject: [PATCH 06/15] Bumped WC/WP versions --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 86da0b0..d832079 100644 --- a/readme.txt +++ b/readme.txt @@ -2,10 +2,10 @@ Contributors: krokedil, danilokrlovic Tags: ecommerce, e-commerce, woocommerce, truelayer, payments, instant payments, refunds, open banking Requires at least: 5.0 -Tested up to: 6.2.2 +Tested up to: 6.3 Requires PHP: 7.4 WC requires at least: 6.0.0 -WC tested up to: 7.8.2 +WC tested up to: 8.0.2 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html Stable tag: 1.2.0 From 9f6b130a6cea00f6b8ab4ee4c51687b993f97ae3 Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Wed, 23 Aug 2023 15:37:49 +0200 Subject: [PATCH 07/15] Add and implement setting for release channel --- classes/class-truelayer-fields.php | 8 ++++++++ .../class-truelayer-request-create-payment.php | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/classes/class-truelayer-fields.php b/classes/class-truelayer-fields.php index dec6014..fa6a3da 100644 --- a/classes/class-truelayer-fields.php +++ b/classes/class-truelayer-fields.php @@ -189,6 +189,14 @@ public static function fields() { 'desc_tip' => true, ), + 'truelayer_release_channel' => array( + 'title' => __( 'Release channel', 'truelayer-for-woocommerce' ), + 'type' => 'text', + 'description' => __( 'Enter the release channel that you wish to use for TrueLayer', 'truelayer-for-woocommerce' ), + 'default' => '', + 'desc_tip' => true, + ), + 'truelayer_payment_page_type' => array( 'title' => __( 'Payments Page Types', 'truelayer-for-woocommerce' ), 'type' => 'select', diff --git a/classes/requests/post/class-truelayer-request-create-payment.php b/classes/requests/post/class-truelayer-request-create-payment.php index 1f3d3db..9394647 100644 --- a/classes/requests/post/class-truelayer-request-create-payment.php +++ b/classes/requests/post/class-truelayer-request-create-payment.php @@ -86,6 +86,11 @@ protected function get_body() { $body['payment_method']['provider_selection']['filter']['customer_segments'] = $customer_segment; } + $release_channel = $this->get_release_channel(); + if ( ! empty( $release_channel ) ) { + $body['payment_method']['provider_selection']['filter']['release_channel'] = $release_channel; + } + return $body; } @@ -144,4 +149,14 @@ private function get_banking_providers() { $banking_providers = empty( $this->settings['truelayer_banking_providers'] ) ? array() : $this->settings['truelayer_banking_providers']; return array_map( 'strtolower', $banking_providers ); } + + /** + * Returns the release channel + * + * @return array + */ + private function get_release_channel() { + $release_channel = empty( $this->settings['truelayer_release_channel'] ) ? array() : $this->settings['truelayer_release_channel']; + return $release_channel; + } } From 8ee3342dc42082a63b527a98d1d64a8004983923 Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 19 Sep 2023 13:10:11 +0200 Subject: [PATCH 08/15] Add woocommerce stubs to composer dev dependencies --- composer.json | 3 ++ composer.lock | 93 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b99a461..c0436d8 100644 --- a/composer.json +++ b/composer.json @@ -9,5 +9,8 @@ "platform": { "php": "7.4" } + }, + "require-dev": { + "php-stubs/woocommerce-stubs": "^8.1" } } diff --git a/composer.lock b/composer.lock index 97d356f..29ae150 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4e1252d8b7ab490329509e8e844d157f", + "content-hash": "e010ccaf3d551c29c897b5377b4c357c", "packages": [ { "name": "brick/math", @@ -1276,7 +1276,96 @@ "time": "2021-01-21T19:18:03+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "php-stubs/woocommerce-stubs", + "version": "v8.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/woocommerce-stubs.git", + "reference": "f5a8621ca0a28c93b37b827ef92e7b49ad3d1923" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/woocommerce-stubs/zipball/f5a8621ca0a28c93b37b827ef92e7b49ad3d1923", + "reference": "f5a8621ca0a28c93b37b827ef92e7b49ad3d1923", + "shasum": "" + }, + "require": { + "php-stubs/wordpress-stubs": "^5.3 || ^6.0" + }, + "require-dev": { + "php": "~7.1 || ~8.0", + "php-stubs/generator": "^0.8.0" + }, + "suggest": { + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WooCommerce function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/woocommerce-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "woocommerce", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/woocommerce-stubs/issues", + "source": "https://github.com/php-stubs/woocommerce-stubs/tree/v8.1.0" + }, + "time": "2023-09-12T20:25:04+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c", + "reference": "adda7609e71d5f4dc7b87c74f8ec9e3437d2e92c", + "shasum": "" + }, + "require-dev": { + "nikic/php-parser": "^4.13", + "php": "^7.4 || ~8.0.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.10.12", + "phpunit/phpunit": "^9.5" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.3.0" + }, + "time": "2023-08-10T16:34:11+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], From 57624e081397240b3224e22c1fd9f482dbcb504f Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 19 Sep 2023 13:12:31 +0200 Subject: [PATCH 09/15] Remove getting settings twice from TrueLayer_Payment_Gateway::get_option We already retrieve the settings on line 75. --- classes/class-truelayer-gateway.php | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/class-truelayer-gateway.php b/classes/class-truelayer-gateway.php index 1ae7daa..fb43196 100644 --- a/classes/class-truelayer-gateway.php +++ b/classes/class-truelayer-gateway.php @@ -85,7 +85,6 @@ public function get_option( $key, $empty_value = null ) { $client_secret = 'truelayer_client_secret'; $client_certificate = 'truelayer_client_certificate'; } - $settings = get_option( 'woocommerce_truelayer_settings', array() ); $truelayer_options = array( $private_key, $client_secret, $client_certificate ); $truelayer_encryption = Truelayer_Encryption::get_instance(); if ( ! empty( $settings[ $key ] ) ) { From 4824d5b530fa9a2f378da6bd1e66cf104e0a68b4 Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 19 Sep 2023 13:16:14 +0200 Subject: [PATCH 10/15] Add class property logging to TrueLayer_Payment_Gateway Prevents a deprecation notice in PHP 8.2 --- classes/class-truelayer-gateway.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/class-truelayer-gateway.php b/classes/class-truelayer-gateway.php index fb43196..b66e087 100644 --- a/classes/class-truelayer-gateway.php +++ b/classes/class-truelayer-gateway.php @@ -13,8 +13,6 @@ * Class TrueLayer_Payment_Gateway. */ class TrueLayer_Payment_Gateway extends WC_Payment_Gateway { - - /** * Allowed currencies. * @@ -29,6 +27,13 @@ class TrueLayer_Payment_Gateway extends WC_Payment_Gateway { */ public $testmode; + /** + * The plugin logging setting value. + * + * @var string + */ + public $logging; + /** * Class constructor. */ From 19c3d0fcd6e690432362edfd0c7ebe694a73525c Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 19 Sep 2023 13:17:16 +0200 Subject: [PATCH 11/15] Minor formatting fix --- classes/class-truelayer-gateway.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-truelayer-gateway.php b/classes/class-truelayer-gateway.php index b66e087..6a020df 100644 --- a/classes/class-truelayer-gateway.php +++ b/classes/class-truelayer-gateway.php @@ -164,8 +164,8 @@ public function country_currency_check( $order = false ) { * @return array */ public function process_payment( $order_id ) { - $settings = get_option( 'woocommerce_truelayer_settings', array() ); - $epp_enabled = $settings['truelayer_payment_page_type'] ?? 'HPP'; + $settings = get_option( 'woocommerce_truelayer_settings', array() ); + $epp_enabled = $settings['truelayer_payment_page_type'] ?? 'HPP'; $response = TrueLayer()->api->create_payment( $order_id ); From 0dffa56019e93e6c58a01fd9e621da7b605e160d Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 19 Sep 2023 13:46:25 +0200 Subject: [PATCH 12/15] Fix deprecation warnings on FILTER_SANITIZE_STRING --- classes/class-truelayer-assets.php | 2 +- classes/class-truelayer-confirmation.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/class-truelayer-assets.php b/classes/class-truelayer-assets.php index d727346..2cacc54 100644 --- a/classes/class-truelayer-assets.php +++ b/classes/class-truelayer-assets.php @@ -98,7 +98,7 @@ public function enqueue_scripts() { * @return bool */ protected function check_for_load_assets() { - $section = filter_input( INPUT_GET, 'section', FILTER_SANITIZE_STRING ); + $section = filter_input( INPUT_GET, 'section', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); if ( empty( $section ) || 'truelayer' !== $section ) { return false; } diff --git a/classes/class-truelayer-confirmation.php b/classes/class-truelayer-confirmation.php index fb519c4..f38214d 100644 --- a/classes/class-truelayer-confirmation.php +++ b/classes/class-truelayer-confirmation.php @@ -28,8 +28,8 @@ public function __construct() { */ public function maybe_redirect() { - $transaction_id = filter_input( INPUT_GET, 'payment_id', FILTER_SANITIZE_STRING ); - $error = filter_input( INPUT_GET, 'error', FILTER_SANITIZE_STRING ); + $transaction_id = filter_input( INPUT_GET, 'payment_id', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); + $error = filter_input( INPUT_GET, 'error', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); $query_args = array( 'fields' => 'ids', From 31ebc0dce4655eadd7fa073660243b15908bc0e3 Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 19 Sep 2023 13:50:56 +0200 Subject: [PATCH 13/15] Version 1.3.0 --- readme.txt | 10 +++++++--- truelayer-for-woocommerce.php | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/readme.txt b/readme.txt index b74f912..6d250b9 100644 --- a/readme.txt +++ b/readme.txt @@ -2,13 +2,13 @@ Contributors: krokedil, danilokrlovic Tags: ecommerce, e-commerce, woocommerce, truelayer, payments, instant payments, refunds, open banking Requires at least: 5.0 -Tested up to: 6.3 +Tested up to: 6.3.1 Requires PHP: 7.4 WC requires at least: 6.0.0 -WC tested up to: 8.0.2 +WC tested up to: 8.1.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html -Stable tag: 1.2.1 +Stable tag: 1.3.0 TrueLayer for WooCommerce is a plugin that extends WooCommerce, allowing you to take payments via TrueLayer. @@ -54,6 +54,10 @@ More information on how to get started can be found in the [plugin documentation 6. Read more about the configuration process in the [plugin documentation](https://docs.krokedil.com/truelayer-for-woocommerce/). == CHANGELOG == += 2023.09.19 - version 1.3.0 = +* Feature - Add feature to set a custom release channel for the payment in TrueLayer. This can be set on the settings page for the plugin in the setting "Release channel". If left empty no release channel will be sent to Truelayer. +* Fix - Fixed some deprecation warnings for PHP version 8.2+. + = 2023.09.15 - version 1.2.1 = * Fix - Remove sensitive data from logs diff --git a/truelayer-for-woocommerce.php b/truelayer-for-woocommerce.php index 77c4323..7e19da0 100644 --- a/truelayer-for-woocommerce.php +++ b/truelayer-for-woocommerce.php @@ -5,7 +5,7 @@ * Description: TrueLayer for WooCommerce. * Author: Krokedil * Author URI: https://krokedil.com/ - * Version: 1.2.1 + * Version: 1.3.0 * Text Domain: truelayer-for-woocommerce * Domain Path: /languages * @@ -29,7 +29,7 @@ define( 'TRUELAYER_WC_MAIN_FILE', __FILE__ ); define( 'TRUELAYER_WC_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); define( 'TRUELAYER_WC_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) ); -define( 'TRUELAYER_WC_PLUGIN_VERSION', '1.2.1' ); +define( 'TRUELAYER_WC_PLUGIN_VERSION', '1.3.0' ); if ( ! class_exists( 'TrueLayer_For_WooCommerce' ) ) { /** From d8aee75b04fb94d2cdb057b30cad681442470b1b Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 19 Sep 2023 13:53:00 +0200 Subject: [PATCH 14/15] Update readme.txt --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 6d250b9..f92f37c 100644 --- a/readme.txt +++ b/readme.txt @@ -55,7 +55,7 @@ More information on how to get started can be found in the [plugin documentation == CHANGELOG == = 2023.09.19 - version 1.3.0 = -* Feature - Add feature to set a custom release channel for the payment in TrueLayer. This can be set on the settings page for the plugin in the setting "Release channel". If left empty no release channel will be sent to Truelayer. +* Feature - Add feature to set a custom release channel for the payment in TrueLayer. This can be set on the settings page for the plugin in the setting "Release channel". If left empty no release channel will be sent to TrueLayer. * Fix - Fixed some deprecation warnings for PHP version 8.2+. = 2023.09.15 - version 1.2.1 = From a0ed3241e4abac39196396a2be66496ccd351034 Mon Sep 17 00:00:00 2001 From: MichaelBengtsson Date: Tue, 3 Oct 2023 17:21:01 +0200 Subject: [PATCH 15/15] Remove the logging property from TrueLayer_Payment_Gateway Removing due to it being unused --- classes/class-truelayer-gateway.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/classes/class-truelayer-gateway.php b/classes/class-truelayer-gateway.php index 6a020df..0ae20c8 100644 --- a/classes/class-truelayer-gateway.php +++ b/classes/class-truelayer-gateway.php @@ -27,13 +27,6 @@ class TrueLayer_Payment_Gateway extends WC_Payment_Gateway { */ public $testmode; - /** - * The plugin logging setting value. - * - * @var string - */ - public $logging; - /** * Class constructor. */ @@ -56,7 +49,6 @@ public function __construct() { $this->description = $this->get_option( 'description' ); $this->testmode = $this->get_option( 'testmode' ); - $this->logging = $this->get_option( 'logging' ); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) ); add_action(