From 510971b35f4b8f36931cb8ee0ffd5a4035d1726a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Feb 2022 21:06:40 +1100 Subject: [PATCH 01/16] Minor fixes --- app/Jobs/PostMark/ProcessPostmarkWebhook.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index e2f1355f3044..290807e64e7a 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -78,7 +78,8 @@ class ProcessPostmarkWebhook implements ShouldQueue if(!$this->invitation) return; - $this->invitation->email_error = $this->request['Details']; + if(array_key_exists('Details', $this->request)) + $this->invitation->email_error = $this->request['Details']; switch ($this->request['RecordType']) { From 7d106f997ae2be8ab4655c9ba9bcbfc0b8727fc0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Feb 2022 08:18:23 +1100 Subject: [PATCH 02/16] Set defaults for client filters' --- app/Filters/ClientFilters.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index c3039605e090..41e01832da01 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -80,12 +80,12 @@ class ClientFilters extends QueryFilters } - public function id_number(string $id_number):Builder + public function id_number(string $id_number = ''):Builder { return $this->builder->where('id_number', $id_number); } - public function number(string $number):Builder + public function number(string $number = ''):Builder { return $this->builder->where('number', $number); } From 45edf58cf157cc9339265e4fd853f69fc10ab592 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Feb 2022 10:38:47 +1100 Subject: [PATCH 03/16] Remove customer profile and payment profile if we are not storing tokens in auth.net --- .../Authorize/AuthorizeCreditCard.php | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 3c52fd146a0a..d7ac0fa5d810 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -22,6 +22,10 @@ use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\AuthorizePaymentDriver; use App\Utils\Traits\MakesHash; +use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest; +use net\authorize\api\contract\v1\DeleteCustomerProfileRequest; +use net\authorize\api\controller\DeleteCustomerPaymentProfileController; +use net\authorize\api\controller\DeleteCustomerProfileController; /** * Class AuthorizeCreditCard. @@ -69,16 +73,54 @@ class AuthorizeCreditCard $payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data); $payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId(); + $data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']); + if ($request->has('store_card') && $request->input('store_card') === true) { $authorise_payment_method->payment_method = GatewayType::CREDIT_CARD; $client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference); } - - $data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']); + else{ + //remove the payment profile + $this->removePaymentProfile($gateway_customer_reference, $payment_profile_id); + } return $this->handleResponse($data, $request); } + private function removePaymentProfile($customer_profile_id, $customer_payment_profile_id) + { + + $request = new DeleteCustomerPaymentProfileRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $request->setCustomerProfileId($customer_profile_id); + $request->setCustomerPaymentProfileId($customer_payment_profile_id); + $controller = new DeleteCustomerPaymentProfileController($request); + $response = $controller->executeWithApiResponse($this->authorize->mode()); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + nlog("SUCCESS: Delete Customer Payment Profile SUCCESS"); + } + else + nlog("unable to delete profile {$customer_profile_id} with payment id {$customer_payment_profile_id}"); + + // Delete a customer profile + $request = new DeleteCustomerProfileRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $request->setCustomerProfileId( $customer_profile_id ); + + $controller = new DeleteCustomerProfileController($request); + $response = $controller->executeWithApiResponse($this->authorize->mode()); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + nlog("SUCCESS: Delete Customer Payment Profile SUCCESS"); + } + else + nlog("unable to delete profile {$customer_profile_id}"); + + + } + private function processTokenPayment($request) { $client_gateway_token = ClientGatewayToken::query() From 88f117054257d41bf15dc5ecd487534261937f45 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Feb 2022 11:00:46 +1100 Subject: [PATCH 04/16] Fixes for domain set on password query: --- routes/client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/client.php b/routes/client.php index 3e69a4d08225..1c19823e85eb 100644 --- a/routes/client.php +++ b/routes/client.php @@ -18,7 +18,7 @@ Route::post('client/password/reset', 'Auth\ContactResetPasswordController@reset' Route::get('view/{entity_type}/{invitation_key}', 'ClientPortal\EntityViewController@index')->name('client.entity_view'); Route::get('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@password')->name('client.entity_view.password'); Route::post('view/{entity_type}/{invitation_key}/password', 'ClientPortal\EntityViewController@handlePassword'); -Route::post('set_password', 'ClientPortal\EntityViewController@handlePasswordSet')->name('client.set_password'); +Route::post('set_password', 'ClientPortal\EntityViewController@handlePasswordSet')->name('client.set_password')->middleware('domain_db'); Route::get('tmp_pdf/{hash}', 'ClientPortal\TempRouteController@index')->name('tmp_pdf'); From 6298ec5552f17431a52642854be5a8e917c72e87 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Feb 2022 12:40:34 +1100 Subject: [PATCH 05/16] Auth.net customer profile --- .../Authorize/AuthorizeCreditCard.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index d7ac0fa5d810..5c5b2e0a5c53 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -105,18 +105,18 @@ class AuthorizeCreditCard nlog("unable to delete profile {$customer_profile_id} with payment id {$customer_payment_profile_id}"); // Delete a customer profile - $request = new DeleteCustomerProfileRequest(); - $request->setMerchantAuthentication($this->authorize->merchant_authentication); - $request->setCustomerProfileId( $customer_profile_id ); + // $request = new DeleteCustomerProfileRequest(); + // $request->setMerchantAuthentication($this->authorize->merchant_authentication); + // $request->setCustomerProfileId( $customer_profile_id ); - $controller = new DeleteCustomerProfileController($request); - $response = $controller->executeWithApiResponse($this->authorize->mode()); - if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) - { - nlog("SUCCESS: Delete Customer Payment Profile SUCCESS"); - } - else - nlog("unable to delete profile {$customer_profile_id}"); + // $controller = new DeleteCustomerProfileController($request); + // $response = $controller->executeWithApiResponse($this->authorize->mode()); + // if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + // { + // nlog("SUCCESS: Delete Customer Payment Profile SUCCESS"); + // } + // else + // nlog("unable to delete profile {$customer_profile_id}"); } From 164223f554ec2176a669123156722aa851127702 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Feb 2022 14:18:27 +1100 Subject: [PATCH 06/16] Extending Auth.net implementation --- .../Authorize/AuthorizeCustomer.php | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 app/PaymentDrivers/Authorize/AuthorizeCustomer.php diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php new file mode 100644 index 000000000000..9f54b149b3b9 --- /dev/null +++ b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php @@ -0,0 +1,104 @@ +authorize = $authorize; + } + + private function getCustomerProfileIds() + { + + // Get all existing customer profile ID's + $request = new GetCustomerProfileIdsRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $controller = new GetCustomerProfileIdsController($request); + $response = $controller->executeWithApiResponse($this->authorize->mode()); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + + return $response->getIds(); + + // echo "GetCustomerProfileId's SUCCESS: " . "\n"; + // $profileIds[] = $response->getIds(); + // echo "There are " . count($profileIds[0]) . " Customer Profile ID's for this Merchant Name and Transaction Key" . "\n"; + } + else + { + return []; + + nlog( "GetCustomerProfileId's ERROR : Invalid response"); + $errorMessages = $response->getMessages()->getMessage(); + nlog( "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText()); + } + + } + + private function getCustomerProfile($customer_profile_id) + { + + $request = new GetCustomerProfileRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $request->setCustomerProfileId($customer_profile_id); + $controller = new GetCustomerProfileController($request); + $response = $controller->executeWithApiResponse($this->authorize->mode()); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + $profileSelected = $response->getProfile(); + $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); + + return [ + 'profile' => $profileSelected, + 'payment_profiles' => $paymentProfilesSelected, + 'error' => '' + ]; + + } + else + { + + nlog("ERROR : GetCustomerProfile: Invalid response"); + $errorMessages = $response->getMessages()->getMessage(); + nlog("Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText()); + + return [ + 'profile' => NULL, + 'payment_profiles' => NULL, + 'error' => $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText(), + ]; + + } + } + +} + + From f00134cbfb6945a9a7a519f8325bf7e8200f7c4d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Feb 2022 18:05:31 +1100 Subject: [PATCH 07/16] Add client public notes to available variables --- app/Utils/HtmlEngine.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index c96e526d5859..73be66a214a6 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -327,6 +327,7 @@ class HtmlEngine $data['$client_address'] = ['value' => $this->client->present()->address() ?: ' ', 'label' => ctrans('texts.address')]; $data['$client.address'] = &$data['$client_address']; $data['$client.postal_code'] = ['value' => $this->client->postal_code ?: ' ', 'label' => ctrans('texts.postal_code')]; + $data['$client.public_notes'] = ['value' => $this->client->public_notes ?: ' ', 'label' => ctrans('texts.notes')]; $data['$client.city'] = ['value' => $this->client->city ?: ' ', 'label' => ctrans('texts.city')]; $data['$client.state'] = ['value' => $this->client->state ?: ' ', 'label' => ctrans('texts.state')]; $data['$client.id_number'] = &$data['$id_number']; From eb2123bf4ec9c4da62df991451937eaaaafbfc75 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 15 Feb 2022 07:39:14 +1100 Subject: [PATCH 08/16] Fixes for bad sort query filter --- app/Filters/InvoiceFilters.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index d6350dac6b37..6a37b29ae8bd 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -148,6 +148,10 @@ class InvoiceFilters extends QueryFilters { $sort_col = explode('|', $sort); + //catch invalid explode array count + if(count($sort_col) == 1) + return $this->builder; + return $this->builder->orderBy($sort_col[0], $sort_col[1]); } From 2a3c23e25dc14e38dc0d2f0418cdfc5a86703b62 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 15 Feb 2022 15:24:00 +1100 Subject: [PATCH 09/16] Working on important Auth.net customers --- .../Authorize/AuthorizeCreditCard.php | 2 +- .../Authorize/AuthorizeCustomer.php | 82 ++++++++++++++++++- app/PaymentDrivers/AuthorizePaymentDriver.php | 6 ++ 3 files changed, 85 insertions(+), 5 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 5c5b2e0a5c53..db5d2a6b54e7 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -80,7 +80,7 @@ class AuthorizeCreditCard $client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference); } else{ - //remove the payment profile + //remove the payment profile if we are not storing tokens in our system $this->removePaymentProfile($gateway_customer_reference, $payment_profile_id); } diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php index 9f54b149b3b9..440e8d7acdcc 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php @@ -13,8 +13,13 @@ namespace App\PaymentDrivers\Authorize; use App\Exceptions\GenericPaymentDriverFailure; +use App\Factory\ClientContactFactory; +use App\Factory\ClientFactory; use App\Models\Client; +use App\Models\ClientContact; +use App\Models\ClientGatewayToken; use App\PaymentDrivers\AuthorizePaymentDriver; +use Illuminate\Support\Facades\Cache; use net\authorize\api\contract\v1\CreateCustomerProfileRequest; use net\authorize\api\contract\v1\CustomerProfileType; use net\authorize\api\contract\v1\GetCustomerProfileIdsRequest; @@ -48,9 +53,6 @@ class AuthorizeCustomer return $response->getIds(); - // echo "GetCustomerProfileId's SUCCESS: " . "\n"; - // $profileIds[] = $response->getIds(); - // echo "There are " . count($profileIds[0]) . " Customer Profile ID's for this Merchant Name and Transaction Key" . "\n"; } else { @@ -77,7 +79,7 @@ class AuthorizeCustomer $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); return [ - 'profile' => $profileSelected, + 'email' => $profileSelected->getEmail(), 'payment_profiles' => $paymentProfilesSelected, 'error' => '' ]; @@ -99,6 +101,78 @@ class AuthorizeCustomer } } + public function importCustomers() + { + $auth_customers = $this->getCustomerProfileIds(); + $company = $this->authorize->company_gateway->company; + $user = $company->owner(); + + foreach($auth_customers as $customer) + { + + + $profile = $this->getCustomerProfile($customer); + + //if the profile ID already exists in ClientGatewayToken we continue else - add. + if($client = ClientGatewayToken::where('company_id', $company->id)->where('gateway_customer_reference', $customer)->first()){ + + } + elseif($client_contact = ClientContact::where('company_id', $company->id)->where('email', $profile['email'])->first()){ + $client = $client_contact->client; + } + else { + + $first_payment_profile = $profile['payment_profiles'][0]; + + $client = ClientFactory::create($company->id, $user->id); + $billTo = $first_payment_profile->getBillTo(); + $client->address1 = $billTo->getAddress(); + $client->city = $billTo->getCity(); + $client->state = $billTo->getState(); + $client->postal_code = $billTo->getZip(); + $client->country_id = $billTo->getCountry() ? $this->getCountryCode($billTo->getCountry()) : $company->settings->country_id; + $client->save(); + + $client_contact = ClientContactFactory::create($company->id, $user->id); + $client_contact->client_id = $client->id; + $client_contact->first_name = $billTo->getFirstName(); + $client_contact->last_name = $billTo->getLastName(); + $client_contact->email = $profile['email']; + $client_contact->phone = $billTo->getPhoneNumber(); + $client_contact->save(); + } + + if($client){ + + foreach($profile['payment_profiles'] as $payment_profile) + { + + $data['payment_profile_id'] = $payment_profile->getCustomerPaymentProfileId(); + $data['card_number'] = $payment_profile->getPayment()->getCreditCard()->getCardNumber(); + $data['card_expiry'] = $payment_profile->getPayment()->getCreditCard()->getExpirationDate(); + $data['card_type'] = $payment_profile->getPayment()->getCreditCard()->getCardType(); + + return $data; + } + } + + } + //iterate through auth.net list + + //exclude any existing customers (ie. only import their missing payment profiles) + + } + + private function getCountryCode($country_code) + { + $countries = Cache::get('countries'); + + $country = $countries->filter(function ($item) use ($country_code) { + return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code; + })->first(); + + return (string) $country->id; + } } diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 428e1fda1b9d..1bc33c4d0e70 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -18,6 +18,7 @@ use App\Models\Payment; use App\Models\PaymentHash; use App\Models\SystemLog; use App\PaymentDrivers\Authorize\AuthorizeCreditCard; +use App\PaymentDrivers\Authorize\AuthorizeCustomer; use App\PaymentDrivers\Authorize\AuthorizePaymentMethod; use App\PaymentDrivers\Authorize\RefundTransaction; use net\authorize\api\constants\ANetEnvironment; @@ -159,4 +160,9 @@ class AuthorizePaymentDriver extends BaseDriver { return (new AuthorizePaymentMethod($this))->deletePaymentProfile($token->gateway_customer_reference, $token->token); } + + public function import() + { + return (new AuthorizeCustomer($this))->importCustomers(); + } } From 3d117134573f58f3c174057d4febf0b52d82f22e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 15 Feb 2022 15:58:37 +1100 Subject: [PATCH 10/16] Import clients and payment methods via auth.net --- .../Authorize/AuthorizeCustomer.php | 32 ++++++++++++------- app/PaymentDrivers/BaseDriver.php | 5 ++- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php index 440e8d7acdcc..46317749c47d 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php @@ -18,6 +18,7 @@ use App\Factory\ClientFactory; use App\Models\Client; use App\Models\ClientContact; use App\Models\ClientGatewayToken; +use App\Models\GatewayType; use App\PaymentDrivers\AuthorizePaymentDriver; use Illuminate\Support\Facades\Cache; use net\authorize\api\contract\v1\CreateCustomerProfileRequest; @@ -107,21 +108,22 @@ class AuthorizeCustomer $company = $this->authorize->company_gateway->company; $user = $company->owner(); - foreach($auth_customers as $customer) + foreach($auth_customers as $gateway_customer_reference) { - - $profile = $this->getCustomerProfile($customer); + $profile = $this->getCustomerProfile($gateway_customer_reference); //if the profile ID already exists in ClientGatewayToken we continue else - add. - if($client = ClientGatewayToken::where('company_id', $company->id)->where('gateway_customer_reference', $customer)->first()){ - + if($client_gateway_token = ClientGatewayToken::where('company_id', $company->id)->where('gateway_customer_reference', $gateway_customer_reference)->first()){ + nlog("found client"); + $client = $client_gateway_token->client; } elseif($client_contact = ClientContact::where('company_id', $company->id)->where('email', $profile['email'])->first()){ $client = $client_contact->client; + nlog("found client through contact"); } else { - + nlog("creating client"); $first_payment_profile = $profile['payment_profiles'][0]; $client = ClientFactory::create($company->id, $user->id); @@ -144,15 +146,23 @@ class AuthorizeCustomer if($client){ + $this->authorize->setClient($client); + foreach($profile['payment_profiles'] as $payment_profile) { + + $payment_meta = new \stdClass; + $payment_meta->brand = (string) $payment_profile->getPayment()->getCreditCard()->getCardType(); + $payment_meta->last4 = (string) $payment_profile->getPayment()->getCreditCard()->getCardNumber(); + $payment_meta->type = GatewayType::CREDIT_CARD; - $data['payment_profile_id'] = $payment_profile->getCustomerPaymentProfileId(); - $data['card_number'] = $payment_profile->getPayment()->getCreditCard()->getCardNumber(); - $data['card_expiry'] = $payment_profile->getPayment()->getCreditCard()->getExpirationDate(); - $data['card_type'] = $payment_profile->getPayment()->getCreditCard()->getCardType(); + $data['payment_method_id'] = GatewayType::CREDIT_CARD; + $data['payment_meta'] = $payment_meta; + $data['token'] = $payment_profile->getCustomerPaymentProfileId(); + $additional['gateway_customer_reference'] = $gateway_customer_reference; + + $this->authorize->storeGatewayToken($data, $additional); - return $data; } } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 5e6cf9ae0958..0c52bb90819c 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -182,7 +182,10 @@ class BaseDriver extends AbstractPaymentDriver { } - + public function setClient(Client $client) + { + $this->client = $client; + } /************************** Helper methods *************************************/ public function setPaymentHash(PaymentHash $payment_hash) From 5810b7c9a6f6e5ca1c0899ef72ae5fa74f539b92 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 15 Feb 2022 16:00:39 +1100 Subject: [PATCH 11/16] Minor fixes --- app/PaymentDrivers/Authorize/AuthorizeCustomer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php index 46317749c47d..a81522489465 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php @@ -124,8 +124,12 @@ class AuthorizeCustomer } else { nlog("creating client"); + $first_payment_profile = $profile['payment_profiles'][0]; + if(!$first_payment_profile) + continue; + $client = ClientFactory::create($company->id, $user->id); $billTo = $first_payment_profile->getBillTo(); $client->address1 = $billTo->getAddress(); From 910aeebaf7d74b787de9d94a5e971649bdbc2b61 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 15 Feb 2022 21:23:51 +1100 Subject: [PATCH 12/16] Fixes for auth.net --- .../Requests/Invoice/ActionInvoiceRequest.php | 2 +- .../Authorize/AuthorizeCustomer.php | 24 ++++++++++++------- .../Authorize/AuthorizePaymentMethod.php | 1 + .../MailCssInlinerServiceProvider.php | 5 ---- app/Utils/HtmlEngine.php | 3 ++- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/Http/Requests/Invoice/ActionInvoiceRequest.php b/app/Http/Requests/Invoice/ActionInvoiceRequest.php index 15d6d230081e..0196c1bdc012 100644 --- a/app/Http/Requests/Invoice/ActionInvoiceRequest.php +++ b/app/Http/Requests/Invoice/ActionInvoiceRequest.php @@ -30,7 +30,7 @@ class ActionInvoiceRequest extends Request private $invoice; public function authorize() : bool - { + { return auth()->user()->can('edit', $this->invoice); } diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php index a81522489465..34c5eaf5c9c8 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php @@ -115,15 +115,15 @@ class AuthorizeCustomer //if the profile ID already exists in ClientGatewayToken we continue else - add. if($client_gateway_token = ClientGatewayToken::where('company_id', $company->id)->where('gateway_customer_reference', $gateway_customer_reference)->first()){ - nlog("found client"); + // nlog("found client"); $client = $client_gateway_token->client; } elseif($client_contact = ClientContact::where('company_id', $company->id)->where('email', $profile['email'])->first()){ $client = $client_contact->client; - nlog("found client through contact"); + // nlog("found client through contact"); } else { - nlog("creating client"); + // nlog("creating client"); $first_payment_profile = $profile['payment_profiles'][0]; @@ -148,14 +148,25 @@ class AuthorizeCustomer $client_contact->save(); } - if($client){ + if($client && is_array($profile['payment_profiles'])){ $this->authorize->setClient($client); foreach($profile['payment_profiles'] as $payment_profile) { + $token_exists = ClientGatewayToken::where('company_id', $company->id) + ->where('token', $payment_profile->getCustomerPaymentProfileId()) + ->where('gateway_customer_reference', $gateway_customer_reference) + ->exists(); + if($token_exists) + continue; + +// $expiry = $payment_profile->getPayment()->getCreditCard()->getExpirationDate(); + $payment_meta = new \stdClass; + $payment_meta->exp_month = 'xx'; + $payment_meta->exp_year = 'xx'; $payment_meta->brand = (string) $payment_profile->getPayment()->getCreditCard()->getCardType(); $payment_meta->last4 = (string) $payment_profile->getPayment()->getCreditCard()->getCardNumber(); $payment_meta->type = GatewayType::CREDIT_CARD; @@ -171,10 +182,7 @@ class AuthorizeCustomer } } - //iterate through auth.net list - - //exclude any existing customers (ie. only import their missing payment profiles) - + } private function getCountryCode($country_code) diff --git a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php index 26a1b9d6aa48..3910fc487119 100644 --- a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php +++ b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php @@ -130,6 +130,7 @@ class AuthorizePaymentMethod public function buildPaymentMethod($payment_profile) { + $payment_meta = new stdClass; $payment_meta->exp_month = 'xx'; $payment_meta->exp_year = 'xx'; diff --git a/app/Providers/MailCssInlinerServiceProvider.php b/app/Providers/MailCssInlinerServiceProvider.php index ca9f3fb71cf8..a3e223a4a1e8 100644 --- a/app/Providers/MailCssInlinerServiceProvider.php +++ b/app/Providers/MailCssInlinerServiceProvider.php @@ -41,10 +41,5 @@ class MailCssInlinerServiceProvider extends ServiceProvider $this->app->singleton(CssInlinerPlugin::class, function ($app) { return new CssInlinerPlugin([]); }); - - // $this->app->afterResolving('mail.manager', function (MailManager $mailManager) { - // $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class)); - // return $mailManager; - // }); } } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 73be66a214a6..dba31cfb1c7e 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -491,7 +491,8 @@ class HtmlEngine //$data['$entity_footer'] = ['value' => $this->client->getSetting("{$this->entity_string}_footer"), 'label' => '']; $data['$entity_footer'] = ['value' => Helpers::processReservedKeywords(\nl2br($this->entity->footer), $this->client), 'label' => '']; - + $data['$footer'] = &$data['$entity_footer']; + $data['$page_size'] = ['value' => $this->settings->page_size, 'label' => '']; $data['$page_layout'] = ['value' => property_exists($this->settings, 'page_layout') ? $this->settings->page_layout : 'Portrait', 'label' => '']; From c1a39a6ea09364d072d187ca9808249c5915365c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 16 Feb 2022 08:50:28 +1100 Subject: [PATCH 13/16] Run time form requests --- app/Http/Controllers/ImportController.php | 1 + .../Requests/Client/StoreClientRequest.php | 3 +- app/Http/Requests/Request.php | 12 +++++- app/Http/Requests/RuntimeFormRequest.php | 43 +++++++++++++++++++ app/Jobs/Import/CSVImport.php | 8 ++-- 5 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 app/Http/Requests/RuntimeFormRequest.php diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index bb0f320c6c9b..0b462c594c13 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -81,6 +81,7 @@ class ImportController extends Controller { /** @var UploadedFile $file */ foreach ( $request->files->get( 'files' ) as $entityType => $file ) { $contents = file_get_contents( $file->getPathname() ); + // $contents = mb_convert_encoding($contents, 'UTF-16LE', 'UTF-8'); // Store the csv in cache with an expiry of 10 minutes Cache::put( $hash . '-' . $entityType, base64_encode( $contents ), 600 ); diff --git a/app/Http/Requests/Client/StoreClientRequest.php b/app/Http/Requests/Client/StoreClientRequest.php index b1525656173a..7d1b1ed4f7db 100644 --- a/app/Http/Requests/Client/StoreClientRequest.php +++ b/app/Http/Requests/Client/StoreClientRequest.php @@ -25,7 +25,6 @@ use Illuminate\Validation\Rule; class StoreClientRequest extends Request { use MakesHash; - /** * Determine if the user is authorized to make this request. * @@ -89,7 +88,7 @@ class StoreClientRequest extends Request protected function prepareForValidation() { $input = $this->all(); - + $settings = ClientSettings::defaults(); if (array_key_exists('settings', $input) && ! empty($input['settings'])) { diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index 628fb76ef547..74764d51b136 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -11,6 +11,7 @@ namespace App\Http\Requests; +use App\Http\Requests\RuntimeFormRequest; use App\Http\ValidationRules\User\RelatedUserRule; use App\Utils\Traits\MakesHash; use Illuminate\Foundation\Http\FormRequest; @@ -18,7 +19,7 @@ use Illuminate\Foundation\Http\FormRequest; class Request extends FormRequest { use MakesHash; - + use RuntimeFormRequest; /** * Get the validation rules that apply to the request. * @@ -163,9 +164,18 @@ class Request extends FormRequest } } + if (array_key_exists('email', $contact)) + $input['contacts'][$key]['email'] = trim($contact['email']); + + } } return $input; } + + protected function prepareForValidation() + { + + } } diff --git a/app/Http/Requests/RuntimeFormRequest.php b/app/Http/Requests/RuntimeFormRequest.php new file mode 100644 index 000000000000..3f028fc2848a --- /dev/null +++ b/app/Http/Requests/RuntimeFormRequest.php @@ -0,0 +1,43 @@ +setContainer(app()); + + $validator->prepareForValidation(); + + $validator->setValidator(Validator::make($validator->all(), $validator->rules())); + + $instance = $validator->getValidatorInstance(); + + return $instance; + // if ($instance->fails()) { + // return $instance->errors(); + // } + + // $validator->passedValidation(); + + // return $validator->all(); + } + + + protected static function getMockedRequestByParameters($paramters) + { + $mockRequest = Request::create('', 'POST'); + + $mockRequest->merge($paramters); + + return $mockRequest; + } +} \ No newline at end of file diff --git a/app/Jobs/Import/CSVImport.php b/app/Jobs/Import/CSVImport.php index 1933d10ecbbe..4057b949fe1b 100644 --- a/app/Jobs/Import/CSVImport.php +++ b/app/Jobs/Import/CSVImport.php @@ -372,11 +372,13 @@ class CSVImport implements ShouldQueue { $entity = $transformer->transform( $record ); /** @var \App\Http\Requests\Request $request */ - $request = new $request_name(); + // $request = new $request_name(); + // $request->prepareForValidation(); // Pass entity data to request so it can be validated - $request->query = $request->request = new ParameterBag( $entity ); - $validator = Validator::make( $entity, $request->rules() ); + // $request->query = $request->request = new ParameterBag( $entity ); + // $validator = Validator::make( $entity, $request->rules() ); + $validator = $request_name::runFormRequest($entity); if ( $validator->fails() ) { $this->error_array[ $entity_type ][] = From 1efe0fb9928d6ed314ec7bd2d6bd570fec82260d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 16 Feb 2022 09:13:23 +1100 Subject: [PATCH 14/16] Fixes for incorrectly implemented guards --- .../ClientPortal/DocumentController.php | 2 +- app/Http/Livewire/Profile/Settings/General.php | 2 +- .../Livewire/Profile/Settings/NameWebsiteLogo.php | 10 +++++----- .../Livewire/Profile/Settings/PersonalAddress.php | 14 +++++++------- .../Livewire/Profile/Settings/ShippingAddress.php | 14 +++++++------- .../ClientPortal/Documents/ShowDocumentRequest.php | 6 +++--- .../ClientPortal/Tasks/ShowTasksRequest.php | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/DocumentController.php b/app/Http/Controllers/ClientPortal/DocumentController.php index fe48891b05bf..0b78238236c2 100644 --- a/app/Http/Controllers/ClientPortal/DocumentController.php +++ b/app/Http/Controllers/ClientPortal/DocumentController.php @@ -75,7 +75,7 @@ class DocumentController extends Controller ->get(); $documents->map(function ($document) { - if (auth()->user('contact')->client->id != $document->documentable->id) { + if (auth()->guard('contact')->user()->client->id != $document->documentable->id) { abort(401, 'Permission denied'); } }); diff --git a/app/Http/Livewire/Profile/Settings/General.php b/app/Http/Livewire/Profile/Settings/General.php index 4b333431a671..6f77f05a4410 100644 --- a/app/Http/Livewire/Profile/Settings/General.php +++ b/app/Http/Livewire/Profile/Settings/General.php @@ -37,7 +37,7 @@ class General extends Component public function mount() { - $profile = auth()->user('contact'); + $profile = auth()->guard('contact')->user(); $this->fill([ 'profile' => $profile, diff --git a/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php b/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php index dfb5a1e71e94..3101dd2f10d1 100644 --- a/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php +++ b/app/Http/Livewire/Profile/Settings/NameWebsiteLogo.php @@ -25,11 +25,11 @@ class NameWebsiteLogo extends Component public function mount() { $this->fill([ - 'profile' => auth()->user('contact')->client, - 'name' => auth()->user('contact')->client->present()->name, - 'vat_number' => auth()->user('contact')->client->present()->vat_number, - 'website' => auth()->user('contact')->client->present()->website, - 'phone' => auth()->user('contact')->client->present()->phone, + 'profile' => auth()->guard('contact')->user()->client, + 'name' => auth()->guard('contact')->user()->client->present()->name, + 'vat_number' => auth()->guard('contact')->user()->client->present()->vat_number, + 'website' => auth()->guard('contact')->user()->client->present()->website, + 'phone' => auth()->guard('contact')->user()->client->present()->phone, 'saved' => ctrans('texts.save'), ]); } diff --git a/app/Http/Livewire/Profile/Settings/PersonalAddress.php b/app/Http/Livewire/Profile/Settings/PersonalAddress.php index 83fb576ae87a..e423d689d119 100644 --- a/app/Http/Livewire/Profile/Settings/PersonalAddress.php +++ b/app/Http/Livewire/Profile/Settings/PersonalAddress.php @@ -31,13 +31,13 @@ class PersonalAddress extends Component public function mount($countries) { $this->fill([ - 'profile' => auth()->user('contact')->client, - 'address1' => auth()->user('contact')->client->address1, - 'address2' => auth()->user('contact')->client->address2, - 'city' => auth()->user('contact')->client->city, - 'state' => auth()->user('contact')->client->state, - 'postal_code' => auth()->user('contact')->client->postal_code, - 'country_id' => auth()->user('contact')->client->country_id, + 'profile' => auth()->guard('contact')->user()->client, + 'address1' => auth()->guard('contact')->user()->client->address1, + 'address2' => auth()->guard('contact')->user()->client->address2, + 'city' => auth()->guard('contact')->user()->client->city, + 'state' => auth()->guard('contact')->user()->client->state, + 'postal_code' => auth()->guard('contact')->user()->client->postal_code, + 'country_id' => auth()->guard('contact')->user()->client->country_id, 'countries' => $countries, 'saved' => ctrans('texts.save'), diff --git a/app/Http/Livewire/Profile/Settings/ShippingAddress.php b/app/Http/Livewire/Profile/Settings/ShippingAddress.php index 871794cd890b..66035904941a 100644 --- a/app/Http/Livewire/Profile/Settings/ShippingAddress.php +++ b/app/Http/Livewire/Profile/Settings/ShippingAddress.php @@ -31,13 +31,13 @@ class ShippingAddress extends Component public function mount($countries) { $this->fill([ - 'profile' => auth()->user('contact')->client, - 'shipping_address1' => auth()->user('contact')->client->shipping_address1, - 'shipping_address2' => auth()->user('contact')->client->shipping_address2, - 'shipping_city' => auth()->user('contact')->client->shipping_city, - 'shipping_state' => auth()->user('contact')->client->shipping_state, - 'shipping_postal_code' => auth()->user('contact')->client->shipping_postal_code, - 'shipping_country_id' => auth()->user('contact')->client->shipping_country_id, + 'profile' => auth()->guard('contact')->user()->client, + 'shipping_address1' => auth()->guard('contact')->user()->client->shipping_address1, + 'shipping_address2' => auth()->guard('contact')->user()->client->shipping_address2, + 'shipping_city' => auth()->guard('contact')->user()->client->shipping_city, + 'shipping_state' => auth()->guard('contact')->user()->client->shipping_state, + 'shipping_postal_code' => auth()->guard('contact')->user()->client->shipping_postal_code, + 'shipping_country_id' => auth()->guard('contact')->user()->client->shipping_country_id, 'countries' => $countries, 'saved' => ctrans('texts.save'), diff --git a/app/Http/Requests/ClientPortal/Documents/ShowDocumentRequest.php b/app/Http/Requests/ClientPortal/Documents/ShowDocumentRequest.php index a11f50fe6068..97ce78a408b0 100644 --- a/app/Http/Requests/ClientPortal/Documents/ShowDocumentRequest.php +++ b/app/Http/Requests/ClientPortal/Documents/ShowDocumentRequest.php @@ -27,9 +27,9 @@ class ShowDocumentRequest extends FormRequest */ public function authorize() { - return auth()->user('contact')->client->id == $this->document->documentable_id - || $this->document->documentable->client_id == auth()->user('contact')->client->id - || $this->document->company_id == auth()->user('contact')->company->id; + return auth()->guard('contact')->user()->client_id == $this->document->documentable_id + || $this->document->documentable->client_id == auth()->guard('contact')->user()->client_id + || $this->document->company_id == auth()->guard('contact')->user()->company_id; } /** diff --git a/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php b/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php index 91c9366d2d4e..19388598936a 100644 --- a/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php +++ b/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php @@ -23,7 +23,7 @@ class ShowTasksRequest extends FormRequest */ public function authorize() { - return (bool)auth()->user('contact')->client->getSetting('enable_client_portal_tasks'); + return (bool)auth()->guard('contact')->user()->client->getSetting('enable_client_portal_tasks'); } /** From 682ba681208bbddf9befc1f5943cad925f57a55b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 16 Feb 2022 10:47:54 +1100 Subject: [PATCH 15/16] Fixes for show/hide invitation key --- .../Controllers/ClientPortal/CreditController.php | 2 +- .../Controllers/ClientPortal/InvoiceController.php | 4 ++-- .../Controllers/ClientPortal/QuoteController.php | 2 +- .../views/portal/ninja2020/credits/show.blade.php | 4 +++- .../views/portal/ninja2020/invoices/show.blade.php | 9 +++++++-- .../ninja2020/quotes/includes/actions.blade.php | 2 +- .../views/portal/ninja2020/quotes/show.blade.php | 13 ++++++++++--- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/CreditController.php b/app/Http/Controllers/ClientPortal/CreditController.php index 3e69220a1563..9d00714bc4ad 100644 --- a/app/Http/Controllers/ClientPortal/CreditController.php +++ b/app/Http/Controllers/ClientPortal/CreditController.php @@ -34,7 +34,7 @@ class CreditController extends Controller $data = [ 'credit' => $credit, - 'key' => $invitation->key + 'key' => $invitation ? $invitation->key : false ]; if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) { diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 5c9d0bcad82e..b6789e8dfdd8 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -61,7 +61,7 @@ class InvoiceController extends Controller $invoice->service()->removeUnpaidGatewayFees()->save(); - $invitation = $invoice->invitations()->where('client_contact_id', auth()->user()->id)->first(); + $invitation = $invoice->invitations()->where('client_contact_id', auth()->guard('contact')->user()->id)->first(); if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) { @@ -74,7 +74,7 @@ class InvoiceController extends Controller $data = [ 'invoice' => $invoice, - 'key' => $invitation->key + 'key' => $invitation ? $invitation->key : false ]; if ($request->query('mode') === 'fullscreen') { diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index 03b0a648af39..c527d7b7fd46 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -63,7 +63,7 @@ class QuoteController extends Controller $data = [ 'quote' => $quote, - 'key' => $invitation->key, + 'key' => $invitation ? $invitation->key : false, ]; if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) { diff --git a/resources/views/portal/ninja2020/credits/show.blade.php b/resources/views/portal/ninja2020/credits/show.blade.php index 28be1ee665da..0504dce30de7 100644 --- a/resources/views/portal/ninja2020/credits/show.blade.php +++ b/resources/views/portal/ninja2020/credits/show.blade.php @@ -17,12 +17,14 @@ {{ ctrans('texts.entity_number_placeholder', ['entity' => ctrans('texts.credit'), 'entity_number' => $credit->number]) }} -
+ @if($key) + + @endif
diff --git a/resources/views/portal/ninja2020/invoices/show.blade.php b/resources/views/portal/ninja2020/invoices/show.blade.php index 15605a39ad07..a9401ca1ef16 100644 --- a/resources/views/portal/ninja2020/invoices/show.blade.php +++ b/resources/views/portal/ninja2020/invoices/show.blade.php @@ -40,12 +40,15 @@ - {{ ctrans('texts.unpaid') }} -
+ @if($key) + + @endif +
@@ -74,12 +77,14 @@ - {{ \App\Models\Invoice::stringStatus($invoice->status_id) }} -
+ @if($key) + + @endif
diff --git a/resources/views/portal/ninja2020/quotes/includes/actions.blade.php b/resources/views/portal/ninja2020/quotes/includes/actions.blade.php index c3f8696aa791..1a3266815ee4 100644 --- a/resources/views/portal/ninja2020/quotes/includes/actions.blade.php +++ b/resources/views/portal/ninja2020/quotes/includes/actions.blade.php @@ -15,7 +15,7 @@ {{ ctrans('texts.approve') }} -
+ @@ -56,12 +59,14 @@ {{ ctrans('texts.approved') }} -
+ @if($key) + + @endif
@@ -76,12 +81,14 @@ {{ ctrans('texts.expired') }} -
+ @if($key) + + @endif
From fb1e27ba7d53bfd725d2a94b00e4abb159f4ba16 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 16 Feb 2022 13:24:10 +1100 Subject: [PATCH 16/16] Clean up for due date days recurring invoices --- app/Filters/CreditFilters.php | 4 ++-- app/Filters/InvoiceFilters.php | 4 ++-- app/Filters/PaymentFilters.php | 4 ++-- app/Filters/QueryFilters.php | 4 ++-- .../ClientPortal/DocumentController.php | 2 +- .../ClientPortal/NinjaPlanController.php | 2 +- .../ClientPortal/PaymentMethodController.php | 2 +- .../ClientPortal/QuoteController.php | 6 +++--- .../ClientPortal/SubscriptionController.php | 6 +++--- .../ClientPortal/TaskController.php | 2 +- app/Http/Livewire/CreditsTable.php | 2 +- app/Http/Livewire/InvoicesTable.php | 2 +- app/Http/Livewire/PaymentsTable.php | 2 +- app/Http/Livewire/QuotesTable.php | 2 +- app/Http/Livewire/RecurringInvoicesTable.php | 2 +- .../SubscriptionRecurringInvoicesTable.php | 2 +- app/Http/Livewire/TasksTable.php | 2 +- app/Http/Middleware/CheckClientExistence.php | 4 ++-- app/Http/Middleware/Locale.php | 4 ++-- .../Credits/ShowCreditRequest.php | 2 +- .../Credits/ShowCreditsRequest.php | 2 +- .../Invoices/ProcessInvoicesInBulkRequest.php | 2 +- .../Invoices/ShowInvoiceRequest.php | 4 ++-- .../Invoices/ShowInvoicesRequest.php | 2 +- .../Quotes/ProcessQuotesInBulkRequest.php | 2 +- .../ClientPortal/Quotes/ShowQuoteRequest.php | 2 +- .../ClientPortal/Quotes/ShowQuotesRequest.php | 2 +- .../RequestCancellationRequest.php | 2 +- .../ShowRecurringInvoiceRequest.php | 4 ++-- .../ShowRecurringInvoicesRequest.php | 2 +- .../Statements/ShowStatementRequest.php | 2 +- .../Uploads/StoreUploadRequest.php | 2 +- app/Http/ViewComposers/PortalComposer.php | 20 +++++++++---------- app/Models/RecurringInvoice.php | 5 ++--- .../Authorize/AuthorizeCreditCard.php | 2 +- app/PaymentDrivers/Braintree/ACH.php | 2 +- app/PaymentDrivers/CheckoutCom/CreditCard.php | 2 +- app/PaymentDrivers/GoCardless/ACH.php | 12 +++++------ app/PaymentDrivers/GoCardless/DirectDebit.php | 12 +++++------ app/PaymentDrivers/GoCardless/SEPA.php | 12 +++++------ app/PaymentDrivers/Stripe/ACH.php | 12 +++++------ app/PaymentDrivers/Stripe/ACSS.php | 10 +++++----- .../Subscription/SubscriptionService.php | 8 ++++---- app/Services/Subscription/ZeroCostProduct.php | 2 +- .../views/billing-portal/purchase.blade.php | 2 +- .../components/general/footer.blade.php | 6 +++--- .../general/sidebar/desktop.blade.php | 6 +++--- .../general/sidebar/header.blade.php | 8 ++++---- .../general/sidebar/mobile.blade.php | 4 ++-- .../gateways/stripe/ach/authorize.blade.php | 2 +- .../gateways/stripe/becs/authorize.blade.php | 2 +- .../stripe/przelewy24/authorize.blade.php | 2 +- .../gateways/stripe/sepa/authorize.blade.php | 2 +- .../portal/ninja2020/layout/app.blade.php | 2 +- .../ninja2020/layout/clean_setup.blade.php | 2 +- .../ninja2020/layout/payments.blade.php | 2 +- .../views/themes/ninja2020/clean.blade.php | 2 +- 57 files changed, 114 insertions(+), 115 deletions(-) diff --git a/app/Filters/CreditFilters.php b/app/Filters/CreditFilters.php index b3b11e62dcf3..6cf8ec194772 100644 --- a/app/Filters/CreditFilters.php +++ b/app/Filters/CreditFilters.php @@ -163,7 +163,7 @@ class CreditFilters extends QueryFilters */ public function entityFilter() { - if (auth('contact')->user()) { + if (auth()->guard('contact')->user()) { return $this->contactViewFilter(); } else { return $this->builder->company(); @@ -181,7 +181,7 @@ class CreditFilters extends QueryFilters private function contactViewFilter() : Builder { return $this->builder - ->whereCompanyId(auth('contact')->user()->company->id) + ->whereCompanyId(auth()->guard('contact')->user()->company->id) ->whereNotIn('status_id', [Credit::STATUS_DRAFT]); } } diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 6a37b29ae8bd..1a85c6d1af30 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -177,7 +177,7 @@ class InvoiceFilters extends QueryFilters */ public function entityFilter() { - if (auth('contact')->user()) { + if (auth()->guard('contact')->user()) { return $this->contactViewFilter(); } else { return $this->builder->company()->with(['invitations.company'], ['documents.company']); @@ -195,7 +195,7 @@ class InvoiceFilters extends QueryFilters private function contactViewFilter() : Builder { return $this->builder - ->whereCompanyId(auth('contact')->user()->company->id) + ->whereCompanyId(auth()->guard('contact')->user()->company->id) ->whereNotIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_CANCELLED]); } } diff --git a/app/Filters/PaymentFilters.php b/app/Filters/PaymentFilters.php index c7000febaa97..f5c2ba42e500 100644 --- a/app/Filters/PaymentFilters.php +++ b/app/Filters/PaymentFilters.php @@ -119,7 +119,7 @@ class PaymentFilters extends QueryFilters */ public function entityFilter() { - if (auth('contact')->user()) { + if (auth()->guard('contact')->user()) { return $this->contactViewFilter(); } else { return $this->builder->company(); @@ -135,7 +135,7 @@ class PaymentFilters extends QueryFilters private function contactViewFilter() : Builder { return $this->builder - ->whereCompanyId(auth('contact')->user()->company->id) + ->whereCompanyId(auth()->guard('contact')->user()->company->id) ->whereIsDeleted(false); } } diff --git a/app/Filters/QueryFilters.php b/app/Filters/QueryFilters.php index 32d1289b5441..28d9f7300b0b 100644 --- a/app/Filters/QueryFilters.php +++ b/app/Filters/QueryFilters.php @@ -161,8 +161,8 @@ abstract class QueryFilters */ public function clientFilter() { - if (auth('contact')->user()) { - return $this->builder->whereClientId(auth('contact')->user()->client->id); + if (auth()->guard('contact')->user()) { + return $this->builder->whereClientId(auth()->guard('contact')->user()->client->id); } } diff --git a/app/Http/Controllers/ClientPortal/DocumentController.php b/app/Http/Controllers/ClientPortal/DocumentController.php index 0b78238236c2..f24615f13618 100644 --- a/app/Http/Controllers/ClientPortal/DocumentController.php +++ b/app/Http/Controllers/ClientPortal/DocumentController.php @@ -71,7 +71,7 @@ class DocumentController extends Controller public function downloadMultiple(DownloadMultipleDocumentsRequest $request) { $documents = Document::whereIn('id', $this->transformKeys($request->file_hash)) - ->where('company_id', auth('contact')->user()->company->id) + ->where('company_id', auth()->guard('contact')->user()->company->id) ->get(); $documents->map(function ($document) { diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index 2e109d39bf46..985ee7c644f7 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -100,7 +100,7 @@ class NinjaPlanController extends Controller } $recurring_invoice = RecurringInvoice::on('db-ninja-01') - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('company_id', Auth::guard('contact')->user()->company->id) ->whereNotNull('subscription_id') ->where('status_id', RecurringInvoice::STATUS_ACTIVE) diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index f7a3da2728d5..ea16b2326d1f 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -130,7 +130,7 @@ class PaymentMethodController extends Controller try { - event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars(auth('contact')->user()->id))); + event(new MethodDeleted($payment_method, auth()->guard('contact')->user()->company, Ninja::eventVars(auth()->guard('contact')->user()->id))); $payment_method->delete(); diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index c527d7b7fd46..fec64c9b411e 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -160,8 +160,8 @@ class QuoteController extends Controller protected function approve(array $ids, $process = false) { $quotes = Quote::whereIn('id', $ids) - ->where('client_id', auth('contact')->user()->client->id) - ->where('company_id', auth('contact')->user()->client->company_id) + ->where('client_id', auth()->guard('contact')->user()->client->id) + ->where('company_id', auth()->guard('contact')->user()->client->company_id) ->whereIn('status_id', [Quote::STATUS_DRAFT, Quote::STATUS_SENT]) ->withTrashed() ->get(); @@ -175,7 +175,7 @@ class QuoteController extends Controller if ($process) { foreach ($quotes as $quote) { $quote->service()->approve(auth()->user())->save(); - event(new QuoteWasApproved(auth('contact')->user(), $quote, $quote->company, Ninja::eventVars())); + event(new QuoteWasApproved(auth()->guard('contact')->user(), $quote, $quote->company, Ninja::eventVars())); if (request()->has('signature') && !is_null(request()->signature) && !empty(request()->signature)) { InjectSignature::dispatch($quote, request()->signature); diff --git a/app/Http/Controllers/ClientPortal/SubscriptionController.php b/app/Http/Controllers/ClientPortal/SubscriptionController.php index e668299ab74a..861e95e4fbf8 100644 --- a/app/Http/Controllers/ClientPortal/SubscriptionController.php +++ b/app/Http/Controllers/ClientPortal/SubscriptionController.php @@ -26,8 +26,8 @@ class SubscriptionController extends Controller $count = RecurringInvoice::query() - ->where('client_id', auth('contact')->user()->client->id) - ->where('company_id', auth('contact')->user()->client->company_id) + ->where('client_id', auth()->guard('contact')->user()->client->id) + ->where('company_id', auth()->guard('contact')->user()->client->company_id) ->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('is_deleted', 0) ->whereNotNull('subscription_id') @@ -35,7 +35,7 @@ class SubscriptionController extends Controller ->count(); if($count == 0) - return redirect()->route('client.ninja_contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'company_key' => auth('contact')->user()->company->company_key]); + return redirect()->route('client.ninja_contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'company_key' => auth()->guard('contact')->user()->company->company_key]); } diff --git a/app/Http/Controllers/ClientPortal/TaskController.php b/app/Http/Controllers/ClientPortal/TaskController.php index 75d923952e9a..07fe73dcac7b 100644 --- a/app/Http/Controllers/ClientPortal/TaskController.php +++ b/app/Http/Controllers/ClientPortal/TaskController.php @@ -26,7 +26,7 @@ class TaskController extends Controller public function index(ShowTasksRequest $request) { \Carbon\Carbon::setLocale( - auth('contact')->user()->preferredLocale() + auth()->guard('contact')->user()->preferredLocale() ); return render('tasks.index'); diff --git a/app/Http/Livewire/CreditsTable.php b/app/Http/Livewire/CreditsTable.php index fe7f1f1487b2..60b0fe615d28 100644 --- a/app/Http/Livewire/CreditsTable.php +++ b/app/Http/Livewire/CreditsTable.php @@ -36,7 +36,7 @@ class CreditsTable extends Component { $query = Credit::query() - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('company_id', $this->company->id) ->where('status_id', '<>', Credit::STATUS_DRAFT) ->where('is_deleted', 0) diff --git a/app/Http/Livewire/InvoicesTable.php b/app/Http/Livewire/InvoicesTable.php index 68351ecf5919..36bf35237512 100644 --- a/app/Http/Livewire/InvoicesTable.php +++ b/app/Http/Livewire/InvoicesTable.php @@ -75,7 +75,7 @@ class InvoicesTable extends Component } $query = $query - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('status_id', '<>', Invoice::STATUS_DRAFT) ->where('status_id', '<>', Invoice::STATUS_CANCELLED) ->withTrashed() diff --git a/app/Http/Livewire/PaymentsTable.php b/app/Http/Livewire/PaymentsTable.php index 1493f37ef191..5c71579c461b 100644 --- a/app/Http/Livewire/PaymentsTable.php +++ b/app/Http/Livewire/PaymentsTable.php @@ -43,7 +43,7 @@ class PaymentsTable extends Component ->with('type', 'client') ->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED]) ->where('company_id', $this->company->id) - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') ->withTrashed() ->paginate($this->per_page); diff --git a/app/Http/Livewire/QuotesTable.php b/app/Http/Livewire/QuotesTable.php index 1aa996f089d9..644ceca9b5a4 100644 --- a/app/Http/Livewire/QuotesTable.php +++ b/app/Http/Livewire/QuotesTable.php @@ -75,7 +75,7 @@ class QuotesTable extends Component $query = $query ->where('company_id', $this->company->id) - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('status_id', '<>', Quote::STATUS_DRAFT) // ->where(function ($query){ // $query->whereDate('due_date', '>=', now()) diff --git a/app/Http/Livewire/RecurringInvoicesTable.php b/app/Http/Livewire/RecurringInvoicesTable.php index 9eeda33d8582..b6fe09ea90ee 100644 --- a/app/Http/Livewire/RecurringInvoicesTable.php +++ b/app/Http/Livewire/RecurringInvoicesTable.php @@ -40,7 +40,7 @@ class RecurringInvoicesTable extends Component $query = RecurringInvoice::query(); $query = $query - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('company_id', $this->company->id) ->whereIn('status_id', [RecurringInvoice::STATUS_ACTIVE]) ->orderBy('status_id', 'asc') diff --git a/app/Http/Livewire/SubscriptionRecurringInvoicesTable.php b/app/Http/Livewire/SubscriptionRecurringInvoicesTable.php index 3568ff8cf502..fcb56ddb9b87 100644 --- a/app/Http/Livewire/SubscriptionRecurringInvoicesTable.php +++ b/app/Http/Livewire/SubscriptionRecurringInvoicesTable.php @@ -35,7 +35,7 @@ class SubscriptionRecurringInvoicesTable extends Component public function render() { $query = RecurringInvoice::query() - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('company_id', $this->company->id) ->whereNotNull('subscription_id') ->where('is_deleted', false) diff --git a/app/Http/Livewire/TasksTable.php b/app/Http/Livewire/TasksTable.php index 1e36c2eed654..872ce4b72ce9 100644 --- a/app/Http/Livewire/TasksTable.php +++ b/app/Http/Livewire/TasksTable.php @@ -37,7 +37,7 @@ class TasksTable extends Component $query = Task::query() ->where('company_id', $this->company->id) ->where('is_deleted', false) - ->where('client_id', auth('contact')->user()->client->id); + ->where('client_id', auth()->guard('contact')->user()->client->id); if ($this->company->getSetting('show_all_tasks_client_portal') === 'invoiced') { $query = $query->whereNotNull('invoice_id'); diff --git a/app/Http/Middleware/CheckClientExistence.php b/app/Http/Middleware/CheckClientExistence.php index 554e74d8e6a1..f7aab8161afc 100644 --- a/app/Http/Middleware/CheckClientExistence.php +++ b/app/Http/Middleware/CheckClientExistence.php @@ -31,7 +31,7 @@ class CheckClientExistence $multiple_contacts = ClientContact::query() ->with('client.gateway_tokens','company') - ->where('email', auth('contact')->user()->email) + ->where('email', auth()->guard('contact')->user()->email) ->whereNotNull('email') ->where('email', '<>', '') // ->whereNull('deleted_at') @@ -42,7 +42,7 @@ class CheckClientExistence return $query->where('is_deleted', false); }) ->whereHas('company', function ($query){ - return $query->where('id', auth('contact')->user()->client->company_id); + return $query->where('id', auth()->guard('contact')->user()->client->company_id); }) ->get(); diff --git a/app/Http/Middleware/Locale.php b/app/Http/Middleware/Locale.php index d9f5513b8f16..e43d6d7ff7ee 100644 --- a/app/Http/Middleware/Locale.php +++ b/app/Http/Middleware/Locale.php @@ -32,8 +32,8 @@ class Locale if ($request->has('lang')) { $locale = $request->input('lang'); App::setLocale($locale); - } elseif (auth('contact')->user()) { - App::setLocale(auth('contact')->user()->client->locale()); + } elseif (auth()->guard('contact')->user()) { + App::setLocale(auth()->guard('contact')->user()->client->locale()); } elseif (auth()->user()) { try{ diff --git a/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php b/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php index 52b76a8d7321..432e22feda32 100644 --- a/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php +++ b/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php @@ -15,7 +15,7 @@ class ShowCreditRequest extends FormRequest public function authorize() { return !$this->credit->is_deleted - && auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS; + && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS; } /** diff --git a/app/Http/Requests/ClientPortal/Credits/ShowCreditsRequest.php b/app/Http/Requests/ClientPortal/Credits/ShowCreditsRequest.php index 2cff1b9014fb..bf0cc0334663 100644 --- a/app/Http/Requests/ClientPortal/Credits/ShowCreditsRequest.php +++ b/app/Http/Requests/ClientPortal/Credits/ShowCreditsRequest.php @@ -19,7 +19,7 @@ class ShowCreditsRequest extends FormRequest { public function authorize() { - return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS; + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS; } public function rules() diff --git a/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php index e3d9ae96b56c..e341214e8daf 100644 --- a/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php @@ -19,7 +19,7 @@ class ProcessInvoicesInBulkRequest extends FormRequest { public function authorize() { - return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php b/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php index f272521d0821..1795dab2f67e 100644 --- a/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php @@ -23,7 +23,7 @@ class ShowInvoiceRequest extends Request */ public function authorize() : bool { - return auth('contact')->user()->client->id == $this->invoice->client_id - && auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; + return auth()->guard('contact')->user()->client_id == $this->invoice->client_id + && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } } diff --git a/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php b/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php index cf8b13f7a617..013d3c96bde7 100644 --- a/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php @@ -19,7 +19,7 @@ class ShowInvoicesRequest extends FormRequest { public function authorize() { - return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php b/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php index 0c312549230d..096eb41206c4 100644 --- a/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php +++ b/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php @@ -20,7 +20,7 @@ class ProcessQuotesInBulkRequest extends FormRequest { public function authorize() { - return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php b/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php index 72fe286b064c..4c6b819cd5e6 100644 --- a/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php +++ b/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php @@ -20,7 +20,7 @@ class ShowQuoteRequest extends FormRequest public function authorize() { return auth()->user()->client->id === $this->quote->client_id - && auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; + && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php b/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php index 6e92f66e7694..abb9c39dd68f 100644 --- a/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php +++ b/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php @@ -19,7 +19,7 @@ class ShowQuotesRequest extends FormRequest { public function authorize() { - return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php b/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php index c4f1cd4ca470..25acacd46d1d 100644 --- a/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php +++ b/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php @@ -9,7 +9,7 @@ class RequestCancellationRequest extends FormRequest { public function authorize() { - return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php index 66108ed79fba..262c1b46d4e2 100644 --- a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php +++ b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php @@ -18,8 +18,8 @@ class ShowRecurringInvoiceRequest extends Request { public function authorize() : bool { - return auth('contact')->user()->client->id === $this->recurring_invoice->client_id - && auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; + return auth()->guard('contact')->user()->client->id === $this->recurring_invoice->client_id + && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php index eb785596bf1e..a45ffab8b6fc 100644 --- a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php +++ b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php @@ -19,7 +19,7 @@ class ShowRecurringInvoicesRequest extends FormRequest { public function authorize() { - return auth('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; } public function rules() diff --git a/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php b/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php index c205aac9095c..aa571296526a 100644 --- a/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php +++ b/app/Http/Requests/ClientPortal/Statements/ShowStatementRequest.php @@ -44,6 +44,6 @@ class ShowStatementRequest extends FormRequest public function client(): Client { - return auth('contact')->user()->client; + return auth()->guard('contact')->user()->client; } } diff --git a/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php b/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php index 0351e92799d5..a106df59e9ab 100644 --- a/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php +++ b/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php @@ -13,7 +13,7 @@ class StoreUploadRequest extends FormRequest */ public function authorize() { - return (bool) auth('contact')->user()->client->getSetting('client_portal_enable_uploads'); + return (bool) auth()->guard('contact')->user()->client->getSetting('client_portal_enable_uploads'); } /** diff --git a/app/Http/ViewComposers/PortalComposer.php b/app/Http/ViewComposers/PortalComposer.php index e6b79e6f5a83..e31771e1b160 100644 --- a/app/Http/ViewComposers/PortalComposer.php +++ b/app/Http/ViewComposers/PortalComposer.php @@ -51,10 +51,10 @@ class PortalComposer $view->with($this->portalData()); - if (auth('contact')->user()) { + if (auth()->guard('contact')->user()) { App::forgetInstance('translator'); $t = app('translator'); - $t->replace(Ninja::transformTranslations(auth('contact')->user()->client->getMergedSettings())); + $t->replace(Ninja::transformTranslations(auth()->guard('contact')->user()->client->getMergedSettings())); } } @@ -63,21 +63,21 @@ class PortalComposer */ private function portalData() :array { - if (! auth('contact')->user()) { + if (! auth()->guard('contact')->user()) { return []; } - $this->settings = auth('contact')->user()->client->getMergedSettings(); + $this->settings = auth()->guard('contact')->user()->client->getMergedSettings(); $data['sidebar'] = $this->sidebarMenu(); $data['header'] = []; $data['footer'] = []; $data['countries'] = TranslationHelper::getCountries(); - $data['company'] = auth('contact')->user()->company; - $data['client'] = auth('contact')->user()->client; + $data['company'] = auth()->guard('contact')->user()->company; + $data['client'] = auth()->guard('contact')->user()->client; $data['settings'] = $this->settings; $data['currencies'] = TranslationHelper::getCurrencies(); - $data['contact'] = auth('contact')->user(); + $data['contact'] = auth()->guard('contact')->user(); $data['multiple_contacts'] = session()->get('multiple_contacts') ?: collect(); @@ -86,7 +86,7 @@ class PortalComposer private function sidebarMenu() :array { - $enabled_modules = auth('contact')->user()->company->enabled_modules; + $enabled_modules = auth()->guard('contact')->user()->company->enabled_modules; $data = []; // TODO: Enable dashboard once it's completed. @@ -114,13 +114,13 @@ class PortalComposer $data[] = ['title' => ctrans('texts.payment_methods'), 'url' => 'client.payment_methods.index', 'icon' => 'shield']; $data[] = ['title' => ctrans('texts.documents'), 'url' => 'client.documents.index', 'icon' => 'download']; - if (auth('contact')->user()->client->getSetting('enable_client_portal_tasks')) { + if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_tasks')) { $data[] = ['title' => ctrans('texts.tasks'), 'url' => 'client.tasks.index', 'icon' => 'clock']; } $data[] = ['title' => ctrans('texts.statement'), 'url' => 'client.statement', 'icon' => 'activity']; - if(Ninja::isHosted() && auth('contact')->user()->company->id == config('ninja.ninja_default_company_id')) + if(Ninja::isHosted() && auth()->guard('contact')->user()->company->id == config('ninja.ninja_default_company_id')) $data[] = ['title' => ctrans('texts.plan'), 'url' => 'client.plan', 'icon' => 'credit-card']; else $data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar']; diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 689abc16d45a..be15ce093b97 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -458,14 +458,13 @@ class RecurringInvoice extends BaseModel public function calculateDueDate($date) { - //if nothing is set, assume we are using terms. - if(!$this->due_date_days) - return $this->calculateDateFromTerms($date); switch ($this->due_date_days) { case 'terms': + case '': return $this->calculateDateFromTerms($date); break; + default: return $this->setDayOfMonth($date, $this->due_date_days); break; diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index db5d2a6b54e7..612e1cf5649e 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -125,7 +125,7 @@ class AuthorizeCreditCard { $client_gateway_token = ClientGatewayToken::query() ->where('id', $this->decodePrimaryKey($request->token)) - ->where('company_id', auth('contact')->user()->client->company->id) + ->where('company_id', auth()->guard('contact')->user()->client->company->id) ->first(); if (!$client_gateway_token) { diff --git a/app/PaymentDrivers/Braintree/ACH.php b/app/PaymentDrivers/Braintree/ACH.php index de109c54cbff..fcc7a1406ccf 100644 --- a/app/PaymentDrivers/Braintree/ACH.php +++ b/app/PaymentDrivers/Braintree/ACH.php @@ -109,7 +109,7 @@ class ACH implements MethodInterface $customer = $this->braintree->findOrCreateCustomer(); $token = ClientGatewayToken::query() - ->where('client_id', auth('contact')->user()->client->id) + ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('id', $this->decodePrimaryKey($request->source)) ->firstOrFail(); diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index 04fe776dc5c1..f6c97c24e4c0 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -145,7 +145,7 @@ class CreditCard implements MethodInterface { $cgt = ClientGatewayToken::query() ->where('id', $this->decodePrimaryKey($request->input('token'))) - ->where('company_id', auth('contact')->user()->client->company->id) + ->where('company_id', auth()->guard('contact')->user()->client->company->id) ->first(); if (!$cgt) { diff --git a/app/PaymentDrivers/GoCardless/ACH.php b/app/PaymentDrivers/GoCardless/ACH.php index c466754f58fa..c15f0795f52b 100644 --- a/app/PaymentDrivers/GoCardless/ACH.php +++ b/app/PaymentDrivers/GoCardless/ACH.php @@ -64,12 +64,12 @@ class ACH implements MethodInterface 'session_token' => $session_token, ]), "prefilled_customer" => [ - "given_name" => auth('contact')->user()->first_name, - "family_name" => auth('contact')->user()->last_name, - "email" => auth('contact')->user()->email, - "address_line1" => auth('contact')->user()->client->address1, - "city" => auth('contact')->user()->client->city, - "postal_code" => auth('contact')->user()->client->postal_code, + "given_name" => auth()->guard('contact')->user()->first_name, + "family_name" => auth()->guard('contact')->user()->last_name, + "email" => auth()->guard('contact')->user()->email, + "address_line1" => auth()->guard('contact')->user()->client->address1, + "city" => auth()->guard('contact')->user()->client->city, + "postal_code" => auth()->guard('contact')->user()->client->postal_code, ], ], ]); diff --git a/app/PaymentDrivers/GoCardless/DirectDebit.php b/app/PaymentDrivers/GoCardless/DirectDebit.php index 51ae2fb1de91..cebefcc9735b 100644 --- a/app/PaymentDrivers/GoCardless/DirectDebit.php +++ b/app/PaymentDrivers/GoCardless/DirectDebit.php @@ -62,12 +62,12 @@ class DirectDebit implements MethodInterface 'session_token' => $session_token, ]), 'prefilled_customer' => [ - 'given_name' => auth('contact')->user()->first_name, - 'family_name' => auth('contact')->user()->last_name, - 'email' => auth('contact')->user()->email, - 'address_line1' => auth('contact')->user()->client->address1, - 'city' => auth('contact')->user()->client->city, - 'postal_code' => auth('contact')->user()->client->postal_code, + 'given_name' => auth()->guard('contact')->user()->first_name, + 'family_name' => auth()->guard('contact')->user()->last_name, + 'email' => auth()->guard('contact')->user()->email, + 'address_line1' => auth()->guard('contact')->user()->client->address1, + 'city' => auth()->guard('contact')->user()->client->city, + 'postal_code' => auth()->guard('contact')->user()->client->postal_code, ], ], ]); diff --git a/app/PaymentDrivers/GoCardless/SEPA.php b/app/PaymentDrivers/GoCardless/SEPA.php index d14d84a69d34..8e4d1312848d 100644 --- a/app/PaymentDrivers/GoCardless/SEPA.php +++ b/app/PaymentDrivers/GoCardless/SEPA.php @@ -63,12 +63,12 @@ class SEPA implements MethodInterface 'session_token' => $session_token, ]), 'prefilled_customer' => [ - 'given_name' => auth('contact')->user()->first_name, - 'family_name' => auth('contact')->user()->last_name, - 'email' => auth('contact')->user()->email, - 'address_line1' => auth('contact')->user()->client->address1, - 'city' => auth('contact')->user()->client->city, - 'postal_code' => auth('contact')->user()->client->postal_code, + 'given_name' => auth()->guard('contact')->user()->first_name, + 'family_name' => auth()->guard('contact')->user()->last_name, + 'email' => auth()->guard('contact')->user()->email, + 'address_line1' => auth()->guard('contact')->user()->client->address1, + 'city' => auth()->guard('contact')->user()->client->city, + 'postal_code' => auth()->guard('contact')->user()->client->postal_code, ], ], ]); diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index cac64514a20c..59889ab86a12 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -74,13 +74,13 @@ class ACH $mailer = new NinjaMailerObject(); $mailer->mailable = new ACHVerificationNotification( - auth('contact')->user()->client->company, - route('client.contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'next' => $verification]) + auth()->guard('contact')->user()->client->company, + route('client.contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'next' => $verification]) ); - $mailer->company = auth('contact')->user()->client->company; - $mailer->settings = auth('contact')->user()->client->company->settings; - $mailer->to_user = auth('contact')->user(); + $mailer->company = auth()->guard('contact')->user()->client->company; + $mailer->settings = auth()->guard('contact')->user()->client->company->settings; + $mailer->to_user = auth()->guard('contact')->user(); NinjaMailerJob::dispatch($mailer); @@ -210,7 +210,7 @@ class ACH $source = ClientGatewayToken::query() ->where('id', $this->decodePrimaryKey($request->source)) - ->where('company_id', auth('contact')->user()->client->company->id) + ->where('company_id', auth()->guard('contact')->user()->client->company->id) ->first(); if (!$source) { diff --git a/app/PaymentDrivers/Stripe/ACSS.php b/app/PaymentDrivers/Stripe/ACSS.php index cab2b571133d..7f3c0cc4a116 100644 --- a/app/PaymentDrivers/Stripe/ACSS.php +++ b/app/PaymentDrivers/Stripe/ACSS.php @@ -66,13 +66,13 @@ class ACSS $mailer = new NinjaMailerObject(); $mailer->mailable = new ACHVerificationNotification( - auth('contact')->user()->client->company, - route('client.contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'next' => $verification]) + auth()->guard('contact')->user()->client->company, + route('client.contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'next' => $verification]) ); - $mailer->company = auth('contact')->user()->client->company; - $mailer->settings = auth('contact')->user()->client->company->settings; - $mailer->to_user = auth('contact')->user(); + $mailer->company = auth()->guard('contact')->user()->client->company; + $mailer->settings = auth()->guard('contact')->user()->client->company->settings; + $mailer->to_user = auth()->guard('contact')->user(); NinjaMailerJob::dispatch($mailer); diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 4dcf472ba0f5..2cf99ad5b410 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -91,7 +91,7 @@ class SubscriptionService 'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id), 'client' => $recurring_invoice->client->hashed_id, 'subscription' => $this->subscription->hashed_id, - 'contact' => auth('contact')->user() ? auth('contact')->user()->hashed_id : $recurring_invoice->client->contacts()->first()->hashed_id, + 'contact' => auth()->guard('contact')->user() ? auth()->guard('contact')->user()->hashed_id : $recurring_invoice->client->contacts()->first()->hashed_id, 'account_key' => $recurring_invoice->client->custom_value2, ]; @@ -452,7 +452,7 @@ class SubscriptionService 'credit' => $credit ? $credit->hashed_id : null, 'client' => $new_recurring_invoice->client->hashed_id, 'subscription' => $target_subscription->hashed_id, - 'contact' => auth('contact')->user()->hashed_id, + 'contact' => auth()->guard('contact')->user()->hashed_id, 'account_key' => $new_recurring_invoice->client->custom_value2, ]; @@ -573,7 +573,7 @@ class SubscriptionService 'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id), 'client' => $recurring_invoice->client->hashed_id, 'subscription' => $this->subscription->hashed_id, - 'contact' => auth('contact')->user()->hashed_id, + 'contact' => auth()->guard('contact')->user()->hashed_id, 'account_key' => $recurring_invoice->client->custom_value2, ]; @@ -921,7 +921,7 @@ class SubscriptionService 'subscription' => $this->subscription->hashed_id, 'recurring_invoice' => $recurring_invoice->hashed_id, 'client' => $recurring_invoice->client->hashed_id, - 'contact' => auth('contact')->user()->hashed_id, + 'contact' => auth()->guard('contact')->user()->hashed_id, 'account_key' => $recurring_invoice->client->custom_value2, ]; diff --git a/app/Services/Subscription/ZeroCostProduct.php b/app/Services/Subscription/ZeroCostProduct.php index fdec4b6b95e8..52fe4598ea46 100644 --- a/app/Services/Subscription/ZeroCostProduct.php +++ b/app/Services/Subscription/ZeroCostProduct.php @@ -71,7 +71,7 @@ class ZeroCostProduct extends AbstractService 'invoice' => $invoice->hashed_id, 'client' => $recurring_invoice->client->hashed_id, 'subscription' => $this->subscription->hashed_id, - 'contact' => auth('contact')->user()->hashed_id, + 'contact' => auth()->guard('contact')->user()->hashed_id, 'redirect_url' => "/client/recurring_invoices/{$recurring_invoice->hashed_id}", ]; diff --git a/resources/views/billing-portal/purchase.blade.php b/resources/views/billing-portal/purchase.blade.php index 2a1bb173ecb8..80fe64c74ac7 100644 --- a/resources/views/billing-portal/purchase.blade.php +++ b/resources/views/billing-portal/purchase.blade.php @@ -2,7 +2,7 @@ @section('meta_title', ctrans('texts.purchase')) @section('body') - @livewire('billing-portal-purchase', ['subscription' => $subscription, 'company' => $subscription->company, 'contact' => auth('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null]) + @livewire('billing-portal-purchase', ['subscription' => $subscription, 'company' => $subscription->company, 'contact' => auth()->guard('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null]) @stop @push('footer') diff --git a/resources/views/portal/ninja2020/components/general/footer.blade.php b/resources/views/portal/ninja2020/components/general/footer.blade.php index 770e8d5e7748..f00ad63f105d 100644 --- a/resources/views/portal/ninja2020/components/general/footer.blade.php +++ b/resources/views/portal/ninja2020/components/general/footer.blade.php @@ -1,7 +1,7 @@