diff --git a/app/Listeners/AnalyticsListener.php b/app/Listeners/AnalyticsListener.php index f9c21221a9..2596293793 100644 --- a/app/Listeners/AnalyticsListener.php +++ b/app/Listeners/AnalyticsListener.php @@ -23,7 +23,7 @@ class AnalyticsListener $invoice = $payment->invoice; $account = $payment->account; - if (! in_array($account->account_key, [NINJA_ACCOUNT_KEY, NINJA_LICENSE_ACCOUNT_KEY])) { + if ($account->isNinjaAccount() || $account->account_key == NINJA_LICENSE_ACCOUNT_KEY) { return; } diff --git a/app/Models/Account.php b/app/Models/Account.php index b5b8b4b2d9..a79d1a1788 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -943,7 +943,7 @@ class Account extends Eloquent */ public function isNinjaAccount() { - return $this->account_key === NINJA_ACCOUNT_KEY; + return strpos($this->account_key, 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx7') === 0; } /** diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php index 43c3e769b4..782a532096 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -312,7 +312,7 @@ class BasePaymentDriver $payment = $this->createPayment($ref, $paymentMethod); // TODO move this to stripe driver - if ($this->invitation->invoice->account->account_key == NINJA_ACCOUNT_KEY) { + if ($this->invitation->invoice->account->isNinjaAccount()) { Session::flash('trackEventCategory', '/account'); Session::flash('trackEventAction', '/buy_pro_plan'); Session::flash('trackEventAmount', $payment->amount); @@ -648,7 +648,7 @@ class BasePaymentDriver $this->createLicense($payment); // TODO move this code // enable pro plan for hosted users - } elseif ($accountKey == NINJA_ACCOUNT_KEY) { + } elseif ($invoice->account->isNinjaAccount()) { foreach ($invoice->invoice_items as $invoice_item) { // Hacky, but invoices don't have meta fields to allow us to store this easily if (1 == preg_match('/^Plan - (.+) \((.+)\)$/', $invoice_item->product_key, $matches)) { diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index e6e4ff8c80..fc2dafd26c 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -335,7 +335,7 @@ class AccountRepository public function getNinjaAccount() { - $account = Account::whereAccountKey(NINJA_ACCOUNT_KEY)->first(); + $account = Account::where('account_key', 'LIKE', substr(NINJA_ACCOUNT_KEY, 0, 30) . '%')->orderBy('id')->first(); if ($account) { return $account; diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 3e932e9e1b..c1400bb636 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -278,7 +278,7 @@ class InvoiceRepository extends BaseRepository ->where('invoices.is_recurring', '=', false) ->where('invoices.is_public', '=', true) // Only show paid invoices for ninja accounts - ->whereRaw(sprintf("((accounts.account_key != '%s' and accounts.account_key != '%s') or invoices.invoice_status_id = %d)", env('NINJA_LICENSE_ACCOUNT_KEY'), NINJA_ACCOUNT_KEY, INVOICE_STATUS_PAID)) + ->whereRaw(sprintf("((accounts.account_key != '%s' and accounts.account_key not like '%s') or invoices.invoice_status_id = %d)", env('NINJA_LICENSE_ACCOUNT_KEY'), substr(NINJA_ACCOUNT_KEY, 0, 30), INVOICE_STATUS_PAID)) ->select( DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),