summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-20 12:02:45 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-20 12:02:45 +0200
commita4a6916f0d872a461ba99097c48b211b1ad389a7 (patch)
treecbb15608cc9e3dedbbf54a7dc2f13ac356e031ff
parentbb70374196e3a2f07c59301118ef342a10b14a21 (diff)
downloadwoocommerce-taler-a4a6916f0d872a461ba99097c48b211b1ad389a7.tar.gz
woocommerce-taler-a4a6916f0d872a461ba99097c48b211b1ad389a7.tar.bz2
woocommerce-taler-a4a6916f0d872a461ba99097c48b211b1ad389a7.zip
logo
-rw-r--r--plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php43
1 files changed, 21 insertions, 22 deletions
diff --git a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
index 5ac2c4b..6ff4073 100644
--- a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
+++ b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
@@ -45,13 +45,10 @@ define("MERCHANT_PROTOCOL_AGE", 0);
/*
TODO (without FIXME in code):
- test WC_Logger based logging
-- payment needs to be tested
-- refund needs to be tested
+- refund needs to be tested more (with wallet!)
FEATURES:
- add support for i18n
-- consider constructing of 'summary text' from order details?
-- try to get 'merchant_name' from WC configuration instead of our own settings!
- MAYBE: set '$this->view_transaction_url' to '$backend_url/orders/%s' to support get_transaction_url()?
(where is this used?)
- MAYBE: multi-currency support (i.e. use https://$CURRENCY.$backend_url/?)
@@ -164,14 +161,8 @@ function gnutaler_init_gateway_class()
'Order_text' => array(
'title' => 'Summary Text of the Order',
'type' => 'text',
- 'description' => 'Set the text the customer will see when confirming payment.',
- 'default' => 'Please Confirm Order',
- ),
- 'merchant_name' => array(
- 'title' => 'Name of This Webshop',
- 'type' => 'text',
- 'description' => 'Set the name of this webshop that the customer will see during the payment transaction.',
- 'default' => '',
+ 'description' => 'Set the text the customer will see when confirming payment. %s will be substituted with the order number.',
+ 'default' => 'Please Confirm Order %s',
),
'wc_gnutaler_debug' => array(
'title' => __( 'Debug Log', 'GNU Taler' ),
@@ -183,21 +174,23 @@ function gnutaler_init_gateway_class()
);
// Load the settings.
- echo "HERE: " . woocommerce_settings_get_option('name');
$this->init_settings();
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$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...
+ $this->view_transaction_url = $this->GNU_Taler_Backend_URL . '/orders/%s';
+
+// 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);
$this->GNU_Taler_Backend_API_Key = $this->get_option( 'GNU_Taler_Backend_API_Key' );
$this->Payment_url = $this->get_option( 'Payment_url' );
$this->Order_text = $this->get_option( 'Order_text' );
+ // Register handler for the fulfillment URL
add_action( 'woocommerce_api_' . strtolower(get_class($this)),
- array( &$this, 'callback_handler' ) );
+ array( &$this, 'fulfillment_url_handler' ) );
$this->info ("added woocommerce_api_callback action: " .
'woocommerce_api_' . strtolower(get_class($this)));
@@ -242,6 +235,13 @@ function gnutaler_init_gateway_class()
}
+ /**
+ * Called when WC sends out the e-mail notification for refunds.
+ * Adds a Taler-specific notice for where to click to obtain
+ * the refund.
+ * UNTESTED (as I don't seem to be able to trigger refund-related
+ * emails form WooCommerce).
+ */
function add_content_refund_email ( $wc_order, $sent_to_admin, $plain_text, $email ) {
if ( $email->id == 'customer_refunded_order' ) {
$backend_url = $this->get_option( 'GNU_Taler_Backend_URL' );
@@ -263,7 +263,7 @@ function gnutaler_init_gateway_class()
* If the order ID is unknown and/or the payment did not succeed, we
* redirect to the home page and/or the user's order page (for logged in users).
*/
- function callback_handler(): void
+ function fulfillment_url_handler(): void
{
global $woocommerce;
@@ -599,12 +599,11 @@ function gnutaler_init_gateway_class()
$order_json = array(
'order' => array(
'amount' => $wc_order_currency . ':' . $wc_order_total_amount,
- 'summary' => sprintf( 'Order %s from %s.',
- $wc_order->get_order_number,
- $this->get_option('merchant_name')),
- // NOTE: This interacts with the
- // 'add_action' call to invoke the 'callback_handler'
- // when the user goes to this URL!
+ 'summary' => sprintf( $this->Order_text,
+ $wc_order->get_order_number),
+ // NOTE: This interacts with the 'add_action' call
+ // to invoke the 'fulfillment_url_handler' when the
+ // user goes to this URL!
'fulfillment_url' => get_home_url()
. '/?wc-api='
. strtolower(get_class($this))