I am trying to process a credit card (Bambora/Beanstream), and when there is an error, pick out the response code and message out of the Exception array. Here is my code:
try {
$result = $beanstream->payments()->makeCardPayment($payment_data, TRUE);
} catch (\Beanstream\Exception $e) {
//handle exception
print_r($e);
}
The error exception output ($e) begins with:
Beanstream\ApiException Object ( [_message:protected] => Invalid Card Number [_code:protected] => 52 [message:protected] => Invalid Card Number [string:Exception:private] => [code:protected] => 52...
I am simply trying to store "message" and "code" into variables. Thank you.
It looks like an object, not like an array.
Just try to get values from the object: