Automattic\WooCommerce\StoreApi\Utilities

AgenticCheckoutUtils::validate_jetpack_requestpublic staticWC 10.6.0

Validate that the request is signed with Jetpack blog token.

Method of the class: AgenticCheckoutUtils{}

No Hooks.

Returns

true|\WP_Error. True if valid, WP_Error otherwise.

Usage

$result = AgenticCheckoutUtils::validate_jetpack_request();

Changelog

Since 10.6.0 Introduced.

AgenticCheckoutUtils::validate_jetpack_request() code WC 10.7.0

public static function validate_jetpack_request() {
	if ( class_exists( 'Automattic\Jetpack\Connection\Rest_Authentication' ) ) {
		if ( \Automattic\Jetpack\Connection\Rest_Authentication::is_signed_with_blog_token() ) {
			return true;
		}
	}

	return new \WP_Error(
		'rest_forbidden',
		__( 'This endpoint requires Jetpack blog token authentication.', 'woocommerce' ),
		array( 'status' => 401 )
	);
}