Checkout.com: Checking if credit card is enabled

This commit is contained in:
Benjamin Beganović 2021-06-29 12:32:55 +02:00
parent 722f1b43ea
commit 3219199d9f

View File

@ -72,11 +72,15 @@ class CheckoutComPaymentDriver extends BaseDriver
/** /**
* Returns the default gateway type. * Returns the default gateway type.
*/ */
public function gatewayTypes() public function gatewayTypes(): array
{ {
return [ $types = [];
GatewayType::CREDIT_CARD,
]; if ($this->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled) {
$types[] = GatewayType::CREDIT_CARD;
}
return $types;
} }
/** /**
@ -232,7 +236,7 @@ class CheckoutComPaymentDriver extends BaseDriver
'transaction_reference' => $response->id, 'transaction_reference' => $response->id,
]; ];
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); $payment = $this->createPayment($data, Payment::STATUS_COMPLETED);
SystemLogger::dispatch( SystemLogger::dispatch(
['response' => $response, 'data' => $data], ['response' => $response, 'data' => $data],
@ -269,11 +273,11 @@ class CheckoutComPaymentDriver extends BaseDriver
return false; return false;
} }
} catch (\Exception | CheckoutHttpException $e) { } catch (Exception | CheckoutHttpException $e) {
$this->unWindGatewayFees($payment_hash); $this->unWindGatewayFees($payment_hash);
$message = $e instanceof CheckoutHttpException $message = $e instanceof CheckoutHttpException
? $e->getBody() ? $e->getBody()
: $e->getMessage(); : $e->getMessage();
$data = [ $data = [
'status' => '', 'status' => '',