summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-16 13:53:59 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-16 13:53:59 +0200
commit7a5f336081cce13f26a962725e89fcb29f3bf2a5 (patch)
tree3ab1bd059bc59e1bc9645c509965f2d82e9c9032
parent16d91cc189554667d9fd649b088188fe848cc0eb (diff)
downloadwoocommerce-taler-7a5f336081cce13f26a962725e89fcb29f3bf2a5.tar.gz
woocommerce-taler-7a5f336081cce13f26a962725e89fcb29f3bf2a5.tar.bz2
woocommerce-taler-7a5f336081cce13f26a962725e89fcb29f3bf2a5.zip
logging
-rw-r--r--plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php31
1 files changed, 19 insertions, 12 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 2b6d304..9116baf 100644
--- a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
+++ b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
@@ -250,13 +250,15 @@ function gnutaler_init_gateway_class()
// FIXME: does this one need to be 'public'???
public function callback_handler(): void
{
+ global $woocommerce;
+
if (! isset( $_GET['order_id'] ) )
{
$this->notice ("Lacking 'order_id', forwarding user to neutral page" );
if ( is_user_logged_in() )
- wp_redirect(get_home_url() . '/my-account/orders/');
+ wp_redirect(get_home_url() . wc_get_page_permalink ('myaccount'));
else
- wp_redirect(get_home_url());
+ wp_redirect(get_home_url() . wc_get_page_permalink ('shop'));
exit;
}
@@ -278,6 +280,9 @@ function gnutaler_init_gateway_class()
//Here we check what kind of http code came back from the backend
$merchant_order_status_response = json_decode ($payment_body, $assoc=true);
if (! $merchant_order_status_response ) {
+ wc_add_notice (__('Payment error:', 'woothemes') . 'backend did not respond');
+ wp_redirect($this->get_return_url ($order_id));
+ exit;
}
if ('paid' == $merchant_order_status_response['order_status']) {
notice('Payment succeeded and the user was forwarded to the order confirmed page' );
@@ -285,25 +290,25 @@ function gnutaler_init_gateway_class()
$wc_order->payment_complete();
//Empties the shopping cart
WC()->cart->empty_cart();
- wp_redirect( get_home_url() . '/checkout/order-received/' . $order_id . '/?key=' . $order_id_name );
- exit;
}
else
{
- warning('Payment failed' );
- break;
+ wc_add_notice (__('Payment error:', 'woothemes') . 'backend did not confirm payment');
}
- break;
+ wp_redirect($this->get_return_url ($order_id));
+ exit;
default:
$this->error('An error occurred during the second request to the GNU Taler backend: '
. $payment_http_status . ' - ' . $payment_body );
- notice('Payment failed' );
+ wc_add_notice (__('Payment error:', 'woothemes') . $payment_http_status . ' - ' . $payment_body );
+ wp_redirect($this->get_return_url ($order_id));
break;
} // end 'switch ($payment_http_status)
- if ( is_user_logged_in() )
- wp_redirect(get_home_url() . '/my-account/orders/');
+ $cart_url = $woocommerce->cart->wc_get_cart_url();
+ if ( is_set ($cart_url))
+ wp_redirect(get_home_url() . $cart_url);
else
- wp_redirect(get_home_url());
+ wp_redirect(wc_get_page_permalink ('shop'));
exit;
}
@@ -590,7 +595,9 @@ function gnutaler_init_gateway_class()
// 'strtolower(get_class($this))'!
'fulfillment_url' => get_home_url()
. '/?wc-api='
- . strtolower(get_class($this)),
+ . strtolower(get_class($this))
+ . '&order_id='
+ . $wc_order_id,
'order_id' => $wc_order_id,
'products' => $wc_order_products_array,
'locations' => array( 'delivery_loc' =>