Plugin Directory

Changeset 3846711


Ignore:
Timestamp:
12/05/2026 06:41:29 PM (4 hours ago)
Author:
devlusion
Message:

Update to version 1.0.1 from GitHub

Location:
omni-cod-return-risk-shield-for-woocommerce
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • omni-cod-return-risk-shield-for-woocommerce/tags/1.0.1/includes/class-omni-api-client.php

    r3846673 r3846711  
    1414    }
    1515
     16    public static function allows_custom_api_url(): bool {
     17        return defined('OMNI_ALLOW_CUSTOM_API_URL') && OMNI_ALLOW_CUSTOM_API_URL;
     18    }
     19
    1620    public static function get_api_url(): string {
    17         $raw = trim((string) get_option('omni_api_url', 'https://api.omni.devlusion.com'));
    18         return rtrim($raw ?: 'https://api.omni.devlusion.com', '/');
     21        $prod = defined('OMNI_PROD_API_URL') ? OMNI_PROD_API_URL : 'https://api.omni.devlusion.com';
     22        if (!self::allows_custom_api_url()) {
     23            return rtrim($prod, '/');
     24        }
     25        $raw = trim((string) get_option('omni_api_url', $prod));
     26        return rtrim($raw ?: $prod, '/');
    1927    }
    2028
    … …  
    2735
    2836    /**
    29      * Returns true only after the store administrator has explicitly opted in
    30      * (via "Activate Free COD Shield") or manually saved a Merchant ID and API Key.
     37     * Returns true once the store administrator has explicitly opted in
     38     * (via "Activate Free COD Shield", which provisions a site-bound shop token)
     39     * or manually saved an active API key. Merchant ID (MCH-*) is optional for
     40     * zero-account out-of-the-box stores and only required when linking to a
     41     * Merchant Portal account.
    3142     */
    3243    public static function is_connected(): bool {
    33         $merchant_id = trim((string) get_option('omni_merchant_id', ''));
    34         return $merchant_id !== '' && self::get_active_key() !== '';
     44        return self::get_active_key() !== '';
    3545    }
    3646
    … …  
    3848        $key = self::get_active_key();
    3949        $merchant_id = trim((string) get_option('omni_merchant_id', ''));
    40         if (empty($merchant_id)) {
    41             return new WP_Error('omni_missing_merchant_id', 'Please enter your Omni Merchant ID (e.g. MCH-2026-XXXXXX) in WooCommerce -> Settings -> Omni by Devlusion.');
     50        if (empty($key)) {
     51            return new WP_Error('omni_missing_key', 'Please click "Activate Free COD Shield (Opt-In)" or enter your Omni API Key in WooCommerce -> Settings -> Omni by Devlusion.');
    4252        }
    43         if (empty($key)) {
    44             return new WP_Error('omni_missing_key', 'Please enter your Omni API Key in WooCommerce -> Settings -> Omni by Devlusion.');
     53
     54        $headers = [
     55            'Content-Type'    => 'application/json',
     56            'Authorization'   => 'Bearer ' . $key,
     57            'X-Omni-Store-ID' => trim((string) get_option('omni_store_id', '')),
     58            'X-Omni-Site-URL' => home_url(),
     59            'X-Omni-Mode'     => self::get_mode(),
     60        ];
     61        if ($merchant_id !== '') {
     62            $headers['X-Omni-Merchant-ID'] = $merchant_id;
    4563        }
    4664
    4765        $response = wp_remote_post(self::get_api_url() . $path, [
    4866            'timeout' => 10,
    49             'headers' => [
    50                 'Content-Type'       => 'application/json',
    51                 'Authorization'      => 'Bearer ' . $key,
    52                 'X-Omni-Merchant-ID' => $merchant_id,
    53                 'X-Omni-Store-ID'    => trim((string) get_option('omni_store_id', '')),
    54                 'X-Omni-Site-URL'    => home_url(),
    55                 'X-Omni-Mode'        => self::get_mode(),
    56             ],
    57             'body' => wp_json_encode($body),
     67            'headers' => $headers,
     68            'body'    => wp_json_encode($body),
    5869        ]);
    5970
    … …  
    7485        $key = self::get_active_key();
    7586        $merchant_id = trim((string) get_option('omni_merchant_id', ''));
    76         if (empty($merchant_id) || empty($key)) {
    77             return new WP_Error('omni_missing_creds', 'Please configure Merchant ID and API Key in WooCommerce -> Settings -> Omni by Devlusion.');
     87        if (empty($key)) {
     88            return new WP_Error('omni_missing_creds', 'Please click "Activate Free COD Shield (Opt-In)" or configure your API Key in WooCommerce -> Settings -> Omni by Devlusion.');
    7889        }
     90
     91        $headers = [
     92            'Authorization'   => 'Bearer ' . $key,
     93            'X-Omni-Store-ID' => trim((string) get_option('omni_store_id', '')),
     94            'X-Omni-Site-URL' => home_url(),
     95            'X-Omni-Mode'     => self::get_mode(),
     96        ];
     97        if ($merchant_id !== '') {
     98            $headers['X-Omni-Merchant-ID'] = $merchant_id;
     99        }
     100
    79101        $response = wp_remote_get(self::get_api_url() . $path, [
    80102            'timeout' => 10,
    81             'headers' => [
    82                 'Authorization'      => 'Bearer ' . $key,
    83                 'X-Omni-Merchant-ID' => $merchant_id,
    84                 'X-Omni-Store-ID'    => trim((string) get_option('omni_store_id', '')),
    85                 'X-Omni-Site-URL'    => home_url(),
    86                 'X-Omni-Mode'        => self::get_mode(),
    87             ],
     103            'headers' => $headers,
    88104        ]);
    89105        if (is_wp_error($response)) {
  • omni-cod-return-risk-shield-for-woocommerce/tags/1.0.1/includes/class-omni-settings.php

    r3846673 r3846711  
    2121
    2222    public static function get_fields(): array {
    23         return [
     23        $fields = [
    2424            [
    2525                'name' => __('Omni by Devlusion — Store Connection & License', 'omni-cod-return-risk-shield-for-woocommerce'),
    2626                'type' => 'title',
    27                 'desc' => __('Connect your WooCommerce store using your Store Instance ID and API Keys from your Omni Dashboard. Use Staging / Simulation Mode for localhost testing.', 'omni-cod-return-risk-shield-for-woocommerce'),
     27                'desc' => __('Connect your WooCommerce store using 1-click Opt-In above or your API Keys from your Omni Dashboard. Use Staging / Simulation Mode for localhost testing.', 'omni-cod-return-risk-shield-for-woocommerce'),
    2828                'id'   => 'omni_section_title',
    2929            ],
    … …  
    3838                ],
    3939            ],
    40             [
    41                 'name'    => __('Omni API Endpoint URL', 'omni-cod-return-risk-shield-for-woocommerce'),
     40        ];
     41
     42        // Only expose custom API Endpoint URL in UAT/DEV builds (OMNI_ALLOW_CUSTOM_API_URL = true).
     43        // Production WordPress.org builds are locked to https://api.omni.devlusion.com.
     44        if (Omni_API_Client::allows_custom_api_url()) {
     45            $fields[] = [
     46                'name'    => __('Omni API Endpoint URL (Dev / UAT)', 'omni-cod-return-risk-shield-for-woocommerce'),
    4247                'type'    => 'text',
    4348                'id'      => 'omni_api_url',
    44                 'default' => 'https://api.omni.devlusion.com',
    45                 'desc'    => __('Use https://api.omni.devlusion.com in production, or http://localhost:8081 when developing locally.', 'omni-cod-return-risk-shield-for-woocommerce'),
    46             ],
    47             [
    48                 'name' => __('Merchant ID (MCH-*)', 'omni-cod-return-risk-shield-for-woocommerce'),
    49                 'type' => 'text',
    50                 'id'   => 'omni_merchant_id',
    51                 'desc' => __('Copy your Merchant ID (e.g. MCH-2026-XXXXXX) from your Omni Dashboard Key Manager or Account tab.', 'omni-cod-return-risk-shield-for-woocommerce'),
    52             ],
    53             [
    54                 'name' => __('Store Instance ID', 'omni-cod-return-risk-shield-for-woocommerce'),
    55                 'type' => 'text',
    56                 'id'   => 'omni_store_id',
    57                 'desc' => __('The UUID of this specific store instance in your Omni Dashboard.', 'omni-cod-return-risk-shield-for-woocommerce'),
    58             ],
    59             [
    60                 'name' => __('Live API Key (omni_live_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
    61                 'type' => 'password',
    62                 'id'   => 'omni_live_api_key',
    63                 'desc' => __('Only issued once your Live HTTPS domain is saved in Omni Key Manager.', 'omni-cod-return-risk-shield-for-woocommerce'),
    64             ],
    65             [
    66                 'name' => __('Staging / Simulation API Key (omni_test_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
    67                 'type' => 'password',
    68                 'id'   => 'omni_staging_api_key',
    69                 'desc' => __('Works with localhost, .local WordPress domains, LAN IPs, or staging subdomains.', 'omni-cod-return-risk-shield-for-woocommerce'),
    70             ],
    71             [
    72                 'name' => __('Webhook Signing Secret', 'omni-cod-return-risk-shield-for-woocommerce'),
    73                 'type' => 'password',
    74                 'id'   => 'omni_webhook_secret',
    75             ],
    76             [
    77                 'type' => 'sectionend',
    78                 'id'   => 'omni_section_end',
    79             ],
    80         ];
     49                'default' => defined('OMNI_PROD_API_URL') ? OMNI_PROD_API_URL : 'https://api.omni.devlusion.com',
     50                'desc'    => __('UAT/DEV only: e.g. https://uat.api.omni.devlusion.com or http://localhost:8081.', 'omni-cod-return-risk-shield-for-woocommerce'),
     51            ];
     52        }
     53
     54        $fields[] = [
     55            'name' => __('Merchant ID (MCH-*, Optional)', 'omni-cod-return-risk-shield-for-woocommerce'),
     56            'type' => 'text',
     57            'id'   => 'omni_merchant_id',
     58            'desc' => __('Optional for 1-click Free Opt-In. Only needed if you linked this store to an Omni Merchant Portal account.', 'omni-cod-return-risk-shield-for-woocommerce'),
     59        ];
     60        $fields[] = [
     61            'name' => __('Store Instance ID', 'omni-cod-return-risk-shield-for-woocommerce'),
     62            'type' => 'text',
     63            'id'   => 'omni_store_id',
     64            'desc' => __('The UUID of this specific store instance in Omni (auto-filled on Opt-In).', 'omni-cod-return-risk-shield-for-woocommerce'),
     65        ];
     66        $fields[] = [
     67            'name' => __('Live API Key (omni_live_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
     68            'type' => 'password',
     69            'id'   => 'omni_live_api_key',
     70            'desc' => __('Auto-filled on Opt-In, or issued once your Live HTTPS domain is saved in Omni Key Manager.', 'omni-cod-return-risk-shield-for-woocommerce'),
     71        ];
     72        $fields[] = [
     73            'name' => __('Staging / Simulation API Key (omni_test_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
     74            'type' => 'password',
     75            'id'   => 'omni_staging_api_key',
     76            'desc' => __('Works with localhost, .local WordPress domains, LAN IPs, or staging subdomains.', 'omni-cod-return-risk-shield-for-woocommerce'),
     77        ];
     78        $fields[] = [
     79            'name' => __('Webhook Signing Secret', 'omni-cod-return-risk-shield-for-woocommerce'),
     80            'type' => 'password',
     81            'id'   => 'omni_webhook_secret',
     82        ];
     83        $fields[] = [
     84            'type' => 'sectionend',
     85            'id'   => 'omni_section_end',
     86        ];
     87
     88        return $fields;
    8189    }
    8290
    8391    public static function render_settings(): void {
     92        $notice_key = 'omni_activate_notice_' . get_current_user_id();
     93        $act_notice = get_transient($notice_key);
     94        if (is_array($act_notice) && !empty($act_notice['message'])) {
     95            delete_transient($notice_key);
     96            $cls = !empty($act_notice['success']) ? 'notice-success' : 'notice-error';
     97            echo '<div class="notice ' . esc_attr($cls) . ' is-dismissible"><p>' . esc_html((string) $act_notice['message']) . '</p></div>';
     98        }
     99
    84100        // Guideline #7 & #11 compliant: never contact external servers or display
    85101        // promotional banners before explicit administrator opt-in.
    … …  
    90106            echo '<p style="margin:0 0 12px;font-size:12px;color:#475569;">' . esc_html__('No external requests are made until you opt in. Click below to provision a free store token (transmits your site URL and store name to api.omni.devlusion.com), or enter existing keys below.', 'omni-cod-return-risk-shield-for-woocommerce') . '</p>';
    91107            echo '<a href="' . esc_url($activate_url) . '" class="button button-primary">' . esc_html__('Activate Free COD Shield (Opt-In)', 'omni-cod-return-risk-shield-for-woocommerce') . '</a>';
     108            echo '</div>';
     109        } else {
     110            $analytics_url = admin_url('admin.php?page=omni-cod-shield');
     111            $mode_label    = Omni_API_Client::get_mode() === 'LIVE' ? __('Live Production Mode', 'omni-cod-return-risk-shield-for-woocommerce') : __('Staging / Simulation Mode', 'omni-cod-return-risk-shield-for-woocommerce');
     112            echo '<div style="margin:12px 0 16px;padding:12px 16px;background:#f0fdf4;border:1px solid #bbf7d0;border-radius:10px;max-width:760px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;">';
     113            echo '<div style="font-size:13px;color:#166534;"><strong>&#10003; ' . esc_html__('Omni COD Return Risk Shield Connected', 'omni-cod-return-risk-shield-for-woocommerce') . '</strong> &middot; ' . esc_html($mode_label) . '</div>';
     114            echo '<a href="' . esc_url($analytics_url) . '" class="button button-secondary">' . esc_html__('View Omni Shield Analytics', 'omni-cod-return-risk-shield-for-woocommerce') . '</a>';
    92115            echo '</div>';
    93116        }
  • omni-cod-return-risk-shield-for-woocommerce/tags/1.0.1/readme.txt

    r3846673 r3846711  
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5454== Changelog ==
    5555
     56= 1.0.1 =
     57* Fix: Opt-In banner now hides immediately after clicking "Activate Free COD Shield (Opt-In)" and displays a Connected status bar with activation confirmation.
     58* Fix: Zero-account Opt-In stores now authenticate API calls and analytics using their site-bound shop token without requiring a Merchant Portal ID.
     59* Improvement: Production WordPress.org builds now lock directly to https://api.omni.devlusion.com and hide the Omni API Endpoint URL input from merchant settings (custom endpoint URL remains available for UAT/DEV via OMNI_ALLOW_CUSTOM_API_URL).
     60
    5661= 1.0.0 =
    5762* Initial public release with HPOS full-width Risk of Return banner, universal Sri Lankan & international phone normalization, 8 Fault-Aware Return Reasons, Omni Shield Analytics menu, and Live/Staging Simulator modes.
  • omni-cod-return-risk-shield-for-woocommerce/tags/1.0.1/woocommerce-omni.php

    r3846673 r3846711  
    44 * Plugin URI:        https://omni.devlusion.com
    55 * Description:       Sri Lanka & International COD Return Risk Assessment for WooCommerce. Shows Risk of Return & Returns Frequency above every order and in the All Orders table, with fault-aware Mark as Returned reasons.
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Author:            Devlusion (Pvt) Ltd
    88 * Author URI:        https://devlusion.com
    … …  
    2121
    2222if (!defined('OMNI_PLUGIN_VERSION')) {
    23     define('OMNI_PLUGIN_VERSION', '1.0.0');
     23    define('OMNI_PLUGIN_VERSION', '1.0.1');
     24}
     25if (!defined('OMNI_PROD_API_URL')) {
     26    define('OMNI_PROD_API_URL', 'https://api.omni.devlusion.com');
     27}
     28if (!defined('OMNI_ALLOW_CUSTOM_API_URL')) {
     29    define('OMNI_ALLOW_CUSTOM_API_URL', false);
    2430}
    2531
    … …  
    3844        return ['success' => true, 'message' => __('Omni COD Shield is already connected.', 'omni-cod-return-risk-shield-for-woocommerce')];
    3945    }
    40     $apiUrl = rtrim((string) get_option('omni_api_url', 'https://api.omni.devlusion.com'), '/');
    41     if ($apiUrl === '') {
    42         $apiUrl = 'https://api.omni.devlusion.com';
    43     }
     46    $apiUrl = Omni_API_Client::get_api_url();
    4447    $resp = wp_remote_post($apiUrl . '/v1/plugin/auto-provision', [
    4548        'timeout' => 10,
    … …  
    5659    $data = json_decode(wp_remote_retrieve_body($resp), true);
    5760    if (!empty($data['success']) && !empty($data['shop_token'])) {
    58         update_option('omni_api_url', esc_url_raw($apiUrl));
     61        if (Omni_API_Client::allows_custom_api_url()) {
     62            update_option('omni_api_url', esc_url_raw($apiUrl));
     63        }
    5964        update_option('omni_live_api_key', sanitize_text_field((string) $data['shop_token']));
    6065        update_option('omni_staging_api_key', sanitize_text_field((string) ($data['staging_token'] ?? '')));
    … …  
    193198    }
    194199    if (isset($_GET['omni_activate_free'], $_GET['_wpnonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wpnonce'])), 'omni_admin_action')) {
    195         omni_auto_provision_shop();
     200        $res = omni_auto_provision_shop();
     201        set_transient('omni_activate_notice_' . get_current_user_id(), $res, 60);
    196202        wp_safe_redirect(remove_query_arg(['omni_activate_free', '_wpnonce']));
    197203        exit;
  • omni-cod-return-risk-shield-for-woocommerce/trunk/includes/class-omni-api-client.php

    r3846673 r3846711  
    1414    }
    1515
     16    public static function allows_custom_api_url(): bool {
     17        return defined('OMNI_ALLOW_CUSTOM_API_URL') && OMNI_ALLOW_CUSTOM_API_URL;
     18    }
     19
    1620    public static function get_api_url(): string {
    17         $raw = trim((string) get_option('omni_api_url', 'https://api.omni.devlusion.com'));
    18         return rtrim($raw ?: 'https://api.omni.devlusion.com', '/');
     21        $prod = defined('OMNI_PROD_API_URL') ? OMNI_PROD_API_URL : 'https://api.omni.devlusion.com';
     22        if (!self::allows_custom_api_url()) {
     23            return rtrim($prod, '/');
     24        }
     25        $raw = trim((string) get_option('omni_api_url', $prod));
     26        return rtrim($raw ?: $prod, '/');
    1927    }
    2028
    … …  
    2735
    2836    /**
    29      * Returns true only after the store administrator has explicitly opted in
    30      * (via "Activate Free COD Shield") or manually saved a Merchant ID and API Key.
     37     * Returns true once the store administrator has explicitly opted in
     38     * (via "Activate Free COD Shield", which provisions a site-bound shop token)
     39     * or manually saved an active API key. Merchant ID (MCH-*) is optional for
     40     * zero-account out-of-the-box stores and only required when linking to a
     41     * Merchant Portal account.
    3142     */
    3243    public static function is_connected(): bool {
    33         $merchant_id = trim((string) get_option('omni_merchant_id', ''));
    34         return $merchant_id !== '' && self::get_active_key() !== '';
     44        return self::get_active_key() !== '';
    3545    }
    3646
    … …  
    3848        $key = self::get_active_key();
    3949        $merchant_id = trim((string) get_option('omni_merchant_id', ''));
    40         if (empty($merchant_id)) {
    41             return new WP_Error('omni_missing_merchant_id', 'Please enter your Omni Merchant ID (e.g. MCH-2026-XXXXXX) in WooCommerce -> Settings -> Omni by Devlusion.');
     50        if (empty($key)) {
     51            return new WP_Error('omni_missing_key', 'Please click "Activate Free COD Shield (Opt-In)" or enter your Omni API Key in WooCommerce -> Settings -> Omni by Devlusion.');
    4252        }
    43         if (empty($key)) {
    44             return new WP_Error('omni_missing_key', 'Please enter your Omni API Key in WooCommerce -> Settings -> Omni by Devlusion.');
     53
     54        $headers = [
     55            'Content-Type'    => 'application/json',
     56            'Authorization'   => 'Bearer ' . $key,
     57            'X-Omni-Store-ID' => trim((string) get_option('omni_store_id', '')),
     58            'X-Omni-Site-URL' => home_url(),
     59            'X-Omni-Mode'     => self::get_mode(),
     60        ];
     61        if ($merchant_id !== '') {
     62            $headers['X-Omni-Merchant-ID'] = $merchant_id;
    4563        }
    4664
    4765        $response = wp_remote_post(self::get_api_url() . $path, [
    4866            'timeout' => 10,
    49             'headers' => [
    50                 'Content-Type'       => 'application/json',
    51                 'Authorization'      => 'Bearer ' . $key,
    52                 'X-Omni-Merchant-ID' => $merchant_id,
    53                 'X-Omni-Store-ID'    => trim((string) get_option('omni_store_id', '')),
    54                 'X-Omni-Site-URL'    => home_url(),
    55                 'X-Omni-Mode'        => self::get_mode(),
    56             ],
    57             'body' => wp_json_encode($body),
     67            'headers' => $headers,
     68            'body'    => wp_json_encode($body),
    5869        ]);
    5970
    … …  
    7485        $key = self::get_active_key();
    7586        $merchant_id = trim((string) get_option('omni_merchant_id', ''));
    76         if (empty($merchant_id) || empty($key)) {
    77             return new WP_Error('omni_missing_creds', 'Please configure Merchant ID and API Key in WooCommerce -> Settings -> Omni by Devlusion.');
     87        if (empty($key)) {
     88            return new WP_Error('omni_missing_creds', 'Please click "Activate Free COD Shield (Opt-In)" or configure your API Key in WooCommerce -> Settings -> Omni by Devlusion.');
    7889        }
     90
     91        $headers = [
     92            'Authorization'   => 'Bearer ' . $key,
     93            'X-Omni-Store-ID' => trim((string) get_option('omni_store_id', '')),
     94            'X-Omni-Site-URL' => home_url(),
     95            'X-Omni-Mode'     => self::get_mode(),
     96        ];
     97        if ($merchant_id !== '') {
     98            $headers['X-Omni-Merchant-ID'] = $merchant_id;
     99        }
     100
    79101        $response = wp_remote_get(self::get_api_url() . $path, [
    80102            'timeout' => 10,
    81             'headers' => [
    82                 'Authorization'      => 'Bearer ' . $key,
    83                 'X-Omni-Merchant-ID' => $merchant_id,
    84                 'X-Omni-Store-ID'    => trim((string) get_option('omni_store_id', '')),
    85                 'X-Omni-Site-URL'    => home_url(),
    86                 'X-Omni-Mode'        => self::get_mode(),
    87             ],
     103            'headers' => $headers,
    88104        ]);
    89105        if (is_wp_error($response)) {
  • omni-cod-return-risk-shield-for-woocommerce/trunk/includes/class-omni-settings.php

    r3846673 r3846711  
    2121
    2222    public static function get_fields(): array {
    23         return [
     23        $fields = [
    2424            [
    2525                'name' => __('Omni by Devlusion — Store Connection & License', 'omni-cod-return-risk-shield-for-woocommerce'),
    2626                'type' => 'title',
    27                 'desc' => __('Connect your WooCommerce store using your Store Instance ID and API Keys from your Omni Dashboard. Use Staging / Simulation Mode for localhost testing.', 'omni-cod-return-risk-shield-for-woocommerce'),
     27                'desc' => __('Connect your WooCommerce store using 1-click Opt-In above or your API Keys from your Omni Dashboard. Use Staging / Simulation Mode for localhost testing.', 'omni-cod-return-risk-shield-for-woocommerce'),
    2828                'id'   => 'omni_section_title',
    2929            ],
    … …  
    3838                ],
    3939            ],
    40             [
    41                 'name'    => __('Omni API Endpoint URL', 'omni-cod-return-risk-shield-for-woocommerce'),
     40        ];
     41
     42        // Only expose custom API Endpoint URL in UAT/DEV builds (OMNI_ALLOW_CUSTOM_API_URL = true).
     43        // Production WordPress.org builds are locked to https://api.omni.devlusion.com.
     44        if (Omni_API_Client::allows_custom_api_url()) {
     45            $fields[] = [
     46                'name'    => __('Omni API Endpoint URL (Dev / UAT)', 'omni-cod-return-risk-shield-for-woocommerce'),
    4247                'type'    => 'text',
    4348                'id'      => 'omni_api_url',
    44                 'default' => 'https://api.omni.devlusion.com',
    45                 'desc'    => __('Use https://api.omni.devlusion.com in production, or http://localhost:8081 when developing locally.', 'omni-cod-return-risk-shield-for-woocommerce'),
    46             ],
    47             [
    48                 'name' => __('Merchant ID (MCH-*)', 'omni-cod-return-risk-shield-for-woocommerce'),
    49                 'type' => 'text',
    50                 'id'   => 'omni_merchant_id',
    51                 'desc' => __('Copy your Merchant ID (e.g. MCH-2026-XXXXXX) from your Omni Dashboard Key Manager or Account tab.', 'omni-cod-return-risk-shield-for-woocommerce'),
    52             ],
    53             [
    54                 'name' => __('Store Instance ID', 'omni-cod-return-risk-shield-for-woocommerce'),
    55                 'type' => 'text',
    56                 'id'   => 'omni_store_id',
    57                 'desc' => __('The UUID of this specific store instance in your Omni Dashboard.', 'omni-cod-return-risk-shield-for-woocommerce'),
    58             ],
    59             [
    60                 'name' => __('Live API Key (omni_live_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
    61                 'type' => 'password',
    62                 'id'   => 'omni_live_api_key',
    63                 'desc' => __('Only issued once your Live HTTPS domain is saved in Omni Key Manager.', 'omni-cod-return-risk-shield-for-woocommerce'),
    64             ],
    65             [
    66                 'name' => __('Staging / Simulation API Key (omni_test_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
    67                 'type' => 'password',
    68                 'id'   => 'omni_staging_api_key',
    69                 'desc' => __('Works with localhost, .local WordPress domains, LAN IPs, or staging subdomains.', 'omni-cod-return-risk-shield-for-woocommerce'),
    70             ],
    71             [
    72                 'name' => __('Webhook Signing Secret', 'omni-cod-return-risk-shield-for-woocommerce'),
    73                 'type' => 'password',
    74                 'id'   => 'omni_webhook_secret',
    75             ],
    76             [
    77                 'type' => 'sectionend',
    78                 'id'   => 'omni_section_end',
    79             ],
    80         ];
     49                'default' => defined('OMNI_PROD_API_URL') ? OMNI_PROD_API_URL : 'https://api.omni.devlusion.com',
     50                'desc'    => __('UAT/DEV only: e.g. https://uat.api.omni.devlusion.com or http://localhost:8081.', 'omni-cod-return-risk-shield-for-woocommerce'),
     51            ];
     52        }
     53
     54        $fields[] = [
     55            'name' => __('Merchant ID (MCH-*, Optional)', 'omni-cod-return-risk-shield-for-woocommerce'),
     56            'type' => 'text',
     57            'id'   => 'omni_merchant_id',
     58            'desc' => __('Optional for 1-click Free Opt-In. Only needed if you linked this store to an Omni Merchant Portal account.', 'omni-cod-return-risk-shield-for-woocommerce'),
     59        ];
     60        $fields[] = [
     61            'name' => __('Store Instance ID', 'omni-cod-return-risk-shield-for-woocommerce'),
     62            'type' => 'text',
     63            'id'   => 'omni_store_id',
     64            'desc' => __('The UUID of this specific store instance in Omni (auto-filled on Opt-In).', 'omni-cod-return-risk-shield-for-woocommerce'),
     65        ];
     66        $fields[] = [
     67            'name' => __('Live API Key (omni_live_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
     68            'type' => 'password',
     69            'id'   => 'omni_live_api_key',
     70            'desc' => __('Auto-filled on Opt-In, or issued once your Live HTTPS domain is saved in Omni Key Manager.', 'omni-cod-return-risk-shield-for-woocommerce'),
     71        ];
     72        $fields[] = [
     73            'name' => __('Staging / Simulation API Key (omni_test_*)', 'omni-cod-return-risk-shield-for-woocommerce'),
     74            'type' => 'password',
     75            'id'   => 'omni_staging_api_key',
     76            'desc' => __('Works with localhost, .local WordPress domains, LAN IPs, or staging subdomains.', 'omni-cod-return-risk-shield-for-woocommerce'),
     77        ];
     78        $fields[] = [
     79            'name' => __('Webhook Signing Secret', 'omni-cod-return-risk-shield-for-woocommerce'),
     80            'type' => 'password',
     81            'id'   => 'omni_webhook_secret',
     82        ];
     83        $fields[] = [
     84            'type' => 'sectionend',
     85            'id'   => 'omni_section_end',
     86        ];
     87
     88        return $fields;
    8189    }
    8290
    8391    public static function render_settings(): void {
     92        $notice_key = 'omni_activate_notice_' . get_current_user_id();
     93        $act_notice = get_transient($notice_key);
     94        if (is_array($act_notice) && !empty($act_notice['message'])) {
     95            delete_transient($notice_key);
     96            $cls = !empty($act_notice['success']) ? 'notice-success' : 'notice-error';
     97            echo '<div class="notice ' . esc_attr($cls) . ' is-dismissible"><p>' . esc_html((string) $act_notice['message']) . '</p></div>';
     98        }
     99
    84100        // Guideline #7 & #11 compliant: never contact external servers or display
    85101        // promotional banners before explicit administrator opt-in.
    … …  
    90106            echo '<p style="margin:0 0 12px;font-size:12px;color:#475569;">' . esc_html__('No external requests are made until you opt in. Click below to provision a free store token (transmits your site URL and store name to api.omni.devlusion.com), or enter existing keys below.', 'omni-cod-return-risk-shield-for-woocommerce') . '</p>';
    91107            echo '<a href="' . esc_url($activate_url) . '" class="button button-primary">' . esc_html__('Activate Free COD Shield (Opt-In)', 'omni-cod-return-risk-shield-for-woocommerce') . '</a>';
     108            echo '</div>';
     109        } else {
     110            $analytics_url = admin_url('admin.php?page=omni-cod-shield');
     111            $mode_label    = Omni_API_Client::get_mode() === 'LIVE' ? __('Live Production Mode', 'omni-cod-return-risk-shield-for-woocommerce') : __('Staging / Simulation Mode', 'omni-cod-return-risk-shield-for-woocommerce');
     112            echo '<div style="margin:12px 0 16px;padding:12px 16px;background:#f0fdf4;border:1px solid #bbf7d0;border-radius:10px;max-width:760px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;">';
     113            echo '<div style="font-size:13px;color:#166534;"><strong>&#10003; ' . esc_html__('Omni COD Return Risk Shield Connected', 'omni-cod-return-risk-shield-for-woocommerce') . '</strong> &middot; ' . esc_html($mode_label) . '</div>';
     114            echo '<a href="' . esc_url($analytics_url) . '" class="button button-secondary">' . esc_html__('View Omni Shield Analytics', 'omni-cod-return-risk-shield-for-woocommerce') . '</a>';
    92115            echo '</div>';
    93116        }
  • omni-cod-return-risk-shield-for-woocommerce/trunk/readme.txt

    r3846673 r3846711  
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    5454== Changelog ==
    5555
     56= 1.0.1 =
     57* Fix: Opt-In banner now hides immediately after clicking "Activate Free COD Shield (Opt-In)" and displays a Connected status bar with activation confirmation.
     58* Fix: Zero-account Opt-In stores now authenticate API calls and analytics using their site-bound shop token without requiring a Merchant Portal ID.
     59* Improvement: Production WordPress.org builds now lock directly to https://api.omni.devlusion.com and hide the Omni API Endpoint URL input from merchant settings (custom endpoint URL remains available for UAT/DEV via OMNI_ALLOW_CUSTOM_API_URL).
     60
    5661= 1.0.0 =
    5762* Initial public release with HPOS full-width Risk of Return banner, universal Sri Lankan & international phone normalization, 8 Fault-Aware Return Reasons, Omni Shield Analytics menu, and Live/Staging Simulator modes.
  • omni-cod-return-risk-shield-for-woocommerce/trunk/woocommerce-omni.php

    r3846673 r3846711  
    44 * Plugin URI:        https://omni.devlusion.com
    55 * Description:       Sri Lanka & International COD Return Risk Assessment for WooCommerce. Shows Risk of Return & Returns Frequency above every order and in the All Orders table, with fault-aware Mark as Returned reasons.
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Author:            Devlusion (Pvt) Ltd
    88 * Author URI:        https://devlusion.com
    … …  
    2121
    2222if (!defined('OMNI_PLUGIN_VERSION')) {
    23     define('OMNI_PLUGIN_VERSION', '1.0.0');
     23    define('OMNI_PLUGIN_VERSION', '1.0.1');
     24}
     25if (!defined('OMNI_PROD_API_URL')) {
     26    define('OMNI_PROD_API_URL', 'https://api.omni.devlusion.com');
     27}
     28if (!defined('OMNI_ALLOW_CUSTOM_API_URL')) {
     29    define('OMNI_ALLOW_CUSTOM_API_URL', false);
    2430}
    2531
    … …  
    3844        return ['success' => true, 'message' => __('Omni COD Shield is already connected.', 'omni-cod-return-risk-shield-for-woocommerce')];
    3945    }
    40     $apiUrl = rtrim((string) get_option('omni_api_url', 'https://api.omni.devlusion.com'), '/');
    41     if ($apiUrl === '') {
    42         $apiUrl = 'https://api.omni.devlusion.com';
    43     }
     46    $apiUrl = Omni_API_Client::get_api_url();
    4447    $resp = wp_remote_post($apiUrl . '/v1/plugin/auto-provision', [
    4548        'timeout' => 10,
    … …  
    5659    $data = json_decode(wp_remote_retrieve_body($resp), true);
    5760    if (!empty($data['success']) && !empty($data['shop_token'])) {
    58         update_option('omni_api_url', esc_url_raw($apiUrl));
     61        if (Omni_API_Client::allows_custom_api_url()) {
     62            update_option('omni_api_url', esc_url_raw($apiUrl));
     63        }
    5964        update_option('omni_live_api_key', sanitize_text_field((string) $data['shop_token']));
    6065        update_option('omni_staging_api_key', sanitize_text_field((string) ($data['staging_token'] ?? '')));
    … …  
    193198    }
    194199    if (isset($_GET['omni_activate_free'], $_GET['_wpnonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wpnonce'])), 'omni_admin_action')) {
    195         omni_auto_provision_shop();
     200        $res = omni_auto_provision_shop();
     201        set_transient('omni_activate_notice_' . get_current_user_id(), $res, 60);
    196202        wp_safe_redirect(remove_query_arg(['omni_activate_free', '_wpnonce']));
    197203        exit;
Note: See TracChangeset for help on using the changeset viewer.