mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Braintree: Checking if credit card is enabled
This commit is contained in:
parent
3219199d9f
commit
a6aa744ee1
@ -25,6 +25,8 @@ use App\Models\PaymentType;
|
|||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\PaymentDrivers\Braintree\CreditCard;
|
use App\PaymentDrivers\Braintree\CreditCard;
|
||||||
use App\PaymentDrivers\Braintree\PayPal;
|
use App\PaymentDrivers\Braintree\PayPal;
|
||||||
|
use Braintree\Gateway;
|
||||||
|
use Exception;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class BraintreePaymentDriver extends BaseDriver
|
class BraintreePaymentDriver extends BaseDriver
|
||||||
@ -36,7 +38,7 @@ class BraintreePaymentDriver extends BaseDriver
|
|||||||
public $can_authorise_credit_card = true;
|
public $can_authorise_credit_card = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Braintree\Gateway;
|
* @var Gateway;
|
||||||
*/
|
*/
|
||||||
public $gateway;
|
public $gateway;
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ class BraintreePaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
public function init(): void
|
public function init(): void
|
||||||
{
|
{
|
||||||
$this->gateway = new \Braintree\Gateway([
|
$this->gateway = new Gateway([
|
||||||
'environment' => $this->company_gateway->getConfigField('testMode') ? 'sandbox' : 'production',
|
'environment' => $this->company_gateway->getConfigField('testMode') ? 'sandbox' : 'production',
|
||||||
'merchantId' => $this->company_gateway->getConfigField('merchantId'),
|
'merchantId' => $this->company_gateway->getConfigField('merchantId'),
|
||||||
'publicKey' => $this->company_gateway->getConfigField('publicKey'),
|
'publicKey' => $this->company_gateway->getConfigField('publicKey'),
|
||||||
@ -68,10 +70,15 @@ class BraintreePaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
public function gatewayTypes(): array
|
public function gatewayTypes(): array
|
||||||
{
|
{
|
||||||
return [
|
$types = [
|
||||||
GatewayType::CREDIT_CARD,
|
|
||||||
GatewayType::PAYPAL,
|
GatewayType::PAYPAL,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($this->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled) {
|
||||||
|
$types[] = GatewayType::CREDIT_CARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authorizeView($data)
|
public function authorizeView($data)
|
||||||
@ -126,11 +133,11 @@ class BraintreePaymentDriver extends BaseDriver
|
|||||||
return [
|
return [
|
||||||
'transaction_reference' => $response->id,
|
'transaction_reference' => $response->id,
|
||||||
'transaction_response' => json_encode($response),
|
'transaction_response' => json_encode($response),
|
||||||
'success' => (bool) $response->success,
|
'success' => (bool)$response->success,
|
||||||
'description' => $response->status,
|
'description' => $response->status,
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
];
|
];
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return [
|
return [
|
||||||
'transaction_reference' => null,
|
'transaction_reference' => null,
|
||||||
'transaction_response' => json_encode($e->getMessage()),
|
'transaction_response' => json_encode($e->getMessage()),
|
||||||
@ -174,7 +181,7 @@ class BraintreePaymentDriver extends BaseDriver
|
|||||||
'gateway_type_id' => GatewayType::CREDIT_CARD,
|
'gateway_type_id' => GatewayType::CREDIT_CARD,
|
||||||
];
|
];
|
||||||
|
|
||||||
$payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED);
|
$payment = $this->createPayment($data, Payment::STATUS_COMPLETED);
|
||||||
|
|
||||||
SystemLogger::dispatch(
|
SystemLogger::dispatch(
|
||||||
['response' => $result, 'data' => $data],
|
['response' => $result, 'data' => $data],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user