diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index 89afe88a8cf5..5a1bca2ea7c3 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -154,6 +154,7 @@ class NinjaPlanController extends Controller $account->is_trial = true; $account->hosted_company_count = 10; $account->trial_started = now(); + $account->trial_plan = 'pro'; $account->save(); } diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index b51264af116e..9570e7736283 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -259,15 +259,23 @@ class NinjaMailerJob implements ShouldQueue $t = app('translator'); $t->replace(Ninja::transformTranslations($this->nmo->settings)); + /** Force free/trials onto specific mail driver */ + if(Ninja::isHosted() && !$this->company->account->isPaid()) + { + $this->mailer = 'mailgun'; + $this->setHostedMailgunMailer(); + return $this; + } + switch ($this->nmo->settings->email_sending_method) { case 'default': $this->mailer = config('mail.default'); // $this->setHostedMailgunMailer(); //should only be activated if hosted platform needs to fall back to mailgun - break; + return $this; case 'mailgun': $this->mailer = 'mailgun'; $this->setHostedMailgunMailer(); - break; + return $this; case 'gmail': $this->mailer = 'gmail'; $this->setGmailMailer(); diff --git a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php index 74d2e259da63..aacd7b32d03a 100644 --- a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php +++ b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php @@ -59,7 +59,7 @@ class CleanStaleInvoiceOrder implements ShouldQueue Invoice::query() ->withTrashed() ->where('status_id', Invoice::STATUS_SENT) - ->whereBetween('created_at', [now()->subHours(1), now()->subMinutes(10)]) + ->whereBetween('created_at', [now()->subHours(1), now()->subMinutes(30)]) ->where('balance', '>', 0) ->cursor() ->each(function ($invoice) { diff --git a/app/Models/Account.php b/app/Models/Account.php index 18d09f68eb65..7249f4308085 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -363,9 +363,10 @@ class Account extends BaseModel return false; } - $plan_details = $this->getPlanDetails(); - - return $plan_details && $plan_details['trial']; + //@27-01-2024 - updates for logic around trials + return !$this->plan_paid && $this->trial_started && Carbon::parse($this->trial_started)->addDays(14)->gte(now()->subHours(12)); + // $plan_details = $this->getPlanDetails(); + // return $plan_details && $plan_details['trial']; } public function startTrial($plan): void diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 39bfe23b7473..ce91f337a6bc 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -44,9 +44,6 @@ use Checkout\Payments\Request\Source\RequestIdSource; use Exception; use Illuminate\Support\Facades\Auth; -//use Checkout\Customers\Four\CustomerRequest as FourCustomerRequest; -//use Checkout\Payments\Four\Request\Source\RequestIdSource as SourceRequestIdSource; - class CheckoutComPaymentDriver extends BaseDriver { use SystemLogTrait; @@ -334,8 +331,10 @@ class CheckoutComPaymentDriver extends BaseDriver public function updateCustomer() { + nlog("merp"); + try { - + $request = new CustomerRequest(); $phone = new Phone(); @@ -346,9 +345,9 @@ class CheckoutComPaymentDriver extends BaseDriver $response = $this->gateway->getCustomersClient()->update("customer_id", $request); } catch (CheckoutApiException $e) { - + nlog($e->getMessage()); } catch (CheckoutAuthorizationException $e) { - + nlog($e->getMessage()); } } diff --git a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php index e24e6a2d470d..9a6f1acf86ef 100644 --- a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php +++ b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php @@ -445,7 +445,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver "items" => [ [ "name" => ctrans('texts.invoice_number').'# '.$invoice->number, - "description" => substr($description, 0, 127), + "description" => mb_substr($description, 0, 127), "quantity" => "1", "unit_amount" => [ "currency_code" => $this->client->currency()->code, diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index e1cbb99ef3b2..9f71781b1993 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -484,6 +484,14 @@ class Email implements ShouldQueue */ private function setMailDriver(): self { + + /** Force free/trials onto specific mail driver */ + if(Ninja::isHosted() && !$this->company->account->isPaid()) { + $this->mailer = 'mailgun'; + $this->setHostedMailgunMailer(); + return $this; + } + switch ($this->email_object->settings->email_sending_method) { case 'default': $this->mailer = config('mail.default');