Plugin Directory

Changeset 3373334


Ignore:
Timestamp:
10/06/2025 03:22:20 AM (6 months ago)
Author:
fraudlabspro
Message:

Fixed Before Payment Validation not working issue

Location:
fraudlabs-pro-for-woocommerce/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fraudlabs-pro-for-woocommerce/trunk/includes/class.wc-fraudlabspro.php

    r3370125 r3373334  
    8585        add_action( 'woocommerce_admin_order_data_after_billing_address', array( $this, 'render_fraud_report' ) );
    8686        add_action( 'woocommerce_store_api_checkout_order_processed', array( $this, 'store_checkout_order_processed' ), 99, 3 );
     87        add_action( 'woocommerce_after_checkout_form', array( $this, 'javascript_agent' ) );
     88        add_action( 'woocommerce_checkout_order_processed', array( $this, 'checkout_order_processed' ), 99, 3 );
    8789        add_action( 'woocommerce_order_status_changed', array( $this, 'order_status_changed' ), 99, 3 );
    8890        add_action( 'woocommerce_order_status_completed', array( $this, 'order_status_completed' ) );
     
    167169        $table_name = $this->create_flpwc_table();
    168170        $this->add_flpwc_data($table_name, $order_id, '_fraudlabspro_ip_before', $flpIP);
    169         $this->write_debug_log( 'Checkout order processed for Order ' . $order_id . '.');
     171        $this->write_debug_log( 'Store checkout order processed for Order ' . $order_id . '.');
    170172
    171173        if ( $this->validate_order() === false ) {
    172174            wc_add_notice( ( !empty( $this->fraud_message ) ) ? $this->fraud_message : 'This order ' . $order_id . ' failed our fraud validation. Please contact us for more details.', 'error' );
     175
     176            global $woocommerce;
     177            $woocommerce->cart->empty_cart();
     178
     179            if ( is_ajax() ) {
     180                wp_send_json( array(
     181                    'result'   => 'success',
     182                    'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', wc_get_cart_url(), $this->order ),
     183                ) );
     184            } else {
     185                wp_safe_redirect(
     186                    apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', wc_get_cart_url(), $this->order )
     187                );
     188                exit;
     189            }
     190        }
     191    }
     192
     193    public function checkout_order_processed( $order_id, $posted_data, $order ) {
     194        // Collect IP information before the payment gateway
     195        $ip_x_sucuri_before = $ip_incap_before = $ip_http_cf_connecting_before = $ip_x_forwarded_for_before = $ip_x_real_before = $ip_http_client_before = $ip_http_forwarded_before = $ip_x_forwarded_before ='::1';
     196
     197        if ( isset( $_SERVER['HTTP_X_SUCURI_CLIENTIP'] ) && filter_var( $_SERVER['HTTP_X_SUCURI_CLIENTIP'], FILTER_VALIDATE_IP ) ) {
     198            $ip_x_sucuri_before = $_SERVER['HTTP_X_SUCURI_CLIENTIP'];
     199        }
     200
     201        if( isset( $_SERVER['HTTP_INCAP_CLIENT_IP'] ) && filter_var( $_SERVER['HTTP_INCAP_CLIENT_IP'], FILTER_VALIDATE_IP ) ) {
     202            $ip_incap_before = $_SERVER['HTTP_INCAP_CLIENT_IP'];
     203        }
     204
     205        if( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) && filter_var( $_SERVER['HTTP_CF_CONNECTING_IP'], FILTER_VALIDATE_IP ) ) {
     206            $ip_http_cf_connecting_before = $_SERVER['HTTP_CF_CONNECTING_IP'];
     207        }
     208
     209        if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
     210            $ip_x_real_before = $_SERVER['HTTP_X_REAL_IP'];
     211        }
     212
     213        if( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
     214            $xip = trim(current(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])));
     215
     216            if (filter_var($xip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
     217                $ip_x_forwarded_for_before = $xip;
     218            }
     219        }
     220
     221        if( isset( $_SERVER['HTTP_CLIENT_IP'] ) && filter_var( $_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP ) ) {
     222            $ip_http_client_before = $_SERVER['HTTP_CLIENT_IP'];
     223        }
     224
     225        if( isset( $_SERVER['HTTP_FORWARDED'] ) && filter_var( $_SERVER['HTTP_FORWARDED'], FILTER_VALIDATE_IP ) ) {
     226            $ip_http_forwarded_before = $_SERVER['HTTP_FORWARDED'];
     227        }
     228
     229        if( isset( $_SERVER['HTTP_X_FORWARDED'] ) && filter_var( $_SERVER['HTTP_X_FORWARDED'], FILTER_VALIDATE_IP ) ) {
     230            $ip_x_forwarded_before = $_SERVER['HTTP_X_FORWARDED'];
     231        }
     232
     233        $ip_remote_addr_before = $_SERVER['REMOTE_ADDR'];
     234        $flp_checksum_before = ( isset( $_COOKIE['flp_checksum'] ) ) ? $_COOKIE['flp_checksum'] : '';
     235        $flp_device_before = ( isset( $_COOKIE['flp_device'] ) ) ? $_COOKIE['flp_device'] : '';
     236
     237        $flpIP = [
     238            'ip_x_sucuri_before'            => $ip_x_sucuri_before,
     239            'ip_incap_before'               => $ip_incap_before,
     240            'ip_http_cf_connecting_before'  => $ip_http_cf_connecting_before,
     241            'ip_x_real_before'              => $ip_x_real_before,
     242            'ip_x_forwarded_for_before'     => $ip_x_forwarded_for_before,
     243            'ip_http_client_before'         => $ip_http_client_before,
     244            'ip_http_forwarded_before'      => $ip_http_forwarded_before,
     245            'ip_x_forwarded_before'         => $ip_x_forwarded_before,
     246            'ip_remote_addr_before'         => $ip_remote_addr_before,
     247            'flp_checksum_before'           => $flp_checksum_before,
     248            'flp_device_before'             => $flp_device_before,
     249        ];
     250
     251        add_post_meta( $order_id, '_fraudlabspro_ip_before', $flpIP );
     252        $table_name = $this->create_flpwc_table();
     253        $this->add_flpwc_data($table_name, $order_id, '_fraudlabspro_ip_before', $flpIP);
     254
     255        if ( $this->validation_sequence != 'before' ) {
     256            return;
     257        }
     258
     259        $this->write_debug_log( 'Checkout order processed for Order ' . $order_id . '.');
     260        $this->order = wc_get_order( $order_id );
     261
     262        if ( $this->validate_order() === false ) {
     263            wc_add_notice( ( !empty( $this->fraud_message ) ) ? $this->fraud_message : 'This order ' . $this->order->get_id() . ' failed our fraud validation. Please contact us for more details.', 'error' );
    173264
    174265            global $woocommerce;
     
    656747            'advanced_velocity_screening'   => ( get_option('wc_settings_woocommerce-fraudlabs-pro_flp_advanced_velocity') == "yes" ) ? 'enabled' : 'disabled',
    657748            'source'                        => 'woocommerce',
    658             'source_version'                => '2.23.3',
     749            'source_version'                => '2.23.4',
    659750            'items'                         => $item_sku,
    660751            'cc_key'                        => $cc_key,
  • fraudlabs-pro-for-woocommerce/trunk/init.php

    r3370125 r3373334  
    66 * Author: FraudLabs Pro
    77 * Author URI: https://www.fraudlabspro.com/
    8  * Version: 2.23.3
     8 * Version: 2.23.4
    99 * Requires Plugins: woocommerce
    1010 * Text Domain: fraudlabs-pro-for-woocommerce
  • fraudlabs-pro-for-woocommerce/trunk/readme.txt

    r3370125 r3373334  
    55Requires at least: 4.6
    66Tested up to: 6.8
    7 Stable tag: 2.23.3
     7Stable tag: 2.23.4
    88
    99Fraud prevention plugin for WooCommerce to minimize payment fraud and avoid chargebacks. With the FraudLabs Pro Micro Plan, you can get 500 free fraud validation credits every month.
     
    9898== Changelog ==
    9999
     100* 2.23.4 Fixed Before Payment Validation not working issue.
    100101* 2.23.3 Updated Before Payment Validation.
    101102* 2.23.2 Removed legacy order properties.
Note: See TracChangeset for help on using the changeset viewer.