Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tzsk
Copy link
Owner

@tzsk tzsk commented Sep 26, 2021

Background

This package throws Laravel's ValidationException when it sees any invalid data in configuration or in the Payment Payload of any sort.

A lot of Issues are being reported where devs are redirected back to the previous page because they are not catching validation exceptions. It is expected cause, that is the default behavior of Laravel for ValidationException.

This PR aims to throw an internal InvalidValueException which will be uncaught. So they will see the exception. They can easily catch this and generate the validation exception there after if they like.

@tzsk tzsk force-pushed the tweak/validation-custom-exception branch from f8611af to 130c495 Compare September 26, 2021 08:33
@tzsk tzsk merged commit d3a9007 into master Sep 26, 2021
@tzsk tzsk deleted the tweak/validation-custom-exception branch September 26, 2021 08:38
@tzsk
Copy link
Owner Author

tzsk commented Sep 26, 2021

If you try to retain the previous behavior, you can use it like the following,

use Tzsk\Payu\Exceptions\InvalidValueException;

...

try {
  return Payu::initiate($transaction)->redirect(route('status'));
} catch (InvalidValueException $e) {
  throw $e->validationException;
}

This will throw the underlying validation exception and your code behavior will remain the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants