summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-02-23 14:50:12 +0100
committerChristian Grothoff <christian@grothoff.org>2023-02-23 14:50:12 +0100
commita6b36d5cee4e464233ec28cfc320b27a339338e4 (patch)
tree91d36b2c7af3a48c19d1c77b7d88202070de1cd7
parent4ef13782382da04784d8266b0854c17a7de1d0cf (diff)
downloadgnu-taler-payment-for-woocommerce-a6b36d5cee4e464233ec28cfc320b27a339338e4.tar.gz
gnu-taler-payment-for-woocommerce-a6b36d5cee4e464233ec28cfc320b27a339338e4.tar.bz2
gnu-taler-payment-for-woocommerce-a6b36d5cee4e464233ec28cfc320b27a339338e4.zip
-fix logging
-rw-r--r--class-wc-gnutaler-gateway.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/class-wc-gnutaler-gateway.php b/class-wc-gnutaler-gateway.php
index 31fc632..940cc1a 100644
--- a/class-wc-gnutaler-gateway.php
+++ b/class-wc-gnutaler-gateway.php
@@ -37,12 +37,12 @@
* Which version of the Taler merchant protocol is implemented
* by this implementation? Used to determine compatibility.
*/
-define( 'GNU_TALER_MERCHANT_PROTOCOL_CURRENT', 1 );
+define( 'GNU_TALER_MERCHANT_PROTOCOL_CURRENT', 3 );
/**
* How many merchant protocol versions are we backwards compatible with?
*/
-define( 'GNU_TALER_MERCHANT_PROTOCOL_AGE', 0 );
+define( 'GNU_TALER_MERCHANT_PROTOCOL_AGE', 2 );
require_once ABSPATH . 'wp-admin/includes/plugin.php';
@@ -131,15 +131,15 @@ function gnutaler_init_gateway_class() {
* Class constructor
*/
public function __construct() {
- // Setup logging.
- $this->log = new WC_logger( $this->id ); // Setup logging.
- $this->debug = 'yes' === $this->get_option( 'debug', 'no' );
- self::$log_enabled = $this->debug;
$this->setup_properties();
$this->init_form_fields();
$this->init_settings();
+ // Setup logging.
+ $this->debug = 'yes' === $this->get_option( 'debug', 'no' );
+ self::$log_enabled = $this->debug;
+
// This gateway can support refunds, saved payment methods.
$this->supports = array(
'products',
@@ -184,6 +184,7 @@ function gnutaler_init_gateway_class() {
20,
4
);
+ $this->debug( "GNU Taler payment gateway class constructed" );
}
@@ -425,6 +426,8 @@ function gnutaler_init_gateway_class() {
* @return array The return array will either have the successful return value or a detailed error message.
*/
private function call_api( $method, $url, $body ): array {
+ $this->warning( "Running " . $method . " on " . $url );
+
$apikey = $this->get_option( 'GNU_Taler_Backend_API_Key' );
$args = array(
'timeout' => 30, // In seconds.
@@ -511,6 +514,8 @@ 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 );
+
$config = $this->call_api( 'GET', $url . '/config', false );
$config_http_status = $config['http_code'];
$config_body = $config['message'];
@@ -1042,7 +1047,13 @@ function gnutaler_init_gateway_class() {
// We intentionally do NOT verify the nonce here, as logging
// should always work.
// phpcs:disable WordPress.Security.NonceVerification
- $order_id = sanitize_text_field( wp_unslash( $_GET['order_id'] ) );
+ if ( isset ($_GET['order_id'] ) ) {
+ $order_id = sanitize_text_field( wp_unslash( $_GET['order_id'] ) );
+ }
+ else
+ {
+ $order_id = 'NONE';
+ }
// phpcs:enable
if ( empty( self::$log ) ) {
self::$log = wc_get_logger();