From cddc43ba14e27fdcbaad0bdf09010b065870151d Mon Sep 17 00:00:00 2001 From: Yahya Fakhroji Date: Tue, 29 Oct 2024 16:37:20 +0700 Subject: [PATCH] Fix Order Callback --- class/class-mpwp-gateway.php | 12 +++++++++--- muggle-pay.php | 10 +++++----- readme.txt | 8 +++++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/class/class-mpwp-gateway.php b/class/class-mpwp-gateway.php index 94ad2af..89e18b3 100644 --- a/class/class-mpwp-gateway.php +++ b/class/class-mpwp-gateway.php @@ -123,9 +123,15 @@ public function __construct() self::$log_enabled = $this->debug; + // Setup callback URL + $this->callback_url = WC()->api_request_url($this->id); + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' )); - add_action('woocommerce_api_wc_gateway_mpwp', array( $this, 'check_response' )); + // add_action('woocommerce_api_wc_gateway_mpwp', array( $this, 'check_response' )); add_filter('woocommerce_order_data_store_cpt_get_orders_query', array( $this, 'custom_query_var' ), 10, 2); + add_action('woocommerce_api_' . $this->id, array($this, 'check_response')); + + // add_action('woocommerce_cancelled_order', array( $this, 'cancel_order' ), 10 ,1); // add_action( 'woocommerce_order_status_processing', array( $this, 'capture_payment' ) ); // add_action( 'woocommerce_order_status_completed', array( $this, 'capture_payment' ) ); @@ -442,7 +448,7 @@ public function get_payment_url($order, $pay_currency) // Translators: %s is the order ID. 'title' => sprintf(__('Payment order #%s', 'mugglepay'), $order->get_id()), 'description' => $description, - 'callback_url' => WC()->api_request_url('MPWP_WC_Gateway'), + 'callback_url' => $this->callback_url, 'cancel_url' => esc_url_raw($order->get_cancel_order_url_raw()), 'success_url' => esc_url_raw($this->get_return_url($order)), 'mobile' => wp_is_mobile(), @@ -690,4 +696,4 @@ public function custom_query_var($query, $query_vars) return $query; } -} +} \ No newline at end of file diff --git a/muggle-pay.php b/muggle-pay.php index 056744e..7dc9ecd 100644 --- a/muggle-pay.php +++ b/muggle-pay.php @@ -8,7 +8,7 @@ Plugin Name: MugglePay Plugin URI: https://mugglepay.com/ Description: MugglePay is a one-stop payment solution for merchants with an online payment need. -Version: 1.0.2 +Version: 1.0.4 Author: Shawn Author URI: https://x.com/shawnmuggle Text Domain: mugglepay @@ -123,12 +123,12 @@ function mpwp_order_meta_general($order)

-

- + get_transaction_id() ) ); ?> -

+