From a2ec713d84410559ae8965633430065de2bd93eb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 7 Jan 2024 10:47:46 +1100 Subject: [PATCH 1/4] fixing for OTP v4 payment links --- .../billing-portal-purchasev2.blade.php | 70 +++++++++++++++++-- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php index 22ed4940b44c..1d3e167d1f71 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php @@ -391,17 +391,68 @@

- + + + + + +
@@ -430,7 +481,7 @@ const input = e.target; this.login = Array.from(Array(this.length), (element, i) => { - return this.$refs[i].value || ""; + return document.getElementById(i.toString()).value || ''; }).join(""); if (input.nextElementSibling && input.value) { @@ -451,8 +502,17 @@ const inputs = Array.from(Array(this.length)); inputs.forEach((element, i) => { - this.$refs[i].value = paste[i] || ''; + document.getElementById(i.toString()).value = paste[i] || ''; }); + + this.login = Array.from(Array(this.length), (element, i) => { + return document.getElementById(i.toString()).value || ''; + }).join(""); + + if(this.login.length == 6){ + this.$wire.handleLogin(this.login); + } + }, handleBackspace(e) { From 98b8b5d3774f873ffa997cc43d14e2a229b845ea Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 7 Jan 2024 20:37:03 +1100 Subject: [PATCH 2/4] Minor fixes --- app/Console/Commands/S3Cleanup.php | 6 ++--- app/Jobs/Company/CompanyExport.php | 2 +- app/Livewire/BillingPortalPurchasev2.php | 22 ++++++++++++++----- .../views/billing-portal/purchasev2.blade.php | 2 ++ .../billing-portal-purchasev2.blade.php | 12 +++------- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/Console/Commands/S3Cleanup.php b/app/Console/Commands/S3Cleanup.php index 0397040120de..b629e20f76e5 100644 --- a/app/Console/Commands/S3Cleanup.php +++ b/app/Console/Commands/S3Cleanup.php @@ -50,9 +50,9 @@ class S3Cleanup extends Command */ public function handle() { - if (!Ninja::isHosted()) { - return; - } + // if (!Ninja::isHosted()) { + // return; + // } $c1 = Company::on('db-ninja-01')->pluck('company_key'); $c2 = Company::on('db-ninja-02')->pluck('company_key'); diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index 9e97bad7f522..1cd862cac912 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -64,7 +64,7 @@ class CompanyExport implements ShouldQueue { MultiDB::setDb($this->company->db); - $this->company = Company::query()->where('company_key', $this->company->company_key)->first(); + // $this->company = Company::query()->where('company_key', $this->company->company_key)->first(); set_time_limit(0); diff --git a/app/Livewire/BillingPortalPurchasev2.php b/app/Livewire/BillingPortalPurchasev2.php index 33524db77138..b554bbd95497 100644 --- a/app/Livewire/BillingPortalPurchasev2.php +++ b/app/Livewire/BillingPortalPurchasev2.php @@ -96,7 +96,8 @@ class BillingPortalPurchasev2 extends Component * * @var Invoice */ - public $invoice; + + public \App\Models\Invoice $invoice; /** * Coupon model for user input @@ -112,6 +113,9 @@ class BillingPortalPurchasev2 extends Component */ public $quantity; + public $invoice_hashed_id = ''; + + public $payable_amount = 0; /** * First-hit request data (queries, locales...). * @@ -160,7 +164,7 @@ class BillingPortalPurchasev2 extends Component public $payment_confirmed = false; public $is_eligible = true; public $not_eligible_message = ''; - + public function mount() { MultiDB::setDb($this->db); @@ -182,6 +186,9 @@ class BillingPortalPurchasev2 extends Component $this->sub_total = 0; $this->float_amount_total = 0; + $this->invoice_hashed_id = ''; + $this->payable_amount = 0; + $this->data = []; $this->price = $this->subscription->price; // ? @@ -493,6 +500,9 @@ class BillingPortalPurchasev2 extends Component $this->payment_method_id = $gateway_type_id; $this->handleBeforePaymentEvents(); + + $this->dispatch('beforePaymentEventsCompleted'); + } /** @@ -500,7 +510,7 @@ class BillingPortalPurchasev2 extends Component * * @return self */ - public function handleBeforePaymentEvents() :self + public function handleBeforePaymentEvents(): self { $eligibility_check = $this->subscription->service()->isEligible($this->contact); @@ -520,7 +530,6 @@ class BillingPortalPurchasev2 extends Component ]], 'user_input_promo_code' => $this->coupon, 'coupon' => empty($this->subscription->promo_code) ? '' : $this->coupon, - ]; $this->invoice = $this->subscription @@ -532,6 +541,9 @@ class BillingPortalPurchasev2 extends Component ->adjustInventory() ->save(); + $this->payable_amount = $this->invoice->partial > 0 ? \App\Utils\Number::formatValue($this->invoice->partial, $this->invoice->client->currency()) : \App\Utils\Number::formatValue($this->invoice->balance, $this->invoice->client->currency()); + $this->invoice_hashed_id = $this->invoice->hashed_id; + Cache::put($this->hash, [ 'subscription_id' => $this->subscription->hashed_id, 'email' => $this->email ?? $this->contact->email, @@ -542,8 +554,6 @@ class BillingPortalPurchasev2 extends Component 'bundle' => $this->bundle, ], now()->addMinutes(60)); - $this->dispatch('beforePaymentEventsCompleted'); - return $this; } diff --git a/resources/views/billing-portal/purchasev2.blade.php b/resources/views/billing-portal/purchasev2.blade.php index 239d2a271f99..311219516e2c 100644 --- a/resources/views/billing-portal/purchasev2.blade.php +++ b/resources/views/billing-portal/purchasev2.blade.php @@ -8,6 +8,8 @@ @push('footer')