diff options
author | Dominique Hofmann <hofmann.dominique@bluewin.ch> | 2019-06-13 01:54:43 +0200 |
---|---|---|
committer | Dominique Hofmann <hofmann.dominique@bluewin.ch> | 2019-06-13 01:54:43 +0200 |
commit | 5a844be02e9098b1d3c28680b8996ba8a2321b70 (patch) | |
tree | c9f596bb53d0a103c7f9ab6de84fe68cc3968c78 | |
parent | 5a00ff587cab19ed8d0a52c1157dac50748bb04e (diff) | |
download | woocommerce-taler-5a844be02e9098b1d3c28680b8996ba8a2321b70.tar.gz woocommerce-taler-5a844be02e9098b1d3c28680b8996ba8a2321b70.tar.bz2 woocommerce-taler-5a844be02e9098b1d3c28680b8996ba8a2321b70.zip |
Added comments
-rw-r--r-- | src/GNU-taler-payment/class-wc-gnutaler-gateway.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/GNU-taler-payment/class-wc-gnutaler-gateway.php b/src/GNU-taler-payment/class-wc-gnutaler-gateway.php index 04d394f..cbb90b5 100644 --- a/src/GNU-taler-payment/class-wc-gnutaler-gateway.php +++ b/src/GNU-taler-payment/class-wc-gnutaler-gateway.php @@ -193,16 +193,35 @@ function gnutaler_init_gateway_class() ); } + /** + * Callback is called, when the payment succeeds. + * + * Is called on successful payment process. + * User is then being forwarded to the order details page. + * + * @since 0.6.0 + */ + public function callback_handler(): void { + if ( is_user_logged_in() ) + { + $user_id = WC()->customer->get_id(); + } + else + { + $user_id = 'Guest'; + } + if ( isset( $_GET['order_id'] ) ) { + //Gets the order id from the fulfillment url $order_id_backend = $_GET['order_id']; - $order_id_array = explode('-', $order_id_backend); + $order_id_array = explode( '-', $order_id_backend ); $order_id_name = $order_id_array[0]; $order_id = $order_id_array[1]; - $wc_order = wc_get_order($order_id_name); + $wc_order = wc_get_order( $order_id_name ); //Completes the order $wc_order->payment_complete(); @@ -210,7 +229,9 @@ function gnutaler_init_gateway_class() //Empties the shopping cart WC()->cart->empty_cart(); - wp_redirect(get_home_url() . '/checkout/order-received/' . $order_id . '/?key=' . $order_id_name); + $this->add_log_entry('transaction', 'Userid: ' . $user_id . ' - Orderid: ' . $order_id . ' - Payment succeeded and the user was forwarded to the order confirmed page' ); + + wp_redirect( get_home_url() . '/checkout/order-received/' . $order_id . '/?key=' . $order_id_name ); exit; } } |