Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIPRES-432 Error message for incorrect first or last name added #1011

Merged
merged 4 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Exception/OrderCreationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ class OrderCreationException extends \Exception
const ORDER_IS_NOT_CREATED = 7;

const WRONG_FAMILY_NAME = 8;

const WRONG_GIVEN_NAME = 9;
}
2 changes: 2 additions & 0 deletions src/Handler/Exception/OrderExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/Service/ExceptionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading