'External agent selected the exact product variant', 'shipping' => 'Address-specific shipping and final total matched normal checkout', 'approval' => 'Customer approval or delegated authority was checked', 'retry' => 'A repeated completion request produced no duplicate payment or order', 'fulfilment' => 'Receipt, stock change and fulfilment/refund workflow were checked' ); public static function record( array $input ) { if ( wp_get_environment_type() === 'production' ) { return new \WP_Error( 'production', 'Record purchase verification on a staging or development site. Set WP_ENVIRONMENT_TYPE in that site’s wp-config.php.' ); } if ( ! function_exists( 'wc_get_order' ) ) { return new \WP_Error( 'dependency', 'WooCommerce is required.' ); } $id = isset( $input['order_id'] ) && is_scalar( $input['order_id'] ) ? absint( $input['order_id'] ) : 0; $order = $id > 0 ? wc_get_order( $id ) : false; if ( ! $order || $order->get_type() !== 'shop_order' || ! $order->is_paid() || ! $order->get_date_paid() || (float) $order->get_total() <= 0 ) { return new \WP_Error( 'unpaid', 'Select a standard order with a positive total, paid status and recorded payment date. This does not independently confirm settlement.' ); } foreach ( self::STEPS as $key => $label ) { if ( empty( $input[ $key ] ) ) { return new \WP_Error( 'incomplete', 'Complete every staging checklist item before recording the result.' ); } } $service = isset( $input['service'] ) && is_string( $input['service'] ) ? substr( sanitize_text_field( $input['service'] ), 0, 100 ) : ''; if ( $service === '' ) { return new \WP_Error( 'service', 'Enter the shopping service or agent used in the test.' ); } $deps = Dependencies::inspect(); update_option( self::OPTION, array( 'time' => time(), 'environment' => wp_get_environment_type(), 'order_id' => $order->get_id(), 'service' => $service, 'wc_version' => $deps['wc_version'], 'ai_version' => $deps['ai']['version'], ), false ); EventLog::record( 'verification_recorded' ); return true; } }