From d4c51871efecc378458a59eccf40e41fc9259022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 29 Apr 2021 11:29:28 +0200 Subject: [PATCH] - Update Braintree credit card to use amount_with_fee - Add amount_with_fee to payment hash --- .../Controllers/ClientPortal/PaymentController.php | 2 +- app/PaymentDrivers/Braintree/CreditCard.php | 10 +++++----- .../gateways/braintree/credit_card/pay.blade.php | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 0cd74d6d63bf..78456482827c 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -239,7 +239,7 @@ class PaymentController extends Controller ->get(); } - $hash_data = ['invoices' => $payable_invoices->toArray(), 'credits' => $credit_totals]; + $hash_data = ['invoices' => $payable_invoices->toArray(), 'credits' => $credit_totals, 'amount_with_fee' => max(0, (($invoice_totals + $fee_totals) - $credit_totals))]; if ($request->query('hash')) { $hash_data['billing_context'] = Cache::get($request->query('hash')); diff --git a/app/PaymentDrivers/Braintree/CreditCard.php b/app/PaymentDrivers/Braintree/CreditCard.php index 1ccaac3b78cb..0e79aa692224 100644 --- a/app/PaymentDrivers/Braintree/CreditCard.php +++ b/app/PaymentDrivers/Braintree/CreditCard.php @@ -45,9 +45,9 @@ class CreditCard return render('gateways.braintree.credit_card.authorize', $data); } - public function authorizeResponse($data) + public function authorizeResponse($data): \Illuminate\Http\RedirectResponse { - + return back(); } /** @@ -85,7 +85,7 @@ class CreditCard $this->braintree->payment_hash->save(); $result = $this->braintree->gateway->transaction()->sale([ - 'amount' => '2000.50', + 'amount' => $this->braintree->payment_hash->data->amount_with_fee, 'paymentMethodNonce' => $state['token'], 'deviceData' => $state['client-data'], 'options' => [ @@ -108,7 +108,7 @@ class CreditCard $data = [ 'payment_type' => PaymentType::parseCardType(strtolower($state->server_response->details->cardType)), - 'amount' => 10, + 'amount' => $this->braintree->payment_hash->data->amount_with_fee, 'transaction_reference' => $response->transaction->id, 'gateway_type_id' => GatewayType::CREDIT_CARD, ]; @@ -137,7 +137,7 @@ class CreditCard $this->braintree->client, $response, $this->braintree->client->company, - 10, + $this->braintree->payment_hash->data->amount_with_fee, ); $message = [ diff --git a/resources/views/portal/ninja2020/gateways/braintree/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/braintree/credit_card/pay.blade.php index 25c109c6972f..5dc59263a151 100644 --- a/resources/views/portal/ninja2020/gateways/braintree/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/braintree/credit_card/pay.blade.php @@ -6,6 +6,12 @@ + + @endsection @section('gateway_content')