mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for Checkout authorization failure exception handling
This commit is contained in:
parent
af0b459f94
commit
6f0f0a4ffa
@ -124,18 +124,20 @@ class CreditCard implements MethodInterface
|
||||
}
|
||||
} catch (CheckoutApiException $e) {
|
||||
// API error
|
||||
$request_id = $e->request_id;
|
||||
$http_status_code = $e->http_status_code;
|
||||
$request_id = $e->request_id ?: '';
|
||||
$http_status_code = $e->http_status_code ?: '';
|
||||
$error_details = $e->error_details;
|
||||
|
||||
if(is_array($error_details)) {
|
||||
$error_details = end($e->error_details['error_codes']);
|
||||
}
|
||||
|
||||
$human_exception = $error_details ? new \Exception($error_details, 400) : $e;
|
||||
$human_exception = $error_details ? $error_details : $e->getMessage();
|
||||
|
||||
$human_exception = "{$human_exception} - Request ID: {$request_id}";
|
||||
|
||||
throw new PaymentFailed($human_exception, $http_status_code);
|
||||
|
||||
throw new PaymentFailed($human_exception);
|
||||
} catch (CheckoutArgumentException $e) {
|
||||
// Bad arguments
|
||||
|
||||
@ -145,9 +147,9 @@ class CreditCard implements MethodInterface
|
||||
$error_details = end($e->error_details['error_codes']);
|
||||
}
|
||||
|
||||
$human_exception = $error_details ? new \Exception($error_details, 400) : $e;
|
||||
$human_exception = $error_details ? $error_details : $e->getMessage();
|
||||
|
||||
throw new PaymentFailed($human_exception);
|
||||
throw new PaymentFailed($human_exception, 422);
|
||||
} catch (CheckoutAuthorizationException $e) {
|
||||
// Bad Invalid authorization
|
||||
|
||||
@ -157,9 +159,9 @@ class CreditCard implements MethodInterface
|
||||
$error_details = end($e->error_details['error_codes']);
|
||||
}
|
||||
|
||||
$human_exception = $error_details ? new \Exception($error_details, 400) : $e;
|
||||
$human_exception = $error_details ? $error_details : $e->getMessage();
|
||||
|
||||
throw new PaymentFailed($human_exception);
|
||||
throw new PaymentFailed($human_exception, 401);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user