squareOAuthService = $squareOAuthService; } protected function handle(WP_REST_Request $data): WP_REST_Response { Sanitizer::verifyNonce($data->get_header('X-WP-Nonce')); $result = $this->squareOAuthService->getAuthorizationUrl(); if (!$result['success']) { throw new InvalidArgumentException( $result['message'] ?? BackendStrings::getPaymentStrings()['square_auth_url_failed'] ); } return new WP_REST_Response( [ 'auth_url' => filter_var((string) $result['url'], FILTER_SANITIZE_URL), ], 200 ); } }