json – Custom REST API error with Stripe webhooks: no signatures were found that match the expected signature for the payload

I have created an API endpoint listener for Stripe's "successful payment" webhook in our installation.

add_action( 'rest_api_init', function () {
  register_rest_route( 'myplugin/v1', '/stripe', array(
    'methods'         => WP_REST_Server::CREATABLE,
    'callback'        => 'stripe_listener',
  ) );
} );

However, when I test the webhook, an error appears: Stripe Exception SignatureVerificationException not captured: No signatures were found that match the expected signature for the payload.

From what I've read, this is because the payload doesn't match exactly (including blank) what was sent in the application.

I'm using $payload = @file_get_contents('php://input'); according to Stripe documentation to retrieve the plain json (instead of getting it from the WP_REST_Request object), but it seems to have changed (parameters in different order, some missing) from the original request.

Could the REST API be processing the request in some way?