Updates for mailers on hosted platform

This commit is contained in:
David Bomba 2024-01-27 15:43:37 +11:00
parent 2aa26a5227
commit 849a9dc113
7 changed files with 30 additions and 13 deletions

View File

@ -154,6 +154,7 @@ class NinjaPlanController extends Controller
$account->is_trial = true; $account->is_trial = true;
$account->hosted_company_count = 10; $account->hosted_company_count = 10;
$account->trial_started = now(); $account->trial_started = now();
$account->trial_plan = 'pro';
$account->save(); $account->save();
} }

View File

@ -259,15 +259,23 @@ class NinjaMailerJob implements ShouldQueue
$t = app('translator'); $t = app('translator');
$t->replace(Ninja::transformTranslations($this->nmo->settings)); $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) { switch ($this->nmo->settings->email_sending_method) {
case 'default': case 'default':
$this->mailer = config('mail.default'); $this->mailer = config('mail.default');
// $this->setHostedMailgunMailer(); //should only be activated if hosted platform needs to fall back to mailgun // $this->setHostedMailgunMailer(); //should only be activated if hosted platform needs to fall back to mailgun
break; return $this;
case 'mailgun': case 'mailgun':
$this->mailer = 'mailgun'; $this->mailer = 'mailgun';
$this->setHostedMailgunMailer(); $this->setHostedMailgunMailer();
break; return $this;
case 'gmail': case 'gmail':
$this->mailer = 'gmail'; $this->mailer = 'gmail';
$this->setGmailMailer(); $this->setGmailMailer();

View File

@ -59,7 +59,7 @@ class CleanStaleInvoiceOrder implements ShouldQueue
Invoice::query() Invoice::query()
->withTrashed() ->withTrashed()
->where('status_id', Invoice::STATUS_SENT) ->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) ->where('balance', '>', 0)
->cursor() ->cursor()
->each(function ($invoice) { ->each(function ($invoice) {

View File

@ -363,9 +363,10 @@ class Account extends BaseModel
return false; return false;
} }
$plan_details = $this->getPlanDetails(); //@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));
return $plan_details && $plan_details['trial']; // $plan_details = $this->getPlanDetails();
// return $plan_details && $plan_details['trial'];
} }
public function startTrial($plan): void public function startTrial($plan): void

View File

@ -44,9 +44,6 @@ use Checkout\Payments\Request\Source\RequestIdSource;
use Exception; use Exception;
use Illuminate\Support\Facades\Auth; 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 class CheckoutComPaymentDriver extends BaseDriver
{ {
use SystemLogTrait; use SystemLogTrait;
@ -334,8 +331,10 @@ class CheckoutComPaymentDriver extends BaseDriver
public function updateCustomer() public function updateCustomer()
{ {
nlog("merp");
try { try {
$request = new CustomerRequest(); $request = new CustomerRequest();
$phone = new Phone(); $phone = new Phone();
@ -346,9 +345,9 @@ class CheckoutComPaymentDriver extends BaseDriver
$response = $this->gateway->getCustomersClient()->update("customer_id", $request); $response = $this->gateway->getCustomersClient()->update("customer_id", $request);
} catch (CheckoutApiException $e) { } catch (CheckoutApiException $e) {
nlog($e->getMessage());
} catch (CheckoutAuthorizationException $e) { } catch (CheckoutAuthorizationException $e) {
nlog($e->getMessage());
} }
} }

View File

@ -445,7 +445,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver
"items" => [ "items" => [
[ [
"name" => ctrans('texts.invoice_number').'# '.$invoice->number, "name" => ctrans('texts.invoice_number').'# '.$invoice->number,
"description" => substr($description, 0, 127), "description" => mb_substr($description, 0, 127),
"quantity" => "1", "quantity" => "1",
"unit_amount" => [ "unit_amount" => [
"currency_code" => $this->client->currency()->code, "currency_code" => $this->client->currency()->code,

View File

@ -484,6 +484,14 @@ class Email implements ShouldQueue
*/ */
private function setMailDriver(): self 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) { switch ($this->email_object->settings->email_sending_method) {
case 'default': case 'default':
$this->mailer = config('mail.default'); $this->mailer = config('mail.default');