From 1b2a5fa09a71eee16362c1a2eea7e33cea09f949 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Feb 2022 15:49:31 +1100 Subject: [PATCH 1/9] Fixes for payment methods --- VERSION.txt | 2 +- app/Import/Providers/BaseImport.php | 1 - app/Services/Client/PaymentMethod.php | 30 +++++++++++++++------------ app/Utils/Number.php | 9 +++++--- config/ninja.php | 4 ++-- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 4d42c3866b..72e2dd4be4 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.3.60 \ No newline at end of file +5.3.61 \ No newline at end of file diff --git a/app/Import/Providers/BaseImport.php b/app/Import/Providers/BaseImport.php index 0b4d430821..5d9a8447c2 100644 --- a/app/Import/Providers/BaseImport.php +++ b/app/Import/Providers/BaseImport.php @@ -80,7 +80,6 @@ class BaseImport public function getCsvData($entity_type) { - nlog("get csv data = entity name = " . $entity_type); $base64_encoded_csv = Cache::pull($this->hash . '-' . $entity_type); if (empty($base64_encoded_csv)) { diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 4a18387d22..1783dd577d 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -70,24 +70,26 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = - CompanyGateway::with('gateway') - ->where('company_id', $this->client->company_id) + $this->gateways = $this->client + ->company + ->company_gateways ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - })->get(); + }); } else { - $this->gateways = CompanyGateway::with('gateway') - ->where('company_id', $this->client->company_id) + $this->gateways = $this->client + ->company + ->company_gateways ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->whereNull('deleted_at') - ->where('is_deleted', false)->get(); + ->where('is_deleted', false); + } @@ -105,23 +107,25 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = CompanyGateway::with('gateway') - ->where('company_id', $this->client->company_id) + $this->gateways = $this->client + ->company + ->company_gateways ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - })->get(); + }); } else { - $this->gateways = CompanyGateway::with('gateway') - ->where('company_id', $this->client->company_id) + $this->gateways = $this->client + ->company + ->company_gateways ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->whereNull('deleted_at') - ->where('is_deleted', false)->get(); + ->where('is_deleted', false); } diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 87b99a8022..40d1401a10 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -200,10 +200,13 @@ class Number /* 08-01-2022 allow increased precision for unit price*/ $v = rtrim(sprintf('%f', $value),"0"); - // $precision = strlen(substr(strrchr($v, $decimal), 1)); + $precision = strlen(substr(strrchr($v, $decimal), 1)); - if($v<1) - $precision = strlen($v) - strrpos($v, '.') - 1; + // if($v<1) + // $precision = strlen($v) - strrpos($v, '.') - 1; + + if($precision == 1) + $precision = 2; $value = number_format($v, $precision, $decimal, $thousand); $symbol = $currency->symbol; diff --git a/config/ninja.php b/config/ninja.php index 491c140389..5bbe097f9a 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.3.60', - 'app_tag' => '5.3.60', + 'app_version' => '5.3.61', + 'app_tag' => '5.3.61', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''), From ea6905f4a0ae95e42cf1dfdbaaf19a95bda323fe Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Feb 2022 15:58:58 +1100 Subject: [PATCH 2/9] Revert Payment method getters --- app/Services/Client/PaymentMethod.php | 30 ++++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 1783dd577d..4a18387d22 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -70,26 +70,24 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = + CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - }); + })->get(); } else { - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->whereNull('deleted_at') - ->where('is_deleted', false); - + ->where('is_deleted', false)->get(); } @@ -107,25 +105,23 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - }); + })->get(); } else { - $this->gateways = $this->client - ->company - ->company_gateways + $this->gateways = CompanyGateway::with('gateway') + ->where('company_id', $this->client->company_id) ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->whereNull('deleted_at') - ->where('is_deleted', false); + ->where('is_deleted', false)->get(); } From e558edb79586fee9e079ee9944ad1d05d43d32e6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Feb 2022 18:07:05 +1100 Subject: [PATCH 3/9] Reversion for unit cost precision --- app/Utils/Number.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 40d1401a10..f3105ce779 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -200,13 +200,13 @@ class Number /* 08-01-2022 allow increased precision for unit price*/ $v = rtrim(sprintf('%f', $value),"0"); - $precision = strlen(substr(strrchr($v, $decimal), 1)); + // $precision = strlen(substr(strrchr($v, $decimal), 1)); - // if($v<1) - // $precision = strlen($v) - strrpos($v, '.') - 1; + if($v<1) + $precision = strlen($v) - strrpos($v, '.') - 1; - if($precision == 1) - $precision = 2; + // if($precision == 1) + // $precision = 2; $value = number_format($v, $precision, $decimal, $thousand); $symbol = $currency->symbol; From 3bad699bfa68165f5f1f7bfa283ffa61fbdce371 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Feb 2022 18:22:28 +1100 Subject: [PATCH 4/9] Fixes for backup update command --- app/Console/Commands/BackupUpdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/BackupUpdate.php b/app/Console/Commands/BackupUpdate.php index d1418a7a79..d8275328c8 100644 --- a/app/Console/Commands/BackupUpdate.php +++ b/app/Console/Commands/BackupUpdate.php @@ -77,7 +77,7 @@ class BackupUpdate extends Command { set_time_limit(0); - Backup::chunk(100, function ($backups) { + Backup::whereRaw('html_backup != "" OR html_backup IS NOT NULL')->chunk(5000, function ($backups) { foreach ($backups as $backup) { if($backup->activity->client()->exists()){ From 0bd0c0d2a1bddc10ff820bf489d9a5b5cd41afd8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Feb 2022 19:02:57 +1100 Subject: [PATCH 5/9] Fixes for mollie webhooks with credit cards --- app/PaymentDrivers/Mollie/CreditCard.php | 12 ++++++++++++ app/Providers/MailServiceProvider.php | 2 +- app/Providers/NinjaTranslationServiceProvider.php | 1 + routes/web.php | 6 +++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/Mollie/CreditCard.php b/app/PaymentDrivers/Mollie/CreditCard.php index 8a6af3dd2d..1c96455d86 100644 --- a/app/PaymentDrivers/Mollie/CreditCard.php +++ b/app/PaymentDrivers/Mollie/CreditCard.php @@ -70,6 +70,12 @@ class CreditCard 'sequenceType' => 'recurring', 'description' => \sprintf('Hash: %s', $this->mollie->payment_hash->hash), 'webhookUrl' => $this->mollie->company_gateway->webhookUrl(), + 'metadata' => [ + 'client_id' => $this->mollie->client->hashed_id, + 'hash' => $this->mollie->payment_hash->hash, + 'gateway_type_id' => GatewayType::CREDIT_CARD, + 'payment_type_id' => PaymentType::CREDIT_CARD_OTHER, + ], ]); if ($payment->status === 'paid') { @@ -106,6 +112,12 @@ class CreditCard 'hash' => $this->mollie->payment_hash->hash, ]), 'webhookUrl' => $this->mollie->company_gateway->webhookUrl(), + 'metadata' => [ + 'client_id' => $this->mollie->client->hashed_id, + 'hash' => $this->mollie->payment_hash->hash, + 'gateway_type_id' => GatewayType::CREDIT_CARD, + 'payment_type_id' => PaymentType::CREDIT_CARD_OTHER, + ], 'cardToken' => $request->gateway_response, ]; diff --git a/app/Providers/MailServiceProvider.php b/app/Providers/MailServiceProvider.php index cc16f654f7..0abea01a9d 100644 --- a/app/Providers/MailServiceProvider.php +++ b/app/Providers/MailServiceProvider.php @@ -33,7 +33,7 @@ class MailServiceProvider extends MailProvider protected function registerIlluminateMailer() { - + //this is not octane safe $this->app->singleton('mail.manager', function($app) { return new GmailTransportManager($app); }); diff --git a/app/Providers/NinjaTranslationServiceProvider.php b/app/Providers/NinjaTranslationServiceProvider.php index 985987bc02..7054f32514 100644 --- a/app/Providers/NinjaTranslationServiceProvider.php +++ b/app/Providers/NinjaTranslationServiceProvider.php @@ -33,6 +33,7 @@ class NinjaTranslationServiceProvider extends TranslationServiceProvider * */ + //this is not octane safe $this->app->singleton('translator', function ($app) { $loader = $app['translation.loader']; diff --git a/routes/web.php b/routes/web.php index f29bf383ab..67513dc9cc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -41,7 +41,7 @@ Route::group(['middleware' => ['url_db']], function () { Route::get('stripe/signup/{token}', 'StripeConnectController@initialize')->name('stripe_connect.initialization'); Route::get('stripe/completed', 'StripeConnectController@completed')->name('stripe_connect.return'); -Route::get('checkout/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\Checkout3dsController@index')->name('checkout.3ds_redirect'); -Route::get('mollie/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\Mollie3dsController@index')->name('mollie.3ds_redirect'); -Route::get('gocardless/ibp_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\GoCardlessController@ibpRedirect')->name('gocardless.ibp_redirect'); +Route::get('checkout/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\Checkout3dsController@index')->middleware('domain_db')->name('checkout.3ds_redirect'); +Route::get('mollie/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\Mollie3dsController@index')->middleware('domain_db')->name('mollie.3ds_redirect'); +Route::get('gocardless/ibp_redirect/{company_key}/{company_gateway_id}/{hash}', 'Gateways\GoCardlessController@ibpRedirect')->middleware('domain_db')->name('gocardless.ibp_redirect'); Route::get('.well-known/apple-developer-merchantid-domain-association', 'ClientPortal\ApplePayDomainController@showAppleMerchantId'); From a37bf5cb70198e05211b2c40ecdddc8627b2e27d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Feb 2022 21:09:20 +1100 Subject: [PATCH 6/9] Center auth login logo --- app/Providers/MailServiceProvider.php | 9 ++++++++- app/Utils/SystemHealth.php | 2 ++ resources/views/portal/ninja2020/auth/login.blade.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Providers/MailServiceProvider.php b/app/Providers/MailServiceProvider.php index 0abea01a9d..55f0b37290 100644 --- a/app/Providers/MailServiceProvider.php +++ b/app/Providers/MailServiceProvider.php @@ -17,6 +17,7 @@ use Coconuts\Mail\PostmarkTransport; use GuzzleHttp\Client as HttpClient; use Illuminate\Mail\MailServiceProvider as MailProvider; use Illuminate\Mail\TransportManager; +use Illuminate\Container\Container; class MailServiceProvider extends MailProvider { @@ -33,11 +34,17 @@ class MailServiceProvider extends MailProvider protected function registerIlluminateMailer() { - //this is not octane safe + // //this is not octane safe $this->app->singleton('mail.manager', function($app) { return new GmailTransportManager($app); }); + + //this is octane ready - but is untested + // $this->app->bind('mail.manager', function ($app){ + // return new GmailTransportManager($app); + // }); + $this->app->bind('mailer', function ($app) { return $app->make('mail.manager')->mailer(); }); diff --git a/app/Utils/SystemHealth.php b/app/Utils/SystemHealth.php index b6ae0d3c88..2b510d8c5c 100644 --- a/app/Utils/SystemHealth.php +++ b/app/Utils/SystemHealth.php @@ -164,6 +164,8 @@ class SystemHealth private static function extensions(): array { + $loaded_extensions = null; + $loaded_extensions = []; foreach (self::$extensions as $extension) { diff --git a/resources/views/portal/ninja2020/auth/login.blade.php b/resources/views/portal/ninja2020/auth/login.blade.php index 5fbc2a0527..44fdaf5d39 100644 --- a/resources/views/portal/ninja2020/auth/login.blade.php +++ b/resources/views/portal/ninja2020/auth/login.blade.php @@ -26,7 +26,7 @@ @elseif(isset($company) && !is_null($company))
{{ $company->present()->name() }} logo + class="mx-auto border-b border-gray-100 h-18 pb-4" alt="{{ $company->present()->name() }} logo">
@endif From 291b0c5669ba0a4201658ffbf9b5fed8508b5d7c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 21 Feb 2022 07:41:13 +1100 Subject: [PATCH 7/9] Revert for markdown parser --- app/Utils/Helpers.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index 6f633612e4..ca4a7e5d5b 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -262,9 +262,11 @@ class Helpers } } - $x = str_replace(["\n", "
"], ["\r", "
"], $value); + return $value; - return $x; + // $x = str_replace(["\n", "
"], ["\r", "
"], $value); + + // return $x; } /** From ce0bcd494d7fe951bb429e3c59c6cb622d2fb3ed Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 21 Feb 2022 07:51:49 +1100 Subject: [PATCH 8/9] Revert for gateway query --- app/Services/Client/PaymentMethod.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 4a18387d22..f36fb2b2d3 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -70,16 +70,16 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = - CompanyGateway::with('gateway') - ->where('company_id', $this->client->company_id) + $this->gateways = $this->client + ->company + ->company_gateways ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - })->get(); + }); } else { @@ -105,15 +105,16 @@ class PaymentMethod $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - $this->gateways = CompanyGateway::with('gateway') - ->where('company_id', $this->client->company_id) + $this->gateways = $this->client + ->company + ->company_gateways ->whereIn('id', $transformed_ids) ->where('is_deleted', false) ->whereNull('deleted_at') ->where('gateway_key', '54faab2ab6e3223dbe848b1686490baa') ->sortby(function ($model) use ($transformed_ids) { //company gateways are sorted in order of priority return array_search($model->id, $transformed_ids);// this closure sorts for us - })->get(); + }); } else { From 091ad58bb37318f983146e0c21ee004f4852f66b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 21 Feb 2022 08:35:03 +1100 Subject: [PATCH 9/9] Format due date in client portal --- resources/views/portal/ninja2020/invoices/payment.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/portal/ninja2020/invoices/payment.blade.php b/resources/views/portal/ninja2020/invoices/payment.blade.php index a3969763b6..b45fd44355 100644 --- a/resources/views/portal/ninja2020/invoices/payment.blade.php +++ b/resources/views/portal/ninja2020/invoices/payment.blade.php @@ -78,7 +78,7 @@ {{ ctrans('texts.due_date') }}
- {{ $invoice->due_date }} + {{ $invoice->translateDate($invoice->due_date, $invoice->client->date_format(), $invoice->client->locale()) }}
@endif