Using Craft CMS implementing Omnipay. Relatively new to Craft and Onmipay but hoping my general concept knowledge is not off here:
This seemed pretty straightforward, an exception should be caught with a try/catch block no?
// Validate on Omnipay Credentials
$formInputData = array(
'number' => $info->CardNumber,
'expiryMonth' => $info->ExpireMonth,
'expiryYear' => $info->ExpireYear,
'cvv' => $info->SecurityCode,
'first_name' => $info->Cardholder,
'billingAddress1' => $info->CardAddress,
'billingCity' => $info->CardCity,
'billingState' => $info->CardState,
'billingPostcode' => $info->CardZip,
);
//try/catch for Omnipay Invalid Card Exception
try{
$card = new CreditCard($formInputData);
$card->validate();
} catch (Exception $e) {
echo 'blah';
}
This does NOT catch the exception and instead I'm redirected to an exception page saying the following:
Omnipay\Common\Exception\InvalidCreditCardException
Card number should have 12 to 19 digits
This is then followed by a stack trace into the CreditCard class where it throws an exception based on any intentional credit card errors I make.
Why is it not catching the exception and performing my catch block? What needs to be done with Omnipay/Craft to get this exception caught so I can redirect the user to the proper page with the errors listed?