I have a stripe bank account verification form that requires integers in a certain format. No decimals, no letters etc. When the user inputs something incorrectly and submits, the page turns into something like this:
Fatal error: Uncaught Stripe\Error\InvalidRequest: Expecting integers...then a bunch of useful but garbage-looking information
Or if the bank account has already been verified then something like this:
Fatal error: Uncaught Stripe\Error\InvalidRequest: This bank account has already been verified.....then a bunch of useful but garbage-looking information
It replaces my page and my logos etc with just this error so the user would have to click the back button to try again.
I realize that I can add my own error checking for these things, like integers would be easy, the already verified would be a little bit more challenging. However, since stripe has already gone through the effort of detecting errors and returning them in this format, i dont want to do my own and re invent the wheel.
So, with all of that being said, how can I keep the user on the same page with the form still visible and just display the error at the top so they know what to fix?
Here is the code that would throw an error if the input is not in the correct format or if there is some other problem:
if ( !empty($_POST["valueOne"]) and !empty( $_POST["valueTwo"]))
{
https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("secret key");
// get the existing bank account
$customer = \Stripe\Customer::retrieve($customerHash);
$bank_account = $customer->sources->retrieve($bankHash);
// verify the account
$bank_account->verify(array('amounts' => array($_POST['valueOne'], $_POST['valueTwo'])));
}