HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
File: //wordpress/plugins/woocommerce-fraud-protection/0.1.5/assets/js/shortcode-checkout.js
/**
 * Shortcode checkout fraud protection integration.
 *
 * Gates the classic checkout form submission via
 * wcFraudProtection.acquireSessionId(), injects the session ID as a
 * hidden field, then re-triggers submit. On re-entry (field present),
 * lets through and defers cleanup + reset for the next attempt.
 *
 * Depends on blackbox-init.js (wcFraudProtection) and jQuery.
 */
/* global jQuery */
( function ( $ ) {
	'use strict';

	$( 'form.checkout' ).on( 'checkout_place_order', function () {
		const fraudProtection = window.wcFraudProtection;

		if ( ! fraudProtection || ! fraudProtection.acquireSessionId ) {
			return true;
		}

		const sessionIdField = fraudProtection.config.sessionIdField;

		// Re-entry: field present, let through. Deferred cleanup removes
		// the field and resets so the next attempt gets a fresh session.
		if ( $( '#' + sessionIdField ).length ) {
			setTimeout( function () {
				$( '#' + sessionIdField ).remove();
				fraudProtection.reset();
			}, 0 );
			return true;
		}

		const $form = $( this );

		fraudProtection.acquireSessionId().then( function ( sessionId ) {
			$( '<input>', {
				type: 'hidden',
				name: sessionIdField,
				id: sessionIdField,
				value: sessionId,
			} ).appendTo( $form );
			$form.trigger( 'submit' );
		} );

		return false;
	} );
} )( jQuery );