Changeset 3846711
- Timestamp:
- 12/05/2026 06:41:29 PM (4 hours ago)
- Location:
- omni-cod-return-risk-shield-for-woocommerce
- Files:
-
- 8 edited
- 1 copied
-
tags/1.0.1 (copied) (copied from omni-cod-return-risk-shield-for-woocommerce/trunk )
-
tags/1.0.1/includes/class-omni-api-client.php (modified) (4 diffs)
-
tags/1.0.1/includes/class-omni-settings.php (modified) (3 diffs)
-
tags/1.0.1/readme.txt (modified) (2 diffs)
-
tags/1.0.1/woocommerce-omni.php (modified) (5 diffs)
-
trunk/includes/class-omni-api-client.php (modified) (4 diffs)
-
trunk/includes/class-omni-settings.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woocommerce-omni.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
omni-cod-return-risk-shield-for-woocommerce/tags/1.0.1/includes/class-omni-api-client.php
r3846673 r3846711 14 14 } 15 15 16 public static function allows_custom_api_url(): bool { 17 return defined('OMNI_ALLOW_CUSTOM_API_URL') && OMNI_ALLOW_CUSTOM_API_URL; 18 } 19 16 20 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, '/'); 19 27 } 20 28 … … 27 35 28 36 /** 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. 31 42 */ 32 43 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() !== ''; 35 45 } 36 46 … … 38 48 $key = self::get_active_key(); 39 49 $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.'); 42 52 } 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; 45 63 } 46 64 47 65 $response = wp_remote_post(self::get_api_url() . $path, [ 48 66 '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), 58 69 ]); 59 70 … … 74 85 $key = self::get_active_key(); 75 86 $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 c onfigure Merchant ID andAPI 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.'); 78 89 } 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 79 101 $response = wp_remote_get(self::get_api_url() . $path, [ 80 102 '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, 88 104 ]); 89 105 if (is_wp_error($response)) { -
omni-cod-return-risk-shield-for-woocommerce/tags/1.0.1/includes/class-omni-settings.php
r3846673 r3846711 21 21 22 22 public static function get_fields(): array { 23 return[23 $fields = [ 24 24 [ 25 25 'name' => __('Omni by Devlusion — Store Connection & License', 'omni-cod-return-risk-shield-for-woocommerce'), 26 26 'type' => 'title', 27 'desc' => __('Connect your WooCommerce store using your Store Instance ID andAPI 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'), 28 28 'id' => 'omni_section_title', 29 29 ], … … 38 38 ], 39 39 ], 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'), 42 47 'type' => 'text', 43 48 '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; 81 89 } 82 90 83 91 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 84 100 // Guideline #7 & #11 compliant: never contact external servers or display 85 101 // promotional banners before explicit administrator opt-in. … … 90 106 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>'; 91 107 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>✓ ' . esc_html__('Omni COD Return Risk Shield Connected', 'omni-cod-return-risk-shield-for-woocommerce') . '</strong> · ' . 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>'; 92 115 echo '</div>'; 93 116 } -
omni-cod-return-risk-shield-for-woocommerce/tags/1.0.1/readme.txt
r3846673 r3846711 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 54 54 == Changelog == 55 55 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 56 61 = 1.0.0 = 57 62 * 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 4 4 * Plugin URI: https://omni.devlusion.com 5 5 * 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. 06 * Version: 1.0.1 7 7 * Author: Devlusion (Pvt) Ltd 8 8 * Author URI: https://devlusion.com … … 21 21 22 22 if (!defined('OMNI_PLUGIN_VERSION')) { 23 define('OMNI_PLUGIN_VERSION', '1.0.0'); 23 define('OMNI_PLUGIN_VERSION', '1.0.1'); 24 } 25 if (!defined('OMNI_PROD_API_URL')) { 26 define('OMNI_PROD_API_URL', 'https://api.omni.devlusion.com'); 27 } 28 if (!defined('OMNI_ALLOW_CUSTOM_API_URL')) { 29 define('OMNI_ALLOW_CUSTOM_API_URL', false); 24 30 } 25 31 … … 38 44 return ['success' => true, 'message' => __('Omni COD Shield is already connected.', 'omni-cod-return-risk-shield-for-woocommerce')]; 39 45 } 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(); 44 47 $resp = wp_remote_post($apiUrl . '/v1/plugin/auto-provision', [ 45 48 'timeout' => 10, … … 56 59 $data = json_decode(wp_remote_retrieve_body($resp), true); 57 60 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 } 59 64 update_option('omni_live_api_key', sanitize_text_field((string) $data['shop_token'])); 60 65 update_option('omni_staging_api_key', sanitize_text_field((string) ($data['staging_token'] ?? ''))); … … 193 198 } 194 199 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); 196 202 wp_safe_redirect(remove_query_arg(['omni_activate_free', '_wpnonce'])); 197 203 exit; -
omni-cod-return-risk-shield-for-woocommerce/trunk/includes/class-omni-api-client.php
r3846673 r3846711 14 14 } 15 15 16 public static function allows_custom_api_url(): bool { 17 return defined('OMNI_ALLOW_CUSTOM_API_URL') && OMNI_ALLOW_CUSTOM_API_URL; 18 } 19 16 20 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, '/'); 19 27 } 20 28 … … 27 35 28 36 /** 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. 31 42 */ 32 43 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() !== ''; 35 45 } 36 46 … … 38 48 $key = self::get_active_key(); 39 49 $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.'); 42 52 } 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; 45 63 } 46 64 47 65 $response = wp_remote_post(self::get_api_url() . $path, [ 48 66 '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), 58 69 ]); 59 70 … … 74 85 $key = self::get_active_key(); 75 86 $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 c onfigure Merchant ID andAPI 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.'); 78 89 } 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 79 101 $response = wp_remote_get(self::get_api_url() . $path, [ 80 102 '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, 88 104 ]); 89 105 if (is_wp_error($response)) { -
omni-cod-return-risk-shield-for-woocommerce/trunk/includes/class-omni-settings.php
r3846673 r3846711 21 21 22 22 public static function get_fields(): array { 23 return[23 $fields = [ 24 24 [ 25 25 'name' => __('Omni by Devlusion — Store Connection & License', 'omni-cod-return-risk-shield-for-woocommerce'), 26 26 'type' => 'title', 27 'desc' => __('Connect your WooCommerce store using your Store Instance ID andAPI 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'), 28 28 'id' => 'omni_section_title', 29 29 ], … … 38 38 ], 39 39 ], 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'), 42 47 'type' => 'text', 43 48 '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; 81 89 } 82 90 83 91 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 84 100 // Guideline #7 & #11 compliant: never contact external servers or display 85 101 // promotional banners before explicit administrator opt-in. … … 90 106 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>'; 91 107 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>✓ ' . esc_html__('Omni COD Return Risk Shield Connected', 'omni-cod-return-risk-shield-for-woocommerce') . '</strong> · ' . 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>'; 92 115 echo '</div>'; 93 116 } -
omni-cod-return-risk-shield-for-woocommerce/trunk/readme.txt
r3846673 r3846711 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 54 54 == Changelog == 55 55 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 56 61 = 1.0.0 = 57 62 * 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 4 4 * Plugin URI: https://omni.devlusion.com 5 5 * 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. 06 * Version: 1.0.1 7 7 * Author: Devlusion (Pvt) Ltd 8 8 * Author URI: https://devlusion.com … … 21 21 22 22 if (!defined('OMNI_PLUGIN_VERSION')) { 23 define('OMNI_PLUGIN_VERSION', '1.0.0'); 23 define('OMNI_PLUGIN_VERSION', '1.0.1'); 24 } 25 if (!defined('OMNI_PROD_API_URL')) { 26 define('OMNI_PROD_API_URL', 'https://api.omni.devlusion.com'); 27 } 28 if (!defined('OMNI_ALLOW_CUSTOM_API_URL')) { 29 define('OMNI_ALLOW_CUSTOM_API_URL', false); 24 30 } 25 31 … … 38 44 return ['success' => true, 'message' => __('Omni COD Shield is already connected.', 'omni-cod-return-risk-shield-for-woocommerce')]; 39 45 } 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(); 44 47 $resp = wp_remote_post($apiUrl . '/v1/plugin/auto-provision', [ 45 48 'timeout' => 10, … … 56 59 $data = json_decode(wp_remote_retrieve_body($resp), true); 57 60 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 } 59 64 update_option('omni_live_api_key', sanitize_text_field((string) $data['shop_token'])); 60 65 update_option('omni_staging_api_key', sanitize_text_field((string) ($data['staging_token'] ?? ''))); … … 193 198 } 194 199 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); 196 202 wp_safe_redirect(remove_query_arg(['omni_activate_free', '_wpnonce'])); 197 203 exit;
Note:
See TracChangeset
for help on using the changeset viewer.