mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Updates for mailers on hosted platform
This commit is contained in:
parent
2aa26a5227
commit
849a9dc113
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user