From e7823ccc43c95ff3e096b64f78c42fec6027b6fe Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 14 Nov 2024 13:11:14 +1100 Subject: [PATCH] Fixes for billing portal purchase v2 --- app/Livewire/BillingPortalPurchasev2.php | 275 ++++++++---------- app/Livewire/Flow2/InvoicePay.php | 8 +- app/Livewire/Flow2/InvoiceSummary.php | 18 +- app/Livewire/Flow2/PaymentMethod.php | 2 +- app/Livewire/Flow2/ProcessPayment.php | 13 + app/Livewire/Flow2/RequiredFields.php | 10 +- app/Livewire/Flow2/Terms.php | 12 +- app/Livewire/RequiredClientInfo.php | 6 - lang/en/texts.php | 1 - .../views/billing-portal/purchasev2.blade.php | 2 +- .../billing-portal-purchasev2.blade.php | 70 ++--- .../components/livewire/terms.blade.php | 10 +- .../flow2/invoices-summary.blade.php | 13 + .../ninja2020/flow2/required-fields.blade.php | 2 +- .../invoices/show_smooth_multi.blade.php | 2 +- 15 files changed, 220 insertions(+), 224 deletions(-) diff --git a/app/Livewire/BillingPortalPurchasev2.php b/app/Livewire/BillingPortalPurchasev2.php index 0d365261a3..ebe0d083a5 100644 --- a/app/Livewire/BillingPortalPurchasev2.php +++ b/app/Livewire/BillingPortalPurchasev2.php @@ -11,27 +11,28 @@ namespace App\Livewire; -use App\DataMapper\ClientSettings; -use App\Factory\ClientFactory; -use App\Jobs\Mail\NinjaMailerJob; -use App\Jobs\Mail\NinjaMailerObject; -use App\Libraries\MultiDB; -use App\Mail\Subscription\OtpCode; -use App\Models\Client; -use App\Models\ClientContact; -use App\Models\Invoice; -use App\Models\RecurringInvoice; -use App\Models\Subscription; -use App\Repositories\ClientContactRepository; -use App\Repositories\ClientRepository; use App\Utils\Number; +use App\Models\Client; +use App\Models\Invoice; +use Livewire\Component; +use App\Libraries\MultiDB; +use Illuminate\Support\Str; +use App\Models\Subscription; +use App\Models\ClientContact; +use InvalidArgumentException; +use App\Factory\ClientFactory; use App\Utils\Traits\MakesHash; +use App\Models\RecurringInvoice; +use App\Jobs\Mail\NinjaMailerJob; +use Livewire\Attributes\Computed; +use App\DataMapper\ClientSettings; +use App\Mail\Subscription\OtpCode; +use App\Jobs\Mail\NinjaMailerObject; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Str; -use InvalidArgumentException; +use App\Repositories\ClientRepository; +use App\Repositories\ClientContactRepository; use Laracasts\Presenter\Exceptions\PresenterException; -use Livewire\Component; class BillingPortalPurchasev2 extends Component { @@ -50,19 +51,9 @@ class BillingPortalPurchasev2 extends Component */ public $email; - /** - * Instance of subscription. - * - * @var \App\Models\Subscription - */ - public $subscription; + + public $subscription_id; - /** - * Instance of client contact. - * - * @var null|ClientContact - */ - public $contact; /** * Id for CompanyGateway record. @@ -90,15 +81,6 @@ class BillingPortalPurchasev2 extends Component * @var array */ public $methods = []; - - /** - * Instance of \App\Models\Invoice - * - * @var Invoice - */ - - public \App\Models\Invoice $invoice; - /** * Coupon model for user input * @@ -123,14 +105,6 @@ class BillingPortalPurchasev2 extends Component */ public $request_data = []; - /** - * Instance of company. - * - * @var \App\Models\Company - */ - public $company; - - /** * Instance of company. * @@ -172,17 +146,27 @@ class BillingPortalPurchasev2 extends Component public ?string $client_city; public ?string $client_postal_code; + #[Computed] + public function subscription() + { + return Subscription::query()->with('company')->find($this->subscription_id); + } + + #[Computed] + public function contact() + { + return auth()->guard('contact')->user(); + } + public function mount() { MultiDB::setDb($this->db); - $this->subscription = Subscription::query()->with('company')->find($this->subscription); - - $this->company = $this->subscription->company; + /** @var \App\Models\Subscription $subscription */ + $subscription = $this->subscription(); if (auth()->guard('contact')->check()) { $this->email = auth()->guard('contact')->user()->email; - $this->contact = auth()->guard('contact')->user(); $this->authenticated = true; $this->payment_started = true; } else { @@ -198,13 +182,13 @@ class BillingPortalPurchasev2 extends Component $this->data = []; - $this->price = $this->subscription->price; // ? + $this->price = $subscription->price; // ? $this->float_amount_total = $this->price; - $this->recurring_products = $this->subscription->service()->recurring_products(); - $this->products = $this->subscription->service()->products(); - $this->optional_recurring_products = $this->subscription->service()->optional_recurring_products(); - $this->optional_products = $this->subscription->service()->optional_products(); + $this->products = $subscription->service()->products(); + $this->recurring_products = $subscription->service()->recurring_products(); + $this->optional_recurring_products = $subscription->service()->optional_recurring_products(); + $this->optional_products = $subscription->service()->optional_products(); $this->bundle = collect(); @@ -213,8 +197,8 @@ class BillingPortalPurchasev2 extends Component if (request()->query('coupon')) { $this->coupon = request()->query('coupon'); $this->handleCoupon(); - } elseif (isset($this->subscription->promo_code) && strlen($this->subscription->promo_code) == 0 && $this->subscription->promo_discount > 0) { - $this->price = $this->subscription->promo_price; + } elseif (isset($subscription->promo_code) && strlen($subscription->promo_code ?? '') == 0 && $subscription->promo_discount > 0) { + $this->price = $subscription->promo_price; } } @@ -229,6 +213,8 @@ class BillingPortalPurchasev2 extends Component $this->resetErrorBag('login'); $this->resetValidation('login'); + $subscription = $this->subscription(); + $code = Cache::get("subscriptions:otp:{$this->email}"); if ($user_code != $code) { @@ -238,14 +224,13 @@ class BillingPortalPurchasev2 extends Component } $contact = ClientContact::where('email', $this->email) - ->where('company_id', $this->subscription->company_id) + ->where('company_id', $subscription->company_id) ->first(); if ($contact) { Auth::guard('contact')->loginUsingId($contact->id, true); - $this->contact = $contact; + } else { - // $this->createClientContact(); $this->createBlankClient(); } @@ -277,13 +262,15 @@ class BillingPortalPurchasev2 extends Component private function emailOtpCode($code) { + $subscription = $this->subscription(); + $cc = new ClientContact(); $cc->email = $this->email; $nmo = new NinjaMailerObject(); - $nmo->mailable = new OtpCode($this->subscription->company, $this->contact, $code); - $nmo->company = $this->subscription->company; - $nmo->settings = $this->subscription->company->settings; + $nmo->mailable = new OtpCode($subscription->company, $cc, $code); + $nmo->company = $subscription->company; + $nmo->settings = $subscription->company->settings; $nmo->to_user = $cc; NinjaMailerJob::dispatch($nmo); } @@ -293,10 +280,13 @@ class BillingPortalPurchasev2 extends Component */ public function handleCoupon() { + + $subscription = $this->subscription(); + $this->resetErrorBag('coupon'); $this->resetValidation('coupon'); - if ($this->coupon == $this->subscription->promo_code) { + if ($this->coupon == $subscription->promo_code) { $this->valid_coupon = true; $this->buildBundle(); } else { @@ -315,6 +305,7 @@ class BillingPortalPurchasev2 extends Component public function buildBundle() { $this->bundle = collect(); + $subscription = $this->subscription(); $data = $this->data; @@ -328,7 +319,7 @@ class BillingPortalPurchasev2 extends Component 'product_key' => $p->product_key, 'unit_cost' => $p->price, 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), - 'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id), + 'price' => Number::formatMoney($total, $subscription->company).' / '. RecurringInvoice::frequencyForKey($subscription->frequency_id), 'total' => $total, 'qty' => $qty, 'is_recurring' => true, @@ -346,7 +337,7 @@ class BillingPortalPurchasev2 extends Component 'product_key' => $p->product_key, 'unit_cost' => $p->price, 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), - 'price' => Number::formatMoney($total, $this->subscription->company), + 'price' => Number::formatMoney($total, $subscription->company), 'total' => $total, 'qty' => $qty, 'is_recurring' => false @@ -369,7 +360,7 @@ class BillingPortalPurchasev2 extends Component 'product_key' => $p->product_key, 'unit_cost' => $p->price, 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), - 'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id), + 'price' => Number::formatMoney($total, $subscription->company).' / '. RecurringInvoice::frequencyForKey($subscription->frequency_id), 'total' => $total, 'qty' => $qty, 'is_recurring' => true @@ -392,7 +383,7 @@ class BillingPortalPurchasev2 extends Component 'product_key' => $p->product_key, 'unit_cost' => $p->price, 'product' => substr(strip_tags($p->markdownNotes()), 0, 50), - 'price' => Number::formatMoney($total, $this->subscription->company), + 'price' => Number::formatMoney($total, $subscription->company), 'total' => $total, 'qty' => $qty, 'is_recurring' => false @@ -401,63 +392,31 @@ class BillingPortalPurchasev2 extends Component } } - $this->sub_total = Number::formatMoney($this->bundle->sum('total'), $this->subscription->company); - $this->recurring_total = Number::formatMoney($this->bundle->where('is_recurring', true)->sum('total'), $this->subscription->company); - $this->non_recurring_total = Number::formatMoney($this->bundle->where('is_recurring', false)->sum('total'), $this->subscription->company); + $this->sub_total = Number::formatMoney($this->bundle->sum('total'), $subscription->company); + $this->recurring_total = Number::formatMoney($this->bundle->where('is_recurring', true)->sum('total'), $subscription->company); + $this->non_recurring_total = Number::formatMoney($this->bundle->where('is_recurring', false)->sum('total'), $subscription->company); $this->total = $this->sub_total; if ($this->valid_coupon) { - if ($this->subscription->is_amount_discount) { - $discount = $this->subscription->promo_discount; + if ($this->subscription()->is_amount_discount) { + $discount = $subscription->promo_discount; } else { - $discount = round($this->bundle->sum('total') * ($this->subscription->promo_discount / 100), 2); + $discount = round($this->bundle->sum('total') * ($subscription->promo_discount / 100), 2); } - $this->discount = Number::formatMoney($discount, $this->subscription->company); + $this->discount = Number::formatMoney($discount, $subscription->company); - $this->total = Number::formatMoney(($this->bundle->sum('total') - $discount), $this->subscription->company); + $this->total = Number::formatMoney(($this->bundle->sum('total') - $discount), $subscription->company); $this->float_amount_total = ($this->bundle->sum('total') - $discount); } else { $this->float_amount_total = $this->bundle->sum('total'); - $this->total = Number::formatMoney($this->float_amount_total, $this->subscription->company); + $this->total = Number::formatMoney($this->float_amount_total, $subscription->company); } return $this; } - /** - * @return $this - * @throws PresenterException - * @throws InvalidArgumentException - */ - // private function createClientContact() - // { - // $company = $this->subscription->company; - // $user = $this->subscription->user; - // $user->setCompany($company); - - // $client_repo = new ClientRepository(new ClientContactRepository()); - // $data = [ - // 'name' => '', - // 'group_settings_id' => $this->subscription->group_id, - // 'contacts' => [ - // ['email' => $this->email], - // ], - // 'client_hash' => Str::random(40), - // 'settings' => ClientSettings::defaults(), - // ]; - - // $client = $client_repo->save($data, ClientFactory::create($company->id, $user->id)); - - // $this->contact = $client->fresh()->contacts()->first(); - - // Auth::guard('contact')->loginUsingId($this->contact->id, true); - - // return $this; - // } - - /** * @param mixed $propertyName * @@ -481,13 +440,14 @@ class BillingPortalPurchasev2 extends Component */ protected function getPaymentMethods(): self { + $contact = $this->contact(); if ($this->float_amount_total == 0) { $this->methods = []; } - if ($this->contact && $this->float_amount_total >= 0) { - $this->methods = $this->contact->client->service()->getPaymentMethods($this->float_amount_total); + if ($contact && $this->float_amount_total >= 0) { + $this->methods = $contact->client->service()->getPaymentMethods($this->float_amount_total); } foreach($this->methods as $method) { @@ -505,11 +465,13 @@ class BillingPortalPurchasev2 extends Component protected function rff() { - $this->contact_first_name = $this->contact->first_name; - $this->contact_last_name = $this->contact->last_name; - $this->contact_email = $this->contact->email; - $this->client_city = $this->contact->client->city; - $this->client_postal_code = $this->contact->client->postal_code; + $contact = $this->contact(); + + $this->contact_first_name = $contact->first_name; + $this->contact_last_name = $contact->last_name; + $this->contact_email = $contact->email; + $this->client_city = $contact->client->city; + $this->client_postal_code = $contact->client->postal_code; if( strlen($this->contact_first_name ?? '') == 0 || @@ -535,15 +497,17 @@ class BillingPortalPurchasev2 extends Component 'contact_email' => ['required', 'email'], ]); + $contact = $this->contact(); + $this->check_rff = false; - $this->contact->first_name = $validated['contact_first_name']; - $this->contact->last_name = $validated['contact_last_name']; - $this->contact->email = $validated['contact_email']; - $this->contact->client->postal_code = $validated['client_postal_code']; - $this->contact->client->city = $validated['client_city']; + $contact->first_name = $validated['contact_first_name']; + $contact->last_name = $validated['contact_last_name']; + $contact->email = $validated['contact_email']; + $contact->client->postal_code = $validated['client_postal_code']; + $contact->client->city = $validated['client_city']; - $this->contact->pushQuietly(); + $contact->pushQuietly(); $this->refreshComponent(); @@ -582,7 +546,10 @@ class BillingPortalPurchasev2 extends Component */ public function handleBeforePaymentEvents(): self { - $eligibility_check = $this->subscription->service()->isEligible($this->contact); + $subscription = $this->subscription(); + $contact = $this->contact(); + + $eligibility_check = $subscription->service()->isEligible($contact); if (is_array($eligibility_check) && $eligibility_check['message'] != 'Success') { $this->is_eligible = false; @@ -592,33 +559,33 @@ class BillingPortalPurchasev2 extends Component } $data = [ - 'client_id' => $this->contact->client->hashed_id, + 'client_id' => $contact->client->hashed_id, 'date' => now()->format('Y-m-d'), 'invitations' => [[ 'key' => '', - 'client_contact_id' => $this->contact->hashed_id, + 'client_contact_id' => $contact->hashed_id, ]], 'user_input_promo_code' => $this->coupon, - 'coupon' => empty($this->subscription->promo_code) ? '' : $this->coupon, + 'coupon' => empty($subscription->promo_code) ? '' : $this->coupon, ]; - $this->invoice = $this->subscription + $invoice = $this->subscription() ->service() - ->createInvoiceV2($this->bundle, $this->contact->client_id, $this->valid_coupon) + ->createInvoiceV2($this->bundle, $contact->client_id, $this->valid_coupon) ->service() ->markSent() ->fillDefaults() ->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; + $this->payable_amount = $invoice->partial > 0 ? \App\Utils\Number::formatValue($invoice->partial, $invoice->client->currency()) : \App\Utils\Number::formatValue($invoice->balance, $invoice->client->currency()); + $this->invoice_hashed_id = $invoice->hashed_id; Cache::put($this->hash, [ - 'subscription_id' => $this->subscription->hashed_id, - 'email' => $this->email ?? $this->contact->email, - 'client_id' => $this->contact->client->hashed_id, - 'invoice_id' => $this->invoice->hashed_id, + 'subscription_id' => $this->subscription()->hashed_id, + 'email' => $this->email ?? $contact->email, + 'client_id' => $contact->client->hashed_id, + 'invoice_id' => $invoice->hashed_id, 'context' => 'purchase', 'campaign' => $this->campaign, 'bundle' => $this->bundle, @@ -635,11 +602,13 @@ class BillingPortalPurchasev2 extends Component */ public function handleTrial() { - return $this->subscription->service()->startTrial([ - 'email' => $this->email ?? $this->contact->email, + $contact = $this->contact(); + + return $this->subscription()->service()->startTrial([ + 'email' => $this->email ?? $contact->email, 'quantity' => $this->quantity, - 'contact_id' => $this->contact->hashed_id, - 'client_id' => $this->contact->client->hashed_id, + 'contact_id' => $contact->hashed_id, + 'client_id' => $contact->client->hashed_id, 'bundle' => $this->bundle, ]); } @@ -652,7 +621,10 @@ class BillingPortalPurchasev2 extends Component */ public function handlePaymentNotRequired() { - $eligibility_check = $this->subscription->service()->isEligible($this->contact); + $subscription = $this->subscription(); + $contact = $this->contact(); + + $eligibility_check = $subscription->service()->isEligible($contact); if (is_array($eligibility_check) && $eligibility_check['message'] != 'Success') { $this->is_eligible = false; @@ -660,9 +632,9 @@ class BillingPortalPurchasev2 extends Component return $this; } - $invoice = $this->subscription + $invoice = $this->subscription() ->service() - ->createInvoiceV2($this->bundle, $this->contact->client_id, $this->valid_coupon) + ->createInvoiceV2($this->bundle, $contact->client_id, $this->valid_coupon) ->service() ->fillDefaults() ->adjustInventory() @@ -674,9 +646,9 @@ class BillingPortalPurchasev2 extends Component ->markPaid() ->save(); - return $this->subscription + return $subscription ->service() - ->handleNoPaymentFlow($invoice, $this->bundle, $this->contact); + ->handleNoPaymentFlow($invoice, $this->bundle, $contact); } @@ -720,8 +692,10 @@ class BillingPortalPurchasev2 extends Component */ protected function createBlankClient() { - $company = $this->subscription->company; - $user = $this->subscription->user; + $subscription = $this->subscription(); + + $company = $subscription->company; + $user = $subscription->user; $user->setCompany($company); $client_repo = new ClientRepository(new ClientContactRepository()); @@ -757,20 +731,20 @@ class BillingPortalPurchasev2 extends Component if ($currency) { $data['settings']->currency_id = $currency->id; } - } elseif ($this->subscription->group_settings && property_exists($this->subscription->group_settings->settings, 'currency_id')) { + } elseif ($subscription->group_settings && property_exists($subscription->group_settings->settings, 'currency_id')) { /** @var \Illuminate\Support\Collection<\App\Models\Currency> */ $currencies = app('currencies'); - $currency = $currencies->first(function ($item) { - return $item->id == $this->subscription->group_settings->settings->currency_id; + $currency = $currencies->first(function ($item) use($subscription) { + return $item->id == $subscription->group_settings->settings->currency_id; }); if ($currency) { $data['settings']->currency_id = $currency->id; } }else { - $data['settings']->currency_id = $this->subscription->company->getSetting('currency_id'); + $data['settings']->currency_id = $subscription->company->getSetting('currency_id'); } if (array_key_exists('locale', $this->request_data)) { @@ -790,8 +764,7 @@ class BillingPortalPurchasev2 extends Component $client = $client_repo->save($data, ClientFactory::create($company->id, $user->id)); $contact = $client->fresh()->contacts->first(); - $this->contact = $contact; - + Auth::guard('contact')->loginUsingId($contact->id, true); return $contact; @@ -811,7 +784,7 @@ class BillingPortalPurchasev2 extends Component $this->email = $this->request_data['email']; } - if ($this->contact instanceof ClientContact) { + if ($this->contact() instanceof ClientContact) { $this->getPaymentMethods(); } diff --git a/app/Livewire/Flow2/InvoicePay.php b/app/Livewire/Flow2/InvoicePay.php index 61482050ee..d868853f82 100644 --- a/app/Livewire/Flow2/InvoicePay.php +++ b/app/Livewire/Flow2/InvoicePay.php @@ -124,8 +124,6 @@ class InvoicePay extends Component #[On('payable-amount')] public function payableAmount($payable_amount) { - // $this->setContext('payable_invoices.0.amount', Number::parseFloat($payable_amount)); // $this->context['payable_invoices'][0]['amount'] = Number::parseFloat($payable_amount); //TODO DB: check parseFloat() - $this->setContext('amount', $payable_amount); $this->under_over_payment = false; } @@ -240,11 +238,7 @@ class InvoicePay extends Component $this->setContext('db', $this->db); // $this->context['db'] = $this->db; $this->setContext('invitation_id', $this->invitation_id); - if(is_array($this->invoices)) - $this->invoices = Invoice::find($this->transformKeys($this->invoices)); - elseif ($this->invoices instanceof \Illuminate\Support\Collection) { - $this->invoices = Invoice::find($this->invoices->pluck('id')); - } + $this->invoices = Invoice::find($this->transformKeys($this->invoices)); $invoices = $this->invoices->filter(function ($i) { $i = $i->service() diff --git a/app/Livewire/Flow2/InvoiceSummary.php b/app/Livewire/Flow2/InvoiceSummary.php index f856ab52e3..35c8559e97 100644 --- a/app/Livewire/Flow2/InvoiceSummary.php +++ b/app/Livewire/Flow2/InvoiceSummary.php @@ -25,14 +25,15 @@ class InvoiceSummary extends Component public $amount; + public $gateway_fee; + public function mount() { - //@TODO for a single invoice - show all details, for multi-invoices, only show the summaries - // $this->invoices = $this->getContext()['invoices']; // $this->context['invitation']->invoice; - + $contact = $this->getContext()['contact']; $this->invoices = $this->getContext()['payable_invoices']; $this->amount = Number::formatMoney($this->getContext()['amount'], $contact->client); + $this->gateway_fee = isset($this->getContext()['gateway_fee']) ? Number::formatMoney($this->getContext()['gateway_fee'], $contact->client) : false; } @@ -43,10 +44,19 @@ class InvoiceSummary extends Component $contact = $this->getContext()['contact']; $this->invoices = $this->getContext()['payable_invoices']; $this->amount = Number::formatMoney($this->getContext()['amount'], $contact->client); + $this->gateway_fee = isset($this->getContext()['gateway_fee']) ? Number::formatMoney($this->getContext()['gateway_fee'], $contact->client) : false; - // $this->invoices = $this->getContext()['invoices']; } + #[On('payment-view-rendered')] + public function handlePaymentViewRendered() + { + + $contact = $this->getContext()['contact']; + $this->amount = Number::formatMoney($this->getContext()['amount'], $contact->client); + $this->gateway_fee = isset($this->getContext()['gateway_fee']) ? Number::formatMoney($this->getContext()['gateway_fee'], $contact->client) : false; + + } public function downloadDocument($invoice_hashed_id) { diff --git a/app/Livewire/Flow2/PaymentMethod.php b/app/Livewire/Flow2/PaymentMethod.php index 8995c2676d..a1c5a0f502 100644 --- a/app/Livewire/Flow2/PaymentMethod.php +++ b/app/Livewire/Flow2/PaymentMethod.php @@ -20,7 +20,7 @@ class PaymentMethod extends Component { use WithSecureContext; - public $invoice; + // public $invoice; public $variables; diff --git a/app/Livewire/Flow2/ProcessPayment.php b/app/Livewire/Flow2/ProcessPayment.php index 322f3de6df..bcc4f34d5f 100644 --- a/app/Livewire/Flow2/ProcessPayment.php +++ b/app/Livewire/Flow2/ProcessPayment.php @@ -58,6 +58,19 @@ class ProcessPayment extends Component throw new PaymentFailed($responder_data['error'], 400); } + if(isset($responder_data['payload']['total']['fee_total'])) + { + + $gateway_fee = data_get($responder_data, 'payload.total.fee_total', false); + $amount = data_get($responder_data, 'payload.total.amount_with_fee', 0); + + $this->setContext('amount', $amount); + $this->setContext('gateway_fee', $gateway_fee); + + $this->dispatch('payment-view-rendered'); + } + + if(isset($responder_data['component']) && $responder_data['component'] == 'CreditPaymentComponent'){ $this->payment_view = $responder_data['view']; $this->payment_data_payload = $responder_data['payload']; diff --git a/app/Livewire/Flow2/RequiredFields.php b/app/Livewire/Flow2/RequiredFields.php index ee637558c3..39ac7a5ab8 100644 --- a/app/Livewire/Flow2/RequiredFields.php +++ b/app/Livewire/Flow2/RequiredFields.php @@ -12,11 +12,12 @@ namespace App\Livewire\Flow2; +use Livewire\Component; use App\Libraries\MultiDB; use App\Models\CompanyGateway; +use Livewire\Attributes\Computed; use App\Services\Client\RFFService; use App\Utils\Traits\WithSecureContext; -use Livewire\Component; class RequiredFields extends Component { @@ -44,7 +45,7 @@ class RequiredFields extends Component public ?string $client_custom_value3; public ?string $client_custom_value4; - public $contact; + // public $contact; /** @var array */ public array $fields = []; @@ -101,11 +102,6 @@ class RequiredFields extends Component else $this->is_loading = false; - // } - - // if ($rff->unfilled_fields > 0) { - // $this->is_loading = false; - // } } public function handleSubmit(array $data) diff --git a/app/Livewire/Flow2/Terms.php b/app/Livewire/Flow2/Terms.php index 95de13bd3a..5c5ffbe9ed 100644 --- a/app/Livewire/Flow2/Terms.php +++ b/app/Livewire/Flow2/Terms.php @@ -12,23 +12,27 @@ namespace App\Livewire\Flow2; -use App\Utils\Traits\WithSecureContext; use Livewire\Component; +use Livewire\Attributes\Computed; +use App\Utils\Traits\WithSecureContext; class Terms extends Component { use WithSecureContext; - public $invoice; - public $variables; public function mount() { - $this->invoice = $this->getContext()['invoices']->first(); $this->variables = $this->getContext()['variables']; } + #[Computed()] + public function invoice() + { + return $this->getContext()['invoices']->first(); + } + public function render() { return render('components.livewire.terms'); diff --git a/app/Livewire/RequiredClientInfo.php b/app/Livewire/RequiredClientInfo.php index b57c4cd42a..66a516aa47 100644 --- a/app/Livewire/RequiredClientInfo.php +++ b/app/Livewire/RequiredClientInfo.php @@ -44,14 +44,8 @@ class RequiredClientInfo extends Component */ public $fields = []; - /** - * @var ClientContact - */ public $contact_id; - /** - * @var \App\Models\Client - */ public $client_id; /** diff --git a/lang/en/texts.php b/lang/en/texts.php index 3737153355..0658d6d3d2 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -2075,7 +2075,6 @@ $lang = array( 'create_expense_category' => 'Create category', 'pro_plan_reports' => ':link to enable reports by joining the Pro Plan', 'mark_ready' => 'Mark Ready', - 'limits' => 'Limits', 'fees' => 'Fees', 'fee' => 'Fee', diff --git a/resources/views/billing-portal/purchasev2.blade.php b/resources/views/billing-portal/purchasev2.blade.php index ff94394bfe..3fcfda4d01 100644 --- a/resources/views/billing-portal/purchasev2.blade.php +++ b/resources/views/billing-portal/purchasev2.blade.php @@ -2,7 +2,7 @@ @section('meta_title', ctrans('texts.purchase')) @section('body') - @livewire('billing-portal-purchasev2', ['subscription' => $subscription->id, 'db' => $subscription->company->db, 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null]) + @livewire('billing-portal-purchasev2', ['subscription_id' => $subscription->id, 'db' => $subscription->company->db, 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null]) @stop @push('footer') 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 986d0d727c..9871e887f5 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 @@ -2,9 +2,9 @@
- {{ $subscription->company->present()->name }} + {{ $this->subscription->company->present()->name }}

- {{ $subscription->name }} + {{ $this->subscription->name }}

@@ -21,18 +21,18 @@ - - - - - + + + + +
    - @if(!empty($subscription->recurring_product_ids)) + @if(!empty($this->subscription->recurring_product_ids)) @foreach($recurring_products as $index => $product)
  • @if(filter_var($product->product_image, FILTER_VALIDATE_URL)) @@ -48,34 +48,34 @@ {!! $product->markdownNotes() !!} -

    {{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }} / {{ App\Models\RecurringInvoice::frequencyForKey($subscription->frequency_id) }}

    +

    {{ \App\Utils\Number::formatMoney($product->price, $this->subscription->company) }} / {{ App\Models\RecurringInvoice::frequencyForKey($this->subscription->frequency_id) }}

- @if($subscription->per_seat_enabled) + @if($this->subscription->per_seat_enabled)

- @if($subscription->use_inventory_management && $product->in_stock_quantity == 0) + @if($this->subscription->use_inventory_management && $product->in_stock_quantity == 0)

Out of stock

@else

{{ ctrans('texts.qty') }}

@endif use_inventory_management && $product->in_stock_quantity == 0) + @if($this->subscription->use_inventory_management && $product->in_stock_quantity == 0) disabled @endif > - @for ($i = 1; $i <= $subscription->maxQuantity($product); $i++) + @for ($i = 1; $i <= $this->subscription->maxQuantity($product); $i++) @endfor @@ -180,7 +180,7 @@ @endforeach @endif - @if(!empty($subscription->optional_product_ids)) + @if(!empty($this->subscription->optional_product_ids)) @foreach($optional_products as $index => $product)
  • @if(filter_var($product->product_image, FILTER_VALIDATE_URL)) @@ -196,7 +196,7 @@ {!! $product->markdownNotes() !!} -

    {{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }}

    +

    {{ \App\Utils\Number::formatMoney($product->price, $this->subscription->company) }}

  • @@ -204,14 +204,14 @@ @if(is_numeric($product->max_quantity))

    - @if($subscription->use_inventory_management && $product->in_stock_quantity == 0) + @if($this->subscription->use_inventory_management && $product->in_stock_quantity == 0)

    Out of stock

    @else

    {{ ctrans('texts.qty') }}

    @endif @@ -248,7 +248,7 @@
    @endforeach - @if(!empty($subscription->promo_code) && !$subscription->trial_enabled) + @if(!empty($this->subscription->promo_code) && !$this->subscription->trial_enabled) @csrf
    @@ -315,7 +315,7 @@ {{ session('message') }} @endcomponent @endif - @if($subscription->trial_enabled) + @if($this->subscription->trial_enabled) @csrf + @endif +