Plugin Directory

Changeset 3356725


Ignore:
Timestamp:
09/05/2025 01:07:00 PM (6 months ago)
Author:
zipnom
Message:

Assets for 1.1.0:

  • Update banner-772x250 / banner-1544x500
  • Update icon-128x128 / icon-256x256
  • Add/refresh screenshots

Release 1.1.0:

  • Implement WhatsApp confirmation feature
  • Add/refresh plugin page assets
  • Performance improvements
  • Security hardening
  • Readme: limit to 5 tags, short description <=150 chars, Stable tag 1.1.0
Location:
codshield-ai
Files:
36 added
6 edited

Legend:

Unmodified
Added
Removed
  • codshield-ai/trunk/assets/js/admin.js

    r3354587 r3356725  
    9797        const licenseKey = ($('#codshield_license_key').val() || '').trim();
    9898        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;
    101101
    102102        if (!licenseKey || !storeId) {
  • codshield-ai/trunk/codshield-ai.php

    r3354587 r3356725  
    55 * Plugin URI:  https://wordpress.org/plugins/codshield-ai/
    66 * Description: Prevent fake COD (Cash on Delivery) orders using a fraud detection engine and mock WhatsApp confirmation logic.
    7  * Version:     1.0.0
     7 * Version:     1.1.0
    88 * Author:      ZipNom Technologies
    99 * Author URI:  https://zipnom.com/
     
    2020define('CODSHIELD_AI_DIR', plugin_dir_path(__FILE__));
    2121define('CODSHIELD_AI_URL', plugin_dir_url(__FILE__));
    22 define('CODSHIELD_AI_VERSION', '1.0.0');
     22define('CODSHIELD_AI_VERSION', '1.1.0');
    2323
    2424
     
    3434require_once CODSHIELD_AI_DIR . 'includes/admin-fraud-score.php';
    3535require_once CODSHIELD_AI_DIR . 'includes/custom-api-sync.php';
     36require_once CODSHIELD_AI_DIR . 'includes/class-codshield-whatsapp-confirmation.php';
    3637
    3738// Environment flag for your own logic (does NOT alter WP globals)
     
    100101    wp_enqueue_script('codshield-admin');
    101102});
     103
     104// A) Always boot the feature (after most plugins load)
     105add_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
     112add_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  
    44
    55/**
    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
    88 */
    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  */
     9if (!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
    1336/**
    1437 * Fetch expected fraud data once per request for a given order.
     
    2447    }
    2548
    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');
    3155
    3256    $path = (defined('CODSHIELD_ENDPOINT_FRAUD_SCORE') ? CODSHIELD_ENDPOINT_FRAUD_SCORE : '/api/fraud/expected-score');
     
    3458
    3559    $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,
    4266    ];
    4367
     
    4973    }
    5074
    51     /* ---------- build body object from order (matches your Postman shape) ---------- */
     75    // Build body object from order (matches your Postman shape)
    5276    $customer_details = [
    5377        'first_name' => (string) $order->get_billing_first_name(),
     
    83107    $order_items = [];
    84108    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 */
    87110        $qty        = (int) $item->get_quantity();
    88111        $line_total = (float) $item->get_total();
     
    96119        ];
    97120    }
     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);
    98126
    99127    $payload = [
     
    105133            'ip_address'     => (string) ($order->get_customer_ip_address() ?: get_post_meta($oid, '_customer_ip_address', true) ?: ($_SERVER['REMOTE_ADDR'] ?? '')),
    106134            '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,
    108136            'billing_address'  => $billing,
    109137            'shipping_address' => $shipping,
     
    114142        ],
    115143    ];
    116     /* ----------------------------------------------------------------------------- */
    117144
    118145    // 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);
    120147    $path_with_payload = $path . '&payload=' . rawurlencode($payload_json);
    121148
     
    239266                    <?php endif; ?>
    240267                <?php endif; ?>
     268
    241269            </div>
    242270        </div>
  • codshield-ai/trunk/includes/admin-fraud-widget.php

    r3354587 r3356725  
    173173
    174174    // 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');
    177177
    178178    $headers = [
  • codshield-ai/trunk/includes/order-sync.php

    r3354587 r3356725  
    4444    ];
    4545
     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
    4649    // Shipping address (fallbacks to billing where empty)
    47     $shipping_phone_meta = $order->get_meta('shipping_phone') ?: $order->get_meta('_shipping_phone');
    4850    $shipping = [
    4951        'first_name'  => $order->get_shipping_first_name() ?: $billing['first_name'],
     
    5557        'postal_code' => $order->get_shipping_postcode() ?: $billing['postal_code'],
    5658        'country'     => $order->get_shipping_country() ?: $billing['country'],
    57         'phone'       => $shipping_phone_meta ?: $billing['phone'],
     59        'phone'       => $shipping_phone ?: $billing['phone'],
    5860    ];
    5961
     
    9496        'order_details' => [
    9597            'woo_order_id'     => (string) $order->get_id(),
    96             // Use the same option the rest of the plugin uses for store id
    9798            'store_id'         => get_option('codshield_store_id', ''),
    9899            '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() ?: ''),
    100102            'total_amount'     => (float) $order->get_total(),
    101103            'payment_method'   => $payment_method_enum,
     
    126128    }
    127129
    128     // 1) Feature flag + license
    129     if (!(bool) get_option('codshield_ai_os_enabled')) {
    130         $log->info('Bail: order sync disabled', $ctx);
    131         return;
    132     }
    133130    if (function_exists('codshield_ai_is_license_valid') && !codshield_ai_is_license_valid()) {
    134131        $log->info('Bail: license invalid', $ctx);
     
    150147    }
    151148
    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)
    169157    $headers = [
    170158        'Content-Type'        => 'application/json',
     
    213201    }
    214202}
    215 
    216203
    217204/**
  • codshield-ai/trunk/readme.txt

    r3354587 r3356725  
    11=== CODShield AI – Cash on Delivery (COD) Fraud Shield ===
    22Contributors: zipnom
    3 Tags: woocommerce, cash-on-delivery, cod, fraud, whatsapp, verification, order-confirmation, ivr, rto
     3Tags: woocommerce, cash on delivery, cod, fraud, whatsapp
    44Requires at least: 5.8
    55Tested up to: 6.6
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    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.
     11Prevent fake COD orders with WhatsApp confirmations, fraud checks, and smart automation to reduce RTO and cancellations.
    1212
    1313== Description ==
     
    115115== Changelog ==
    116116
     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
    117123= 1.0.0 =
    118124* 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.
    119125
    120126== Upgrade Notice ==
     127
     128= 1.1.0 =
     129Adds WhatsApp confirmations, assets, and general performance/security improvements. Recommended update.
    121130
    122131= 1.0.0 =
Note: See TracChangeset for help on using the changeset viewer.