Skip to content

Commit

Permalink
Update compatibility for WooCommerce
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinwy committed Jul 17, 2024
1 parent 28b8e3c commit 9c2261e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
4 changes: 4 additions & 0 deletions includes/class-wc-gateway-komoju-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
12 changes: 7 additions & 5 deletions includes/class-wc-gateway-komoju-ipn-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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();
}
}
23 changes: 16 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<?php
/*
Plugin Name: KOMOJU Payments
Plugin URI: https://github.com/komoju/komoju-woocommerce
Description: Extends WooCommerce with KOMOJU gateway.
Version: 3.1.3
Author: KOMOJU
Author URI: https://komoju.com
*/
* Plugin Name: KOMOJU Payments
* Plugin URI: https://github.com/komoju/komoju-woocommerce
* Description: Extends WooCommerce with KOMOJU gateway.
* Author: KOMOJU
* Author URI: https://komoju.com
* Version: 3.1.3
* WC requires at least: 6.0
* WC tested up to: 8.8.3
*/

add_action('before_woocommerce_init', function () {
if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('cart_checkout_blocks', __FILE__, true);
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
}
});

add_action('plugins_loaded', 'woocommerce_komoju_init', 0);

Expand Down

0 comments on commit 9c2261e

Please sign in to comment.