diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index a04392dd6a12..e2c913152178 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -401,7 +401,7 @@ class InvoiceController extends BaseController $invoice = $this->invoice_repo->save($request->all(), $invoice); - $invoice->service()->triggeredActions($request)->deletePdf(); + $invoice->service()->triggeredActions($request)->deletePdf()->touchPdf(); event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); @@ -708,7 +708,7 @@ class InvoiceController extends BaseController } break; case 'cancel': - $invoice = $invoice->service()->handleCancellation()->deletePdf()->save(); + $invoice = $invoice->service()->handleCancellation()->deletePdf()->touchPdf()->save(); if (! $bulk) { $this->itemResponse($invoice); diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index f688ec47dcd2..24de8b99f883 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -95,7 +95,7 @@ class SendRecurring implements ShouldQueue $invoice = $this->createRecurringInvitations($invoice); /* 09-01-2022 ensure we create the PDFs at this point in time! */ - $invoice->service()->touchPdf(); + $invoice->service()->touchPdf(true); nlog("updating recurring invoice dates"); /* Set next date here to prevent a recurring loop forming */ diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 93c61e7482cd..05c2e8f6bfbd 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -80,6 +80,8 @@ class ReminderJob implements ShouldQueue $invoice->service()->touchReminder($reminder_template)->save(); $invoice = $this->calcLateFee($invoice, $reminder_template); + $invoice->service()->touchPdf(); + //check if this reminder needs to be emailed if(in_array($reminder_template, ['reminder1','reminder2','reminder3','reminder_endless']) && $invoice->client->getSetting("enable_".$reminder_template)) { diff --git a/app/Listeners/Invoice/InvoiceArchivedActivity.php b/app/Listeners/Invoice/InvoiceArchivedActivity.php index 1ceff8ede006..4b37f0070c08 100644 --- a/app/Listeners/Invoice/InvoiceArchivedActivity.php +++ b/app/Listeners/Invoice/InvoiceArchivedActivity.php @@ -43,7 +43,7 @@ class InvoiceArchivedActivity implements ShouldQueue { MultiDB::setDb($event->company->db); - $event->invoice->service()->deletePdf(); + // $event->invoice->service()->deletePdf(); $fields = new stdClass; diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index a85229956014..a1e3e279eb38 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -442,7 +442,7 @@ class BaseDriver extends AbstractPaymentDriver $invoices->each(function ($invoice) { - $invoice->service()->deletePdf(); + $invoice->service()->touchPdf(); }); @@ -494,7 +494,7 @@ class BaseDriver extends AbstractPaymentDriver $invoices->each(function ($invoice){ - $invoice->service()->deletePdf(); + $invoice->service()->touchPdf(); }); diff --git a/app/PaymentDrivers/Stripe/BrowserPay.php b/app/PaymentDrivers/Stripe/BrowserPay.php index 22b4cb111cd2..9de0cbcca8fa 100644 --- a/app/PaymentDrivers/Stripe/BrowserPay.php +++ b/app/PaymentDrivers/Stripe/BrowserPay.php @@ -194,13 +194,18 @@ class BrowserPay implements MethodInterface return; } - $domain = config('ninja.app_url'); + // $domain = config('ninja.app_url'); - if (Ninja::isHosted()) { - $domain = isset($this->stripe->company_gateway->company->portal_domain) - ? $this->stripe->company_gateway->company->portal_domain - : $this->stripe->company_gateway->company->domain(); - } + // if (Ninja::isHosted()) { + // $domain = isset($this->stripe->company_gateway->company->portal_domain) + // ? $this->stripe->company_gateway->company->portal_domain + // : $this->stripe->company_gateway->company->domain(); + // } + + $domain = $this->getAppleDomain(); + + if(!$domain) + throw new PaymentFailed('Unable to register Domain with Apple Pay', 500); $response = ApplePayDomain::create([ 'domain_name' => $domain, @@ -212,4 +217,36 @@ class BrowserPay implements MethodInterface $this->stripe->company_gateway->save(); } + + + private function getAppleDomain() + { + + $domain = ''; + + if(Ninja::isHosted()) + { + + if($this->company_gateway->company->portal_mode == 'domain'){ + $domain = $this->company_gateway->company->portal_domain; + } + else{ + $domain = $this->company_gateway->company->subdomain . '.' . config('ninja.app_domain'); + } + + } + else { + + $domain = config('ninja.app_url'); + } + + $parsed_url = parse_url($domain); + + if(array_key_exists('host', $parsed_url)) + return $parsed_url['host']; + + return false; + + } + } diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 23c50125c89d..281cea3ebc8d 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -390,18 +390,27 @@ class InvoiceService */ public function touchPdf($force = false) { - if($force){ + try { + + if($force){ + + $this->invoice->invitations->each(function ($invitation) { + CreateEntityPdf::dispatchNow($invitation); + }); + + return $this; + } $this->invoice->invitations->each(function ($invitation) { - CreateEntityPdf::dispatchNow($invitation); + CreateEntityPdf::dispatch($invitation); }); - - return $this; + } + catch(\Exception $e){ - $this->invoice->invitations->each(function ($invitation) { - CreateEntityPdf::dispatch($invitation); - }); + nlog("failed creating invoices in Touch PDF"); + + } return $this; } diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index 3178eba97862..49443d4168c6 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -89,6 +89,7 @@ class MarkPaid extends AbstractService ->service() ->applyNumber() ->deletePdf() + ->touchPdf() ->save(); $payment->ledger() diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index ca5534245416..e1750713c95b 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -87,7 +87,7 @@ class UpdateInvoicePayment $invoice->refresh(); $invoice->service() - ->deletePdf() + ->touchPdf() ->workFlow() ->save(); diff --git a/app/Utils/Traits/SettingsSaver.php b/app/Utils/Traits/SettingsSaver.php index ac80a055ff49..0699c04325cf 100644 --- a/app/Utils/Traits/SettingsSaver.php +++ b/app/Utils/Traits/SettingsSaver.php @@ -94,7 +94,7 @@ trait SettingsSaver case 'double': return is_float($value) || is_numeric(strval($value)); case 'string': - return ( is_string( $value ) && method_exists($value, '__toString') ) || is_null($value) || is_string($value); + return !is_int($value) || ( is_string( $value ) && method_exists($value, '__toString') ) || is_null($value) || is_string($value); case 'bool': case 'boolean': return is_bool($value) || (int) filter_var($value, FILTER_VALIDATE_BOOLEAN);