diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 3ce1032ce9c1..d9f781b41797 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -12,8 +12,8 @@ jobs: runs-on: ${{ matrix.operating-system }} strategy: matrix: - operating-system: ['ubuntu-18.04', 'ubuntu-20.04'] - php-versions: ['7.4','8.0','8.1'] + operating-system: ['ubuntu-18.04', 'ubuntu-20.04', 'ubuntu-22.04'] + php-versions: ['8.1'] phpunit-versions: ['latest'] env: @@ -107,7 +107,3 @@ jobs: env: DB_PORT: ${{ job.services.mysql.ports[3306] }} PHP_CS_FIXER_IGNORE_ENV: true - - - name: Run php-cs-fixer - run: | - PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix diff --git a/app/Jobs/Cron/RecurringInvoicesCron.php b/app/Jobs/Cron/RecurringInvoicesCron.php index 330efe77dde9..ca65974bdefa 100644 --- a/app/Jobs/Cron/RecurringInvoicesCron.php +++ b/app/Jobs/Cron/RecurringInvoicesCron.php @@ -40,7 +40,8 @@ class RecurringInvoicesCron public function handle() : void { /* Get all invoices where the send date is less than NOW + 30 minutes() */ - nlog('Sending recurring invoices '.Carbon::now()->format('Y-m-d h:i:s')); + $start = Carbon::now()->format('Y-m-d h:i:s'); + nlog('Sending recurring invoices '.$start); if (! config('ninja.db.multi_db_enabled')) { $recurring_invoices = RecurringInvoice::where('next_send_date', '<=', now()->toDateTimeString()) @@ -119,5 +120,8 @@ class RecurringInvoicesCron }); } } + + nlog("Recurring invoice send duration " . $start . " - " . Carbon::now()->format('Y-m-d h:i:s')); + } } diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 23234de47dfd..598156ce711a 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -100,7 +100,7 @@ class NinjaMailerJob implements ShouldQueue $this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name()); } - // $this->nmo->mailable->tag($this->company->company_key); + $this->nmo->mailable->tag($this->company->company_key); //send email try { diff --git a/app/Jobs/Mail/PaymentFailedMailer.php b/app/Jobs/Mail/PaymentFailedMailer.php index 9fb6b53d31f3..6b09f5f80845 100644 --- a/app/Jobs/Mail/PaymentFailedMailer.php +++ b/app/Jobs/Mail/PaymentFailedMailer.php @@ -41,7 +41,7 @@ class PaymentFailedMailer implements ShouldQueue public ?PaymentHash $payment_hash; - public string $error; + public $error; public Company $company; @@ -55,7 +55,7 @@ class PaymentFailedMailer implements ShouldQueue * @param $company * @param $amount */ - public function __construct(?PaymentHash $payment_hash, Company $company, Client $client, string $error) + public function __construct(?PaymentHash $payment_hash, Company $company, Client $client, $error) { $this->payment_hash = $payment_hash; $this->client = $client; @@ -70,6 +70,10 @@ class PaymentFailedMailer implements ShouldQueue */ public function handle() { + if(!is_string($this->error)){ + $this->error = "Payment failed, no reason given."; + } + //Set DB MultiDB::setDb($this->company->db); App::setLocale($this->client->locale()); diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index c67b28fd6e3f..c22127554ff2 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -127,7 +127,7 @@ class SendRecurring implements ShouldQueue $invoice->invitations->each(function ($invitation) use ($invoice) { if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) { try { - EmailEntity::dispatch($invitation, $invoice->company)->delay(10); + EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(10,20)); } catch (\Exception $e) { nlog($e->getMessage()); } @@ -140,13 +140,13 @@ class SendRecurring implements ShouldQueue if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) { nlog("attempting to autobill {$invoice->number}"); // $invoice->service()->autoBill(); - AutoBill::dispatch($invoice, $this->db)->delay(20); + AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40)); } elseif ($invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->auto_bill_enabled) { if ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay())) { nlog("attempting to autobill {$invoice->number}"); // $invoice->service()->autoBill(); - AutoBill::dispatch($invoice, $this->db)->delay(20); + AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40)); } } } diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index 66007e9f4ed5..b62f402ec0dc 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -96,12 +96,9 @@ class InvoiceEmailEngine extends BaseEmailEngine if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) { $subject_template = $this->template_data['subject']; - nlog('subject = template data'); } elseif (strlen($this->client->getSetting('email_subject_'.$this->reminder_template)) > 0) { $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); - nlog('subject = settings var'); } else { - nlog('subject = default template '.'email_subject_'.$this->reminder_template); $subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_'.$this->reminder_template, $this->client->locale()); // $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); } diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 941cbc8a9637..d4b840c547d3 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -115,12 +115,12 @@ class TemplateEmail extends Mailable 'company' => $company, 'whitelabel' => $this->client->user->account->isPaid() ? true : false, 'logo' => $this->company->present()->logo($settings), - ]) - ->withSymfonyMessage(function ($message) use ($company) { - $message->getHeaders()->addTextHeader('Tag', $company->company_key); - $message->invitation = $this->invitation; - }) - ->tag($company->company_key); + ]); + // ->withSymfonyMessage(function ($message) use ($company) { + // $message->getHeaders()->addTextHeader('Tag', $company->company_key); + // $message->invitation = $this->invitation; + //}); + // ->tag($company->company_key); /*In the hosted platform we need to slow things down a little for Storage to catch up.*/ diff --git a/app/Mail/VendorTemplateEmail.php b/app/Mail/VendorTemplateEmail.php index 94ff1319376d..2211a0adccfe 100644 --- a/app/Mail/VendorTemplateEmail.php +++ b/app/Mail/VendorTemplateEmail.php @@ -109,12 +109,12 @@ class VendorTemplateEmail extends Mailable 'company' => $this->company, 'whitelabel' => $this->vendor->user->account->isPaid() ? true : false, 'logo' => $this->company->present()->logo($settings), - ]) - ->withSymfonyMessage(function ($message) { - $message->getHeaders()->addTextHeader('Tag', $this->company->company_key); - $message->invitation = $this->invitation; - }) - ->tag($this->company->company_key); + ]); + //->withSymfonyMessage(function ($message) { + // $message->getHeaders()->addTextHeader('Tag', $this->company->company_key); + // $message->invitation = $this->invitation; + //}); + // ->tag($this->company->company_key); if(Ninja::isHosted() && $this->invitation){ diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 1a520977060d..d637dfd6a1eb 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -431,6 +431,10 @@ class BaseDriver extends AbstractPaymentDriver public function sendFailureMail($error) { + if(is_object($error)){ + $error = 'Payment Aborted'; + } + if (! is_null($this->payment_hash)) { $this->unWindGatewayFees($this->payment_hash); } diff --git a/app/PaymentDrivers/PayTrace/CreditCard.php b/app/PaymentDrivers/PayTrace/CreditCard.php index 403ca22ed6fe..99d07915e818 100644 --- a/app/PaymentDrivers/PayTrace/CreditCard.php +++ b/app/PaymentDrivers/PayTrace/CreditCard.php @@ -156,7 +156,6 @@ class CreditCard 'zip' => $this->paytrace->client->postal_code, ]; - nlog($data); } public function paymentView($data) diff --git a/app/PaymentDrivers/PaytracePaymentDriver.php b/app/PaymentDrivers/PaytracePaymentDriver.php index f3b3a325d75f..6d82c703a6de 100644 --- a/app/PaymentDrivers/PaytracePaymentDriver.php +++ b/app/PaymentDrivers/PaytracePaymentDriver.php @@ -89,15 +89,11 @@ class PaytracePaymentDriver extends BaseDriver public function refund(Payment $payment, $amount, $return_client_response = false) { - // $cgt = ClientGatewayToken::where('company_gateway_id', $payment->company_gateway_id) - // ->where('gateway_type_id', $payment->gateway_type_id) - // ->first(); $data = [ 'amount' => $amount, - //'customer_id' => $cgt->token, 'transaction_id' => $payment->transaction_reference, - 'integrator_id' => '959195xd1CuC', + 'integrator_id' => $this->company_gateway->getConfigField('integratorId'), ]; $response = $this->gatewayRequest('/v1/transactions/refund/for_transaction', $data); diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index f0ca05eaa34d..25644f29ae56 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -167,6 +167,17 @@ class CreditCard $this->stripe->client->company, ); + //If the user has come from a subscription double check here if we need to redirect. + //08-08-2022 + if($payment->invoices()->whereHas('subscription')->exists()){ + $subscription = $payment->invoices()->first()->subscription; + + if($subscription && array_key_exists('return_url', $subscription->webhook_configuration) && strlen($subscription->webhook_configuration['return_url']) >=1) + return redirect($subscription->webhook_configuration['return_url']); + + } + //08-08-2022 + return redirect()->route('client.payments.show', ['payment' => $this->stripe->encodePrimaryKey($payment->id)]); }