1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

improve error handling with EWay

This commit is contained in:
David Bomba 2023-06-28 09:57:03 +10:00
parent 1f757cf9e3
commit feb4461812

View File

@ -70,12 +70,17 @@ class CreditCard
$response = $this->eway_driver->init()->eway->createCustomer(\Eway\Rapid\Enum\ApiMethod::DIRECT, $transaction);
$response_status = ErrorCode::getStatus($response->ResponseMessage);
if(property_exists($response, 'ResponseMessage'))
$response_status = ErrorCode::getStatus($response->ResponseMessage);
if (! $response_status['success']) {
$this->eway_driver->sendFailureMail($response_status['message']);
throw new PaymentFailed($response_status['message'], 400);
$this->logResponse($response);
throw new PaymentFailed($response_status['message'] ?? 'Unknown response from gateway, please contact you merchant.', 400);
}
//success
@ -94,6 +99,8 @@ class CreditCard
$token = $this->eway_driver->storeGatewayToken($cgt, []);
$this->logResponse($response);
return $token;
}
@ -135,7 +142,7 @@ class CreditCard
$amount = array_sum(array_column($this->eway_driver->payment_hash->invoices(), 'amount')) + $this->eway_driver->payment_hash->fee_total;
$description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->eway_driver->client->present()->name()}";
// $description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->eway_driver->client->present()->name()}";
$transaction = [
'Payment' => [
@ -152,29 +159,6 @@ class CreditCard
$this->logResponse($response);
// if(!$response || !property_exists($response, 'ResponseMessage'))
// throw new PaymentFailed('The gateway did not return a valid response. Please check your gateway credentials.', 400);
// $response_status = ErrorCode::getStatus($response->ResponseMessage);
// if(!$response_status['success']){
// if($response->getErrors())
// {
// $message = false;
// foreach ($response->getErrors() as $error) {
// $message = \Eway\Rapid::getMessage($error);
// }
// $return_message = $message ?: $response_status['message'];
// }
// $this->eway_driver->sendFailureMail($response_status['message']);
// throw new PaymentFailed($response_status['message'], 400);
// }
if ($response->TransactionStatus) {
$payment = $this->storePayment($response);
} else {