gnu-taler-payment-for-woocommerce

WooCommerce plugin to enable payments with GNU Taler
Log | Files | Refs | LICENSE

commit 84c1b3cca0f54da0c33f25918df6c67c51ba4afa
parent 3f0ddc7cfeed27b8a3be4bd52095c013d6f1b958
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 14 Sep 2025 13:39:28 +0200

bump versions, declare compatibility with custom_order_tables

Diffstat:
Mclass-wc-gnutaler-gateway.php | 82++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Mreadme.txt | 8+++++---
2 files changed, 61 insertions(+), 29 deletions(-)

diff --git a/class-wc-gnutaler-gateway.php b/class-wc-gnutaler-gateway.php @@ -9,13 +9,15 @@ * Plugin Name: GNU Taler Payment for WooCommerce * Plugin URI: https://git.taler.net/woocommerce-taler * Description: This plugin enables payments via the GNU Taler payment system - * Version: 1.0.0 + * Version: 1.1.0 * Author: Dominique Hofmann, Jan StrĂ¼bin, Christian Grothoff * Author URI: https://taler.net/ - * - * License: GNU General Public License v2.0 - * License URI: http://www.gnu.org/licenses/gpl-2.0.html - * WC requires at least: 2.2 + * License: GNU General Public License v3.0 + * License URI: http://www.gnu.org/licenses/gpl-3.0.html + * Requires Plugins: woocommerce + * WC requires at least: 9.6 + * WC tested up to: 10.1 + * Text Domain: gnutaler **/ /* @@ -37,12 +39,12 @@ * Which version of the Taler merchant protocol is implemented * by this implementation? Used to determine compatibility. */ -define( 'GNU_TALER_MERCHANT_PROTOCOL_CURRENT', 18 ); +define( 'GNU_TALER_MERCHANT_PROTOCOL_CURRENT', 21 ); /** * How many merchant protocol versions are we backwards compatible with? */ -define( 'GNU_TALER_MERCHANT_PROTOCOL_AGE', 2 ); +define( 'GNU_TALER_MERCHANT_PROTOCOL_AGE', 5 ); require_once ABSPATH . 'wp-admin/includes/plugin.php'; @@ -66,6 +68,18 @@ function gnutaler_add_gateway_class( $gateways ) { return $gateways; } +// Declare that we are compatible with custom order tables +add_action('before_woocommerce_init', function() { + if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) { + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( + 'custom_order_tables', + __FILE__, + true + ); + } +}); + +// Make GNU Taler payment gateway available to WC add_filter( 'woocommerce_payment_gateways', 'gnutaler_add_gateway_class' ); /** @@ -127,16 +141,23 @@ function gnutaler_init_gateway_class() { */ private static $log_enabled = false; + /** + * Unique id for the gateway. + * @var string + */ + public $id = 'gnutaler'; + /** * Class constructor */ public function __construct() { - $this->setup_properties(); - $this->init_form_fields(); - $this->init_settings(); + $this->icon = plugins_url( '/assets/images/taler.png', __FILE__ ); + + // We cannot use custom fields to show the QR code / do the wallet integration as WC doesn't give us the order_id at that time. Bummer. + $this->has_fields = false; - // Setup logging. + // Setup logging. $this->debug = 'yes' === $this->get_option( 'debug', 'no' ); self::$log_enabled = $this->debug; @@ -146,13 +167,18 @@ function gnutaler_init_gateway_class() { 'refunds', ); + $this->method_title = _x( 'GNU Taler', 'GNU Taler payment method', 'gnutaler' ); + $this->method_description = __( 'This plugin enables payments via the GNU Taler payment system', 'gnutaler' ); + $this->init_form_fields(); + $this->init_settings(); + $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); $this->instructions = $this->get_option( 'instructions' ); $this->enable_for_virtual = true; - $this->enabled = $this->get_option( 'enabled' ); - $this->gnu_taler_backend_url = $this->get_option( 'gnu_taler_backend_url' ); + $this->enabled = $this->get_option( 'enabled' ); + $this->gnu_taler_backend_url = $this->get_option( 'gnu_taler_backend_url' ); // Remove trailing '/', we add one always ourselves... if ( substr( $this->gnu_taler_backend_url, -1 ) === '/' ) { $this->gnu_taler_backend_url = substr( $this->gnu_taler_backend_url, 0, -1 ); @@ -186,18 +212,16 @@ function gnutaler_init_gateway_class() { ); } + public function is_available() { + $res = ('yes' === $this->enabled); + $this->debug ( get_woocommerce_currency() ); + $this->debug( $res + ? __( "Returning payment method is available", 'gnutaler' ) + : __( "Returning payment method is unavailable", 'gnutaler' ) + ); + return $res; + } - /** - * Setup general properties for the gateway. - */ - protected function setup_properties() { - $this->id = 'gnutaler'; // Payment gateway plugin ID. - $this->icon = plugins_url( '/assets/images/taler.png', __FILE__ ); - $this->method_title = 'GNU Taler'; - $this->method_description = __( 'This plugin enables payments via the GNU Taler payment system', 'gnutaler' ); - // We cannot use custom fields to show the QR code / do the wallet integration as WC doesn't give us the order_id at that time. Bummer. - $this->has_fields = false; - } /** * Initialise Gateway Settings Form Fields. @@ -496,10 +520,16 @@ function gnutaler_init_gateway_class() { */ public function needs_setup() { $backend_url = $this->gnu_taler_backend_url; - return ! $this->verify_backend_url( + $verify_result = $this->verify_backend_url( $backend_url, null ); + + $this->debug( $verify_result + ? __( "Backend is ready", 'gnutaler' ) + : __( "Backend is not setup correctly", 'gnutaler' ) ); + + return ! $verify_result; } /** @@ -511,7 +541,7 @@ function gnutaler_init_gateway_class() { * @return bool - Returns if valid or not. */ private function verify_backend_url( $url, $ecurrency ): bool { - $this->warning( "Verifying backend URL " . $url ); + $this->info( "Verifying backend URL " . $url ); $config = $this->call_api( 'GET', $url . '/config', false ); $config_http_status = $config['http_code']; diff --git a/readme.txt b/readme.txt @@ -1,8 +1,11 @@ === GNU Taler Payment Gateway for WooCommerce === +Version: 1.1.0 +Author: Taler Systems SA Contributors: gnutaler Tags: WooCommerce, e-commerce, Taler, Payment Gateway -Requires at least: 5.1 -Tested up to: 7.4.0 +Requires at least: 6.5 +WC Requires at least: 9.6 +Tested up to: 10.1 Stable tag: 7.4 Requires PHP: 7.2 License: GNU General Public License v2.0+ @@ -64,4 +67,3 @@ A: For the plugin to work correctly you need to have the WooCommerce plugin inst * Adaptations to GNU Taler Merchant API 1:0:0 * Ensure plugin follows Wordpress guidelines. First upload to WordPress. -