smart_button = $smart_button; $this->logger = $logger; } /** * Returns the nonce. * * @return string */ public static function nonce(): string { return self::ENDPOINT; } /** * Handles the request. * * @return bool */ public function handle_request(): bool { try { $script_data = $this->smart_button->script_data(); wp_send_json_success( array( 'url_params' => $script_data['url_params'], 'amount' => WC()->cart->get_total( 'raw' ), ) ); return true; } catch ( Throwable $error ) { $this->logger->error( "CartScriptParamsEndpoint execution failed. {$error->getMessage()} {$error->getFile()}:{$error->getLine()}" ); wp_send_json_error(); return false; } } }