From de33f510f6e6e16219ab0bf57c74eeb227130edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 9 Jul 2021 15:56:16 +0200 Subject: [PATCH] Support for Braintree in CreateSingleAccount --- app/Console/Commands/CreateSingleAccount.php | 25 ++++++++++++++++++++ config/ninja.php | 1 + 2 files changed, 26 insertions(+) diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index fb5c264fc567..b53626595059 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -441,6 +441,10 @@ class CreateSingleAccount extends Command $invoice = $invoice_calc->getInvoice(); + if ($this->gateway === 'braintree') { + $invoice->amount = 100; // Braintree sandbox only allows payments under 2,000 to complete successfully. + } + $invoice->save(); $invoice->service()->createInvitations()->markSent(); @@ -717,6 +721,27 @@ class CreateSingleAccount extends Command $cg->fees_and_limits = $fees_and_limits; $cg->save(); } + + if (config('ninja.testvars.braintree') && ($this->gateway == 'all' || $this->gateway == 'braintree')) { + $cg = new CompanyGateway; + $cg->company_id = $company->id; + $cg->user_id = $user->id; + $cg->gateway_key = 'f7ec488676d310683fb51802d076d713'; + $cg->require_cvv = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; + $cg->update_details = true; + $cg->config = encrypt(config('ninja.testvars.braintree')); + $cg->save(); + + $gateway_types = $cg->driver(new Client)->gatewayTypes(); + + $fees_and_limits = new stdClass; + $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits; + + $cg->fees_and_limits = $fees_and_limits; + $cg->save(); + } } private function createRecurringInvoice($client) diff --git a/config/ninja.php b/config/ninja.php index 5872d60779f0..c1ca132618bc 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -83,6 +83,7 @@ return [ 'travis' => env('TRAVIS', false), 'test_email' => env('TEST_EMAIL', 'test@example.com'), 'wepay' => env('WEPAY_KEYS', ''), + 'braintree' => env('BRAINTREE_KEYS', ''), ], 'contact' => [ 'email' => env('MAIL_FROM_ADDRESS'),