Changeset 3356725
- Timestamp:
- 09/05/2025 01:07:00 PM (6 months ago)
- Location:
- codshield-ai
- Files:
-
- 36 added
- 6 edited
-
assets/banner-1544x500.png (added)
-
assets/banner-772x250.png (added)
-
assets/icon-128x128.png (added)
-
assets/icon-256x256.png (added)
-
assets/screenshot-1.png (added)
-
assets/screenshot-2.png (added)
-
assets/screenshot-3.png (added)
-
assets/screenshot-4.png (added)
-
assets/screenshot-5.png (added)
-
tags/1.1.0 (added)
-
tags/1.1.0/README.md (added)
-
tags/1.1.0/assets (added)
-
tags/1.1.0/assets/css (added)
-
tags/1.1.0/assets/css/admin.css (added)
-
tags/1.1.0/assets/css/style.css (added)
-
tags/1.1.0/assets/js (added)
-
tags/1.1.0/assets/js/admin.js (added)
-
tags/1.1.0/codshield-ai.php (added)
-
tags/1.1.0/includes (added)
-
tags/1.1.0/includes/admin-dashboard.php (added)
-
tags/1.1.0/includes/admin-fraud-score.php (added)
-
tags/1.1.0/includes/admin-fraud-widget.php (added)
-
tags/1.1.0/includes/api.php (added)
-
tags/1.1.0/includes/auth-mock.php (added)
-
tags/1.1.0/includes/class-codshield-whatsapp-confirmation.php (added)
-
tags/1.1.0/includes/custom-api-sync.php (added)
-
tags/1.1.0/includes/fraud-engine.php (added)
-
tags/1.1.0/includes/functions.php (added)
-
tags/1.1.0/includes/order-sync.php (added)
-
tags/1.1.0/includes/settings-order-sync.php (added)
-
tags/1.1.0/readme.txt (added)
-
tags/1.1.0/templates (added)
-
tags/1.1.0/templates/admin-dashboard.php (added)
-
tags/1.1.0/uninstall.php (added)
-
trunk/README.md (added)
-
trunk/assets/js/admin.js (modified) (1 diff)
-
trunk/codshield-ai.php (modified) (4 diffs)
-
trunk/includes/admin-fraud-score.php (modified) (9 diffs)
-
trunk/includes/admin-fraud-widget.php (modified) (1 diff)
-
trunk/includes/class-codshield-whatsapp-confirmation.php (added)
-
trunk/includes/order-sync.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codshield-ai/trunk/assets/js/admin.js
r3354587 r3356725 97 97 const licenseKey = ($('#codshield_license_key').val() || '').trim(); 98 98 const storeId = ($('#codshield_store_id').val() || '').trim(); 99 const siteUrl = codshield_ajax.env === 'dev' ? 'https://zipnom.com' :window.location.origin;100 const adminEmail = codshield_ajax. env === 'dev' ? 'info@zipnom.com' : codshield_ajax.admin_email;99 const siteUrl = window.location.origin; 100 const adminEmail = codshield_ajax.admin_email; 101 101 102 102 if (!licenseKey || !storeId) { -
codshield-ai/trunk/codshield-ai.php
r3354587 r3356725 5 5 * Plugin URI: https://wordpress.org/plugins/codshield-ai/ 6 6 * Description: Prevent fake COD (Cash on Delivery) orders using a fraud detection engine and mock WhatsApp confirmation logic. 7 * Version: 1. 0.07 * Version: 1.1.0 8 8 * Author: ZipNom Technologies 9 9 * Author URI: https://zipnom.com/ … … 20 20 define('CODSHIELD_AI_DIR', plugin_dir_path(__FILE__)); 21 21 define('CODSHIELD_AI_URL', plugin_dir_url(__FILE__)); 22 define('CODSHIELD_AI_VERSION', '1. 0.0');22 define('CODSHIELD_AI_VERSION', '1.1.0'); 23 23 24 24 … … 34 34 require_once CODSHIELD_AI_DIR . 'includes/admin-fraud-score.php'; 35 35 require_once CODSHIELD_AI_DIR . 'includes/custom-api-sync.php'; 36 require_once CODSHIELD_AI_DIR . 'includes/class-codshield-whatsapp-confirmation.php'; 36 37 37 38 // Environment flag for your own logic (does NOT alter WP globals) … … 100 101 wp_enqueue_script('codshield-admin'); 101 102 }); 103 104 // A) Always boot the feature (after most plugins load) 105 add_action('plugins_loaded', function () { 106 if (class_exists('CODShield_AI_WhatsApp_Confirmation')) { 107 CODShield_AI_WhatsApp_Confirmation::init(); 108 } 109 }, 20); 110 111 // B) Belt & suspenders: ensure the REST route is registered no matter what 112 add_action('rest_api_init', function () { 113 if (class_exists('CODShield_AI_WhatsApp_Confirmation')) { 114 CODShield_AI_WhatsApp_Confirmation::register_rest(); 115 } 116 }); -
codshield-ai/trunk/includes/admin-fraud-score.php
r3354587 r3356725 4 4 5 5 /** 6 * Fetch expected fraud data once per request for a given order.7 * Returns : ['score'=>?int, 'risk_api'=>'HIGH|MEDIUM|LOW' or '', 'breakdown'=>array, 'ai_summary'=>string, 'error'=>string]6 * Normalize Woo payment method to backend enum. 7 * Returns one of: COD | WOOCOMMERCE_PAYMENTS | PAYMENT_GATEWAY 8 8 */ 9 /** 10 * Fetch expected fraud data once per request for a given order. 11 * Returns: ['score'=>?int, 'risk_api'=>'HIGH|MEDIUM|LOW' or '', 'breakdown'=>array, 'ai_summary'=>string, 'error'=>string] 12 */ 9 if (!function_exists('codshield_ai_map_payment_method_enum')) { 10 function codshield_ai_map_payment_method_enum(string $method_id, string $method_title): string 11 { 12 $id = strtolower(trim($method_id)); 13 $title = strtolower(trim($method_title)); 14 15 // Cash on Delivery 16 if ($id === 'cod' || str_contains($id, 'cash') || str_contains($title, 'cash')) { 17 return 'COD'; 18 } 19 20 // WooCommerce Payments 21 if ( 22 $id === 'woocommerce_payments' 23 || str_starts_with($id, 'wcpay') 24 || str_contains($id, 'woocommerce_payments') 25 || str_contains($title, 'woocommerce payments') 26 || str_contains($id, 'woo-pay') 27 ) { 28 return 'WOOCOMMERCE_PAYMENTS'; 29 } 30 31 // Everything else 32 return 'PAYMENT_GATEWAY'; 33 } 34 } 35 13 36 /** 14 37 * Fetch expected fraud data once per request for a given order. … … 24 47 } 25 48 26 // Credentials/headers like your code 27 $store_id = get_option('codshield_store_id', ''); 28 $api_key = get_option('codshield_license_key', ''); 29 $site_url = (function_exists('codshield_ai_env') && codshield_ai_env() === 'dev') ? 'https://zipnom.com' : site_url(); 30 $admin_email = (function_exists('codshield_ai_env') && codshield_ai_env() === 'dev') ? 'info@zipnom.com' : get_option('admin_email'); 49 // Credentials/headers 50 $store_id = get_option('codshield_store_id', ''); 51 $api_key = get_option('codshield_license_key', ''); 52 $registered = trim((string) get_option('codshield_registered_site_url', '')); 53 $site_url = $registered !== '' ? $registered : site_url(); // match backend tenant 54 $admin_email = get_option('admin_email'); 31 55 32 56 $path = (defined('CODSHIELD_ENDPOINT_FRAUD_SCORE') ? CODSHIELD_ENDPOINT_FRAUD_SCORE : '/api/fraud/expected-score'); … … 34 58 35 59 $headers = [ 36 'Content-Type' => 'application/json',37 'Accept' => 'application/json',38 'x-store-id' => $store_id,39 'x-store-url' => $site_url,40 'x-license-key' => $api_key,41 'x-registered-email' => $admin_email,60 'Content-Type' => 'application/json', 61 'Accept' => 'application/json', 62 'x-store-id' => $store_id, 63 'x-store-url' => $site_url, 64 'x-license-key' => $api_key, 65 'x-registered-email' => $admin_email, 42 66 ]; 43 67 … … 49 73 } 50 74 51 / * ---------- build body object from order (matches your Postman shape) ---------- */75 // Build body object from order (matches your Postman shape) 52 76 $customer_details = [ 53 77 'first_name' => (string) $order->get_billing_first_name(), … … 83 107 $order_items = []; 84 108 foreach ($order->get_items('line_item') as $item_id => $item) { 85 /** @var WC_Order_Item_Product $item */ // <-- tell the analyzer 86 109 /** @var WC_Order_Item_Product $item */ 87 110 $qty = (int) $item->get_quantity(); 88 111 $line_total = (float) $item->get_total(); … … 96 119 ]; 97 120 } 121 122 // Map payment method to enum the API expects 123 $pm_title = (string) ($order->get_payment_method_title() ?: $order->get_payment_method()); 124 $pm_id = (string) $order->get_payment_method(); 125 $payment_method_enum = codshield_ai_map_payment_method_enum($pm_id, $pm_title); 98 126 99 127 $payload = [ … … 105 133 'ip_address' => (string) ($order->get_customer_ip_address() ?: get_post_meta($oid, '_customer_ip_address', true) ?: ($_SERVER['REMOTE_ADDR'] ?? '')), 106 134 'total_amount' => (float) $order->get_total(), 107 'payment_method' => (string) ($order->get_payment_method_title() ?: $order->get_payment_method()),135 'payment_method' => $payment_method_enum, 108 136 'billing_address' => $billing, 109 137 'shipping_address' => $shipping, … … 114 142 ], 115 143 ]; 116 /* ----------------------------------------------------------------------------- */117 144 118 145 // Encode payload into the URL (GET must not send a raw body via WP HTTP) 119 $payload_json = wp_json_encode($payload);146 $payload_json = wp_json_encode($payload); 120 147 $path_with_payload = $path . '&payload=' . rawurlencode($payload_json); 121 148 … … 239 266 <?php endif; ?> 240 267 <?php endif; ?> 268 241 269 </div> 242 270 </div> -
codshield-ai/trunk/includes/admin-fraud-widget.php
r3354587 r3356725 173 173 174 174 // Auth headers 175 $site_url = function_exists('codshield_ai_env') && codshield_ai_env() === 'dev' ? 'https://zipnom.com' :site_url();176 $admin_email = function_exists('codshield_ai_env') && codshield_ai_env() === 'dev' ? 'info@zipnom.com' :get_option('admin_email');175 $site_url = site_url(); 176 $admin_email = get_option('admin_email'); 177 177 178 178 $headers = [ -
codshield-ai/trunk/includes/order-sync.php
r3354587 r3356725 44 44 ]; 45 45 46 // Shipping phone (use public getter; never access _shipping_phone directly) 47 $shipping_phone = method_exists($order, 'get_shipping_phone') ? (string) $order->get_shipping_phone() : ''; 48 46 49 // Shipping address (fallbacks to billing where empty) 47 $shipping_phone_meta = $order->get_meta('shipping_phone') ?: $order->get_meta('_shipping_phone');48 50 $shipping = [ 49 51 'first_name' => $order->get_shipping_first_name() ?: $billing['first_name'], … … 55 57 'postal_code' => $order->get_shipping_postcode() ?: $billing['postal_code'], 56 58 'country' => $order->get_shipping_country() ?: $billing['country'], 57 'phone' => $shipping_phone _meta?: $billing['phone'],59 'phone' => $shipping_phone ?: $billing['phone'], 58 60 ]; 59 61 … … 94 96 'order_details' => [ 95 97 'woo_order_id' => (string) $order->get_id(), 96 // Use the same option the rest of the plugin uses for store id97 98 'store_id' => get_option('codshield_store_id', ''), 98 99 'status' => $order->get_status(), 99 'ip_address' => $order->get_customer_ip_address() ?: $order->get_meta('_customer_ip_address') ?: '', 100 // Do NOT read _customer_ip_address directly (internal); stick to the getter. 101 'ip_address' => (string) ($order->get_customer_ip_address() ?: ''), 100 102 'total_amount' => (float) $order->get_total(), 101 103 'payment_method' => $payment_method_enum, … … 126 128 } 127 129 128 // 1) Feature flag + license129 if (!(bool) get_option('codshield_ai_os_enabled')) {130 $log->info('Bail: order sync disabled', $ctx);131 return;132 }133 130 if (function_exists('codshield_ai_is_license_valid') && !codshield_ai_is_license_valid()) { 134 131 $log->info('Bail: license invalid', $ctx); … … 150 147 } 151 148 152 // 4) Registered identifiers (match Postman) 153 // If you saved these during onboarding, use them; otherwise fall back. 154 $registered_site_url = (string) get_option('codshield_registered_site_url', ''); 155 $registered_email = (string) get_option('codshield_registered_email', ''); 156 157 // backend often stores canonical https URL; mirror that 158 $store_url = $registered_site_url !== '' 159 ? untrailingslashit($registered_site_url) 160 : untrailingslashit(set_url_scheme(home_url(), 'https')); // ensure https like your Postman 161 162 $admin_email = $registered_email !== '' 163 ? $registered_email 164 : (function_exists('codshield_ai_env') && codshield_ai_env() === 'dev' 165 ? 'info@zipnom.com' 166 : (string) get_option('admin_email')); 167 168 // 5) Headers (mirror Postman) 149 // 4) Registered identifiers (dynamic only) 150 $store_url = (string) get_option('codshield_registered_site_url', site_url()); 151 $store_url = untrailingslashit($store_url); 152 153 $registered_email = (string) get_option('codshield_registered_email', ''); 154 $admin_email = $registered_email !== '' ? $registered_email : (string) get_option('admin_email'); 155 156 // 5) Headers (no dev defaults) 169 157 $headers = [ 170 158 'Content-Type' => 'application/json', … … 213 201 } 214 202 } 215 216 203 217 204 /** -
codshield-ai/trunk/readme.txt
r3354587 r3356725 1 1 === CODShield AI – Cash on Delivery (COD) Fraud Shield === 2 2 Contributors: zipnom 3 Tags: woocommerce, cash -on-delivery, cod, fraud, whatsapp, verification, order-confirmation, ivr, rto3 Tags: woocommerce, cash on delivery, cod, fraud, whatsapp 4 4 Requires at least: 5.8 5 5 Tested up to: 6.6 6 6 Requires PHP: 7.4 7 Stable tag: 1. 0.07 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 AI-powered COD fraud prevention for WooCommerce with WhatsApp order confirmation (single built-in message) and Voice IVR confirmation (PRO). Includes an analytics dashboard, fraud-risk trends, and order-level verification logs.11 Prevent fake COD orders with WhatsApp confirmations, fraud checks, and smart automation to reduce RTO and cancellations. 12 12 13 13 == Description == … … 115 115 == Changelog == 116 116 117 = 1.1.0 - 2025-09-05 = 118 * Implemented WhatsApp confirmation feature. 119 * Implemented plugin page assets (banner/icons/screenshots). 120 * Implemented performance improvements. 121 * Implemented security hardening. 122 117 123 = 1.0.0 = 118 124 * Initial release with AI-gated COD checks, WhatsApp confirmation (single built-in message), Analytics dashboard, Orders Details with filters + CSV export, License screen, and (PRO) Voice IVR confirmation. 119 125 120 126 == Upgrade Notice == 127 128 = 1.1.0 = 129 Adds WhatsApp confirmations, assets, and general performance/security improvements. Recommended update. 121 130 122 131 = 1.0.0 =
Note: See TracChangeset
for help on using the changeset viewer.