diff --git a/src/Exception/OrderCreationException.php b/src/Exception/OrderCreationException.php index 977a8e7c0..8ac44e415 100644 --- a/src/Exception/OrderCreationException.php +++ b/src/Exception/OrderCreationException.php @@ -33,4 +33,6 @@ class OrderCreationException extends \Exception const ORDER_IS_NOT_CREATED = 7; const WRONG_FAMILY_NAME = 8; + + const WRONG_GIVEN_NAME = 9; } diff --git a/src/Handler/Exception/OrderExceptionHandler.php b/src/Handler/Exception/OrderExceptionHandler.php index 0443486b3..7d2dc74dd 100644 --- a/src/Handler/Exception/OrderExceptionHandler.php +++ b/src/Handler/Exception/OrderExceptionHandler.php @@ -32,6 +32,8 @@ public function handle(Exception $e) return new OrderCreationException($e->getMessage(), OrderCreationException::WRONG_SHIPPING_PHONE_NUMBER_EXCEPTION); } elseif (strpos($e->getMessage(), 'billingAddress.familyName')) { return new OrderCreationException($e->getMessage(), OrderCreationException::WRONG_FAMILY_NAME); + } elseif (strpos($e->getMessage(), 'billingAddress.givenName')) { + return new OrderCreationException($e->getMessage(), OrderCreationException::WRONG_GIVEN_NAME); } elseif (strpos($e->getMessage(), 'payment.amount')) { if (strpos($e->getMessage(), 'minimum')) { throw new OrderCreationException($e->getMessage(), OrderCreationException::ORDER_TOTAL_LOWER_THAN_MINIMUM); diff --git a/src/Service/ExceptionService.php b/src/Service/ExceptionService.php index 417d5eef8..d3aca54e2 100644 --- a/src/Service/ExceptionService.php +++ b/src/Service/ExceptionService.php @@ -43,6 +43,8 @@ public function getErrorMessages(): array OrderCreationException::WRONG_SHIPPING_PHONE_NUMBER_EXCEPTION => $this->module->l('It looks like you have entered incorrect phone number format in shipping address step. Please change the number and try again.', self::FILE_NAME), OrderCreationException::ORDER_TOTAL_LOWER_THAN_MINIMUM => $this->module->l('Chosen payment option is unavailable for your order total amount. Please consider using other payment option and try again.', self::FILE_NAME), OrderCreationException::ORDER_TOTAL_HIGHER_THAN_MAXIMUM => $this->module->l('Chosen payment option is unavailable for your order total amount. Please consider using other payment option and try again.', self::FILE_NAME), + OrderCreationException::WRONG_GIVEN_NAME => $this->module->l('The first name is invalid. Please check and try again.', self::FILE_NAME), + OrderCreationException::WRONG_FAMILY_NAME => $this->module->l('The second name is invalid. Please check and try again.', self::FILE_NAME), ], ShipmentCannotBeSentException::class => [ ShipmentCannotBeSentException::NO_SHIPPING_INFORMATION => $this->module->l('Shipment information cannot be sent. Order reference (%s) has no shipping information.', self::FILE_NAME),