From 454f7df01e88353efa40774057f4f76c1445813e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 6 Sep 2024 18:31:00 +1000 Subject: [PATCH] Powerboard --- app/Livewire/Flow2/InvoiceSummary.php | 7 +- app/Models/Gateway.php | 4 +- .../CBAPowerBoard/CreditCard.php | 9 +- .../CBAPowerBoardPaymentDriver.php | 17 +- .../powerboard/credit_card/pay.blade.php | 150 ++++++++++++++++++ .../gateways/powerboard/pay.blade.php | 10 -- 6 files changed, 173 insertions(+), 24 deletions(-) create mode 100644 resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php delete mode 100644 resources/views/portal/ninja2020/gateways/powerboard/pay.blade.php diff --git a/app/Livewire/Flow2/InvoiceSummary.php b/app/Livewire/Flow2/InvoiceSummary.php index af21a26894a6..f856ab52e3e7 100644 --- a/app/Livewire/Flow2/InvoiceSummary.php +++ b/app/Livewire/Flow2/InvoiceSummary.php @@ -50,7 +50,7 @@ class InvoiceSummary extends Component public function downloadDocument($invoice_hashed_id) { - nlog("here"); + $contact = $this->getContext()['contact']; $_invoices = $this->getContext()['invoices']; $i = $_invoices->first(function ($i) use($invoice_hashed_id){ @@ -61,11 +61,6 @@ class InvoiceSummary extends Component $file = (new \App\Jobs\Entity\CreateRawPdf($i->invitations()->where('client_contact_id', $contact->id)->first()))->handle(); - - nlog("here"); - - nlog($file); - $headers = ['Content-Type' => 'application/pdf']; return response()->streamDownload(function () use ($file) { diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 51537dc1901f..d1276d931348 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -237,8 +237,8 @@ class Gateway extends StaticModel ]; // Rotessa case 64: //b67581d804dbad1743b61c57285142ad - powerboard return [ - - ] + GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], + ]; default: return []; } diff --git a/app/PaymentDrivers/CBAPowerBoard/CreditCard.php b/app/PaymentDrivers/CBAPowerBoard/CreditCard.php index 3207497f3c8c..f8ef176e991a 100644 --- a/app/PaymentDrivers/CBAPowerBoard/CreditCard.php +++ b/app/PaymentDrivers/CBAPowerBoard/CreditCard.php @@ -56,7 +56,10 @@ class CreditCard implements LivewireMethodInterface { // $description = $this->stripe->getDescription(false); $merge = [ - 'publicKey' => $this->powerboard->company_gateway->getConfigField('publicKey'), + 'public_key' => $this->powerboard->company_gateway->getConfigField('publicKey'), + 'widget_endpoint' => $this->powerboard->widget_endpoint, + 'gateway' => $this->powerboard, + 'environment' => $this->powerboard->environment, ]; // $payment_intent_data = [ // 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), @@ -81,7 +84,7 @@ class CreditCard implements LivewireMethodInterface { $data = $this->paymentData($data); - return render('gateways.stripe.credit_card.pay', $data); + return render('gateways.powerboard.credit_card.pay', $data); } public function livewirePaymentView(array $data): string @@ -91,6 +94,8 @@ class CreditCard implements LivewireMethodInterface public function paymentResponse(PaymentResponseRequest $request) { + nlog($request->all()); + // $this->stripe->init(); // $state = [ diff --git a/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php b/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php index 27583f6a69ed..a14c294b117a 100644 --- a/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php +++ b/app/PaymentDrivers/CBAPowerBoardPaymentDriver.php @@ -37,9 +37,11 @@ class CBAPowerBoardPaymentDriver extends BaseDriver public $refundable = true; - protected $api_endpoint = 'https://api.powerboard.commbank.com.au/'; + public string $api_endpoint = 'https://api.powerboard.commbank.com.au/'; - protected $widget_endpoint = 'https://widget.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js'; + public string $widget_endpoint = 'https://widget.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js'; + + public string $environment = 'production_cba'; public static $methods = [ GatewayType::CREDIT_CARD => CreditCard::class, @@ -60,14 +62,19 @@ class CBAPowerBoardPaymentDriver extends BaseDriver { if($this->company_gateway->getConfigField('testMode')) { $this->widget_endpoint = 'https://widget.preproduction.powerboard.commbank.com.au/sdk/latest/widget.umd.min.js'; - $this->api_endpoint = 'https://api.preproduction.powerboard.commbank.com.au/'; } + $this->api_endpoint = 'https://api.preproduction.powerboard.commbank.com.au/'; + $this->environment = 'preproduction_cba'; + } return $this; } public function setPaymentMethod($payment_method_id) { - $this->payment_method = $payment_method_id; + + $class = self::$methods[$payment_method_id]; + + $this->payment_method = new $class($this); return $this; } @@ -80,6 +87,8 @@ class CBAPowerBoardPaymentDriver extends BaseDriver */ public function processPaymentView($data) { + $this->init(); + return $this->payment_method->paymentView($data); } diff --git a/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php new file mode 100644 index 000000000000..35dc0680f9c4 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php @@ -0,0 +1,150 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Credit card', 'card_title' => 'Credit card']) + +@section('gateway_head') + +@endsection + +@section('gateway_content') + +
+ @csrf + + + + + + + + + +
+ + + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.credit_card') }} + @endcomponent + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + + + + @endcomponent + +
+
+
+ @include('portal.ninja2020.gateways.includes.pay_now') + +@endsection + +@section('gateway_footer') + + + + + + + +@endsection + + + diff --git a/resources/views/portal/ninja2020/gateways/powerboard/pay.blade.php b/resources/views/portal/ninja2020/gateways/powerboard/pay.blade.php deleted file mode 100644 index b41083273dc0..000000000000 --- a/resources/views/portal/ninja2020/gateways/powerboard/pay.blade.php +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -
\ No newline at end of file