From a47040aa1501b0206813c89e07efbe706beb7453 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 28 Jun 2024 12:42:44 +1000 Subject: [PATCH] Updated - now trying to get vite and livewire to play nice --- app/Livewire/Flow2/ProcessPayment.php | 12 +++ app/PaymentDrivers/Stripe/CreditCard.php | 17 +++- app/PaymentDrivers/StripePaymentDriver.php | 5 + .../stripe/credit_card/livewire_pay.blade.php | 94 +++++++++++++++++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 resources/views/portal/ninja2020/gateways/stripe/credit_card/livewire_pay.blade.php diff --git a/app/Livewire/Flow2/ProcessPayment.php b/app/Livewire/Flow2/ProcessPayment.php index a761b8440dab..dd9b8641afe1 100644 --- a/app/Livewire/Flow2/ProcessPayment.php +++ b/app/Livewire/Flow2/ProcessPayment.php @@ -30,6 +30,18 @@ class ProcessPayment extends Component public $isLoading = true; + private string $component_view = ''; + + private array $payment_data_payload = []; + + public $isLoading = true; + + + // public function toJSON() + // { + // nlog("why"); + // } + public function mount() { diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index eab1a98c3262..4f9d565a7fed 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -57,8 +57,16 @@ class CreditCard return redirect()->route('client.payment_methods.index'); } - public function paymentView(array $data) + public function paymentData(array $data) { + $data = $this->getData($data); + + return $data; + } + + private function getData(array $data): array + { + $description = $this->stripe->getDescription(false); $payment_intent_data = [ @@ -77,6 +85,13 @@ class CreditCard $data['intent'] = $this->stripe->createPaymentIntent($payment_intent_data); $data['gateway'] = $this->stripe; + return $data; + } + + public function paymentView(array $data) + { + $data = $this->getData($data); + return render('gateways.stripe.credit_card.pay', $data); } diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index d91e39fc3763..7ec32c7111dd 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -419,6 +419,11 @@ class StripePaymentDriver extends BaseDriver return $this->payment_method->paymentView($data); } + public function processPaymentViewData(array $data): array + { + return $this->payment_method->paymentData($data); + } + public function processPaymentResponse($request) { return $this->payment_method->paymentResponse($request); diff --git a/resources/views/portal/ninja2020/gateways/stripe/credit_card/livewire_pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/credit_card/livewire_pay.blade.php new file mode 100644 index 000000000000..9e6385828435 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/credit_card/livewire_pay.blade.php @@ -0,0 +1,94 @@ + + +
+ + + + @if($stripe_account_id) + + + @else + + @endif + + + + + + +
+ @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.stripe.includes.card_widget') + @include('portal.ninja2020.gateways.includes.pay_now') + + + @script + + @vite('resources/js/clients/payments/stripe-credit-card.js') + @endscript + +
\ No newline at end of file