Skip to content

Commit

Permalink
updated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GytisZum committed Dec 16, 2024
1 parent caefb0f commit ff05a6b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
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

0 comments on commit ff05a6b

Please sign in to comment.