• Iara

    (@iara-chan)


    Hello! 🙂

    I believe there may be a compatibility issue between the Komoju WooCommerce plugin and Sequential Order Numbers for WooCommerce plugins: https://wordpress.org/plugins/woocommerce-sequential-order-numbers/

    Environment

    • WordPress: Latest version
    • WooCommerce: Latest version
    • Komoju for WooCommerce
    • Sequential Order Number plugin enabled

    Problem Description

    Our store uses a Sequential Order Number plugin, which generates a custom order number stored in the _order_number meta field.

    When a customer is redirected to Komoju, the payment reference sent to Komoju appears to be the sequential order number (for example, 105432) rather than the internal WooCommerce order ID.

    However, when Komoju receives the payment confirmation and processes the callback/webhook, it appears to attempt to load the WooCommerce order directly using that reference as if it were the internal order ID.

    This causes one of two issues:

    1. The order cannot be found.
    2. A different/older WooCommerce order is updated because its internal ID matches the sequential order number used as the payment reference.

    Example

    • WooCommerce internal order ID: 254781
    • Sequential order number (_order_number): 105432

    Komoju receives reference 105432.

    When the payment is completed, the plugin appears to look for WooCommerce order ID 105432 instead of searching for the order whose _order_number equals 105432.

    As a result, the payment status may be applied to the wrong order.

    Expected Behavior

    If the payment reference sent to Komoju is the sequential order number, the callback should locate the order by that reference (for example using _order_number) and then retrieve the actual WooCommerce order ID before updating the order status.

    Additional Information

    This issue only becomes visible when the sequential order number differs from the WooCommerce internal order ID, which is the normal behavior when using sequential order number plugins.

    Could you please verify whether the callback/webhook logic is using the payment reference directly as the WooCommerce order ID?

    Thank you 😀

Viewing 1 replies (of 1 total)
  • @iara-chan
    Hello. Thank you for sharing this issue.
    I’m facing the same problem.

    発生バージョン: 3.3.2

    同じ症状です。注文番号と内部 ID が異なると、決済完了後に注文を見つけられずサンクスページへ遷移しません。

    原因はセッションのメタデータの woocommerce_order_id に $order->get_order_number() を入れ、それを wc_get_order() に渡していることです。wc_get_order() は内部 ID 検索なので、番号が違うと失敗します。
    メタデータには $order->get_id() を入れる必要があります。

    修正案

    1. metadata は $order->get_id() を入れる

    class-wc-gateway-komoju.php 275-277行目

    'metadata'   => [
    'woocommerce_order_id' => $order->get_order_number(), // 問題のコード
    ],

    'metadata'   => [
    'woocommerce_order_id' => (string) $order->get_id(), // order_id を保存する
    ],

    ※ KOMOJU API が string 型しか受け入れないので、string へのキャストは必須です。

    1. 戻り時の引き当てを内部 ID 基準にする。だめなら既に保存している komoju_session_id で探す

    includes/class-wc-gateway-komoju-response.php 45-47行目

    $order = wc_get_order($session->metadata->woocommerce_order_id);
    if ($order) {
        return $order;

    見つからない場合のフォールバック(57-58行目)も、注文番号を wc_get_order() に渡しています。ここも内部 ID、または komoju_session_id メタ検索に変えてください。

    $order_id = $payment->external_order_num;
    $order    = wc_get_order(substr($order_id, strlen($invoice_prefix), -7));
    1. Webhook 側も同じ

    includes/class-wc-gateway-komoju-response.php 30行目の get_komoju_order() も external_order_num から取り出した注文番号を wc_get_order() に渡しています。こちらも内部 ID / komoju_session_id に揃えてください。

    if (!$order = wc_get_order(substr($order_id, strlen($invoice_prefix), -7))) {

    便利な決済サービスですので、ぜひご対応いただけますと幸いです。

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.