diff --git a/includes/class-wc-gateway-komoju-block.php b/includes/class-wc-gateway-komoju-block.php index 7b9ada6..047470b 100644 --- a/includes/class-wc-gateway-komoju-block.php +++ b/includes/class-wc-gateway-komoju-block.php @@ -49,6 +49,10 @@ public function get_payment_method_data() return; } + if (is_wc_endpoint_url('order-received')) { + return; + } + // We lazily fetch one session to be shared by all payment methods with dynamic fields. static $checkout_session; if (is_null($checkout_session)) { diff --git a/includes/class-wc-gateway-komoju-ipn-handler.php b/includes/class-wc-gateway-komoju-ipn-handler.php index 5b11074..1fa256f 100644 --- a/includes/class-wc-gateway-komoju-ipn-handler.php +++ b/includes/class-wc-gateway-komoju-ipn-handler.php @@ -221,7 +221,8 @@ protected function payment_status_captured($order, $webhookEvent) if (!empty($webhookEvent->payment_method_fee())) { // log komoju transaction fee - update_post_meta($order->get_id(), 'Payment Gateway Transaction Fee', wc_clean($webhookEvent->payment_method_fee())); + $order->update_meta_data('Payment Gateway Transaction Fee', wc_clean($webhookEvent->payment_method_fee())); + $order->save(); } } else { $this->payment_on_hold($order, sprintf(__('Payment pending: %s', 'komoju-woocommerce'), $webhookEvent->additional_information())); @@ -343,16 +344,17 @@ private function get_session($session_id) protected function save_komoju_meta_data($order, $webhookEvent) { if (!empty($webhookEvent->tax())) { - update_post_meta($order->get_id(), 'Tax', wc_clean($webhookEvent->tax())); + $order->update_meta_data('Tax', wc_clean($webhookEvent->tax())); } if (!empty($webhookEvent->amount())) { - update_post_meta($order->get_id(), 'Amount', wc_clean($webhookEvent->amount())); + $order->update_meta_data('Amount', wc_clean($webhookEvent->amount())); } if (!empty($webhookEvent->additional_information())) { - update_post_meta($order->get_id(), 'Additional info', wc_clean(print_r($webhookEvent->additional_information(), true))); + $order->update_meta_data('Additional info', wc_clean(print_r($webhookEvent->additional_information(), true))); } if (!empty($webhookEvent->uuid())) { - $order->add_meta_data('komoju_payment_id', $webhookEvent->uuid(), true); + $order->update_meta_data('komoju_payment_id', $webhookEvent->uuid(), true); } + $order->save(); } } diff --git a/index.php b/index.php index eb31b07..1cadb14 100755 --- a/index.php +++ b/index.php @@ -1,12 +1,21 @@