diff --git a/app/DataMapper/Analytics/AccountCreated.php b/app/DataMapper/Analytics/AccountCreated.php index b0df3fa6ddd0..5d82945eb8f9 100644 --- a/app/DataMapper/Analytics/AccountCreated.php +++ b/app/DataMapper/Analytics/AccountCreated.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class AccountCreated +use Turbo124\Beacon\ExampleMetric\GenericCounter; + +class AccountCreated extends GenericCounter { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/AccountDeleted.php b/app/DataMapper/Analytics/AccountDeleted.php index 1ea0cc27aa34..342796254f50 100644 --- a/app/DataMapper/Analytics/AccountDeleted.php +++ b/app/DataMapper/Analytics/AccountDeleted.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class AccountDeleted +use Turbo124\Beacon\ExampleMetric\GenericCounter; + +class AccountDeleted extends GenericCounter { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/DbQuery.php b/app/DataMapper/Analytics/DbQuery.php index e802c64c4f2c..1abd42ec9df8 100644 --- a/app/DataMapper/Analytics/DbQuery.php +++ b/app/DataMapper/Analytics/DbQuery.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class DbQuery +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class DbQuery extends GenericMixedMetric { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/EmailFailure.php b/app/DataMapper/Analytics/EmailFailure.php index d91e37725b37..473b7c9bd0c9 100644 --- a/app/DataMapper/Analytics/EmailFailure.php +++ b/app/DataMapper/Analytics/EmailFailure.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class EmailFailure +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class EmailFailure extends GenericMixedMetric { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/EmailInvoiceFailure.php b/app/DataMapper/Analytics/EmailInvoiceFailure.php index 8637f87a05f5..9d259f2d38ce 100644 --- a/app/DataMapper/Analytics/EmailInvoiceFailure.php +++ b/app/DataMapper/Analytics/EmailInvoiceFailure.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class EmailInvoiceFailure +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class EmailInvoiceFailure extends GenericMixedMetric { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/EmailSuccess.php b/app/DataMapper/Analytics/EmailSuccess.php index bd39f7cd695b..14dfbb6ca89b 100644 --- a/app/DataMapper/Analytics/EmailSuccess.php +++ b/app/DataMapper/Analytics/EmailSuccess.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class EmailSuccess +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class EmailSuccess extends GenericMixedMetric { /** diff --git a/app/DataMapper/Analytics/LoginFailure.php b/app/DataMapper/Analytics/LoginFailure.php index 3fd8f943bb0e..584a5894aaec 100644 --- a/app/DataMapper/Analytics/LoginFailure.php +++ b/app/DataMapper/Analytics/LoginFailure.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class LoginFailure +use Turbo124\Beacon\ExampleMetric\GenericCounter; + +class LoginFailure extends GenericCounter { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/LoginSuccess.php b/app/DataMapper/Analytics/LoginSuccess.php index 5d489e93911f..2da5daece414 100644 --- a/app/DataMapper/Analytics/LoginSuccess.php +++ b/app/DataMapper/Analytics/LoginSuccess.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class LoginSuccess +use Turbo124\Beacon\ExampleMetric\GenericCounter; + +class LoginSuccess extends GenericCounter { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/Mail/EmailBounce.php b/app/DataMapper/Analytics/Mail/EmailBounce.php index 5a8aaf10af3d..15340b5a6ff5 100644 --- a/app/DataMapper/Analytics/Mail/EmailBounce.php +++ b/app/DataMapper/Analytics/Mail/EmailBounce.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics\Mail; -class EmailBounce +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class EmailBounce extends GenericMixedMetric { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/Mail/EmailSpam.php b/app/DataMapper/Analytics/Mail/EmailSpam.php index c420327ddc78..ff7acbd750c2 100644 --- a/app/DataMapper/Analytics/Mail/EmailSpam.php +++ b/app/DataMapper/Analytics/Mail/EmailSpam.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics\Mail; -class EmailSpam +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class EmailSpam extends GenericMixedMetric { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/MigrationFailure.php b/app/DataMapper/Analytics/MigrationFailure.php index c57421d1f52f..b4cf68fe3588 100644 --- a/app/DataMapper/Analytics/MigrationFailure.php +++ b/app/DataMapper/Analytics/MigrationFailure.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class MigrationFailure +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class MigrationFailure extends GenericMixedMetric { /** * The type of Sample. diff --git a/app/DataMapper/Analytics/SendRecurringFailure.php b/app/DataMapper/Analytics/SendRecurringFailure.php index 26affa205a3c..7b000464c88b 100644 --- a/app/DataMapper/Analytics/SendRecurringFailure.php +++ b/app/DataMapper/Analytics/SendRecurringFailure.php @@ -11,7 +11,9 @@ namespace App\DataMapper\Analytics; -class SendRecurringFailure +use Turbo124\Beacon\ExampleMetric\GenericMixedMetric; + +class SendRecurringFailure extends GenericMixedMetric { /** * The type of Sample. diff --git a/app/Http/Livewire/WepaySignup.php b/app/Http/Livewire/WepaySignup.php index 783bff6f33da..a069997f6fed 100644 --- a/app/Http/Livewire/WepaySignup.php +++ b/app/Http/Livewire/WepaySignup.php @@ -12,6 +12,7 @@ namespace App\Http\Livewire; +use App\Factory\CompanyGatewayFactory; use App\Models\Company; use App\Models\CompanyGateway; use App\Models\User; @@ -48,6 +49,7 @@ class WepaySignup extends Component 'country' => ['required'], 'ach' => ['sometimes'], 'wepay_payment_tos_agree' => ['accepted'], + 'debit_cards' => ['sometimes'], ]; public function mount() @@ -77,22 +79,29 @@ class WepaySignup extends Component public function submit() { + $data = $this->validate($this->rules); + //need to create or get a new WePay CompanyGateway - $cg = CompanyGateway::where('id', 49) + $cg = CompanyGateway::where('gateway_key', '8fdeed552015b3c7b44ed6c8ebd9e992') ->where('company_id', $this->company->id) ->firstOrNew(); if(!$cg->id) { - + $cg = CompanyGatewayFactory::create($this->company->id, $this->user->id); + $cg->gateway_key = '8fdeed552015b3c7b44ed6c8ebd9e992'; + $cg->require_cvv = false; + $cg->require_billing_address = false; + $cg->require_shipping_address = false; + $cg->update_details = false; + $cg->config = encrypt(config('ninja.testvars.checkout')); + $cg->save(); } - $data = $this->validate($this->rules); - $this->saved = ctrans('texts.processing'); - $wepay_driver = new WePayPaymentDriver(new CompanyGateway, null, null); + $wepay_driver = new WePayPaymentDriver($cg, null, null); - $wepay_driver->init(); + $wepay = $wepay_driver->init()->wepay; $user_details = [ 'client_id' => config('ninja.wepay.client_id'), @@ -107,7 +116,7 @@ class WepaySignup extends Component 'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money', ]; - $wepay_user = $wepay_driver->request('user/register/', $user_details); + $wepay_user = $wepay->request('user/register/', $user_details); $access_token = $wepay_user->access_token; @@ -120,7 +129,7 @@ class WepaySignup extends Component 'description' => ctrans('texts.wepay_account_description'), 'theme_object' => json_decode('{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}'), 'callback_uri' => route('payment_webhook', ['company_key' => $this->company->company_key, 'company_gateway_id' => $cg->hashed_id]), - 'rbits' => $this->company->present()->rBits, + 'rbits' => $this->company->rBits(), 'country' => $data['country'], ]; @@ -144,5 +153,19 @@ class WepaySignup extends Component } } + $config = [ + 'userId' => $wepay_user->user_id, + 'accessToken' => $access_token, + 'tokenType' => $wepay_user->token_type, + 'tokenExpires' => $access_token_expires, + 'accountId' => $wepay_account->account_id, + 'state' => $wepay_account->state, + 'testMode' => config('ninja.wepay.environment') == 'staging', + 'country' => $data['country'], + ]; + + $cg->setConfig($config); + $cg->save(); } + } diff --git a/app/Models/Company.php b/app/Models/Company.php index a750ad81c89f..f35d33d649bb 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -445,21 +445,36 @@ class Company extends BaseModel public function rBits() { - $account = $this->account; $user = $this->owner(); $data = []; $data[] = $this->createRBit('business_name', 'user', ['business_name' => $this->present()->name()]); - $data[] = $this->createRBit('industry_code', 'user', ['industry_detail' => $this->industry->name]); + $data[] = $this->createRBit('industry_code', 'user', ['industry_detail' => $this->industry ? $this->industry->name : '']); $data[] = $this->createRBit('comment', 'partner_database', ['comment_text' => 'Logo image not present']); - $data[] = $this->createRBit('business_description', 'user', ['business_description' => $company->present()->size()]); + $data[] = $this->createRBit('business_description', 'user', ['business_description' => $this->present()->size()]); $data[] = $this->createRBit('person', 'user', ['name' => $user->present()->getFullName()]); $data[] = $this->createRBit('email', 'user', ['email' => $user->email]); $data[] = $this->createRBit('phone', 'user', ['phone' => $user->phone]); - $data[] = $this->createRBit('website_uri', 'user', ['uri' => $this->entity->settings->website]); + $data[] = $this->createRBit('website_uri', 'user', ['uri' => $this->settings->website]); $data[] = $this->createRBit('external_account', 'partner_database', ['is_partner_account' => 'yes', 'account_type' => 'Invoice Ninja', 'create_time' => time()]); return $data; } + + + private function createRBit($type, $source, $properties) + { + $data = new \stdClass; + $data->receive_time = time(); + $data->type = $type; + $data->source = $source; + $data->properties = new \stdClass; + + foreach ($properties as $key => $val) { + $data->properties->$key = $val; + } + + return $data; + } } diff --git a/app/PaymentDrivers/WePayPaymentDriver.php b/app/PaymentDrivers/WePayPaymentDriver.php index d6f281893dfe..2b21cc6880af 100644 --- a/app/PaymentDrivers/WePayPaymentDriver.php +++ b/app/PaymentDrivers/WePayPaymentDriver.php @@ -48,14 +48,14 @@ class WePayPaymentDriver extends BaseDriver if (WePay::getEnvironment() == 'none') { if(config('ninja.wepay.environment') == 'staging') - WePay::useStaing(config('ninja.wepay.client_id'), config('ninja.wepay.client_secret')); + WePay::useStaging(config('ninja.wepay.client_id'), config('ninja.wepay.client_secret')); else WePay::useProduction(config('ninja.wepay.client_id'), config('ninja.wepay.client_secret')); } if ($this->company_gateway) - $this->wepay = new WePay($this->company_gateway->getConfig()->accessToken); + $this->wepay = new WePay($this->company_gateway->getConfigField('accessToken')); $this->wepay = new WePay(null); diff --git a/app/Utils/Statics.php b/app/Utils/Statics.php index 9d5da011f5ae..1543c8e08f7c 100644 --- a/app/Utils/Statics.php +++ b/app/Utils/Statics.php @@ -12,6 +12,7 @@ namespace App\Utils; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; /** @@ -69,6 +70,28 @@ class Statics $data = []; foreach (config('ninja.cached_tables') as $name => $class) { + + if (!Cache::has($name)) { + + // check that the table exists in case the migration is pending + if (!Schema::hasTable((new $class())->getTable())) { + continue; + } + if ($name == 'payment_terms') { + $orderBy = 'num_days'; + } elseif ($name == 'fonts') { + $orderBy = 'sort_order'; + } elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) { + $orderBy = 'name'; + } else { + $orderBy = 'id'; + } + $tableData = $class::orderBy($orderBy)->get(); + if ($tableData->count()) { + Cache::forever($name, $tableData); + } + } + $data[$name] = Cache::get($name); } diff --git a/composer.lock b/composer.lock index ada9fd8b8449..6171f7333c35 100644 --- a/composer.lock +++ b/composer.lock @@ -103,16 +103,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.180.1", + "version": "3.180.5", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "7801112fd8be227954a6ecfbfd85b01ee4a7cae4" + "reference": "948a4defbe2a571cc4460725015b8e98b7060f2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7801112fd8be227954a6ecfbfd85b01ee4a7cae4", - "reference": "7801112fd8be227954a6ecfbfd85b01ee4a7cae4", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/948a4defbe2a571cc4460725015b8e98b7060f2d", + "reference": "948a4defbe2a571cc4460725015b8e98b7060f2d", "shasum": "" }, "require": { @@ -187,9 +187,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.180.1" + "source": "https://github.com/aws/aws-sdk-php/tree/3.180.5" }, - "time": "2021-05-04T18:14:38+00:00" + "time": "2021-05-07T18:12:43+00:00" }, { "name": "bacon/bacon-qr-code", @@ -6811,16 +6811,16 @@ }, { "name": "sentry/sentry", - "version": "3.2.1", + "version": "3.2.2", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f" + "reference": "02237728bdc5b82b0a14c37417644e3f3606db9b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f", - "reference": "fb4f83e6e2d718d1e5fbfe3a20cced83f47f040f", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/02237728bdc5b82b0a14c37417644e3f3606db9b", + "reference": "02237728bdc5b82b0a14c37417644e3f3606db9b", "shasum": "" }, "require": { @@ -6899,7 +6899,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/3.2.1" + "source": "https://github.com/getsentry/sentry-php/tree/3.2.2" }, "funding": [ { @@ -6911,20 +6911,20 @@ "type": "custom" } ], - "time": "2021-04-06T07:55:41+00:00" + "time": "2021-05-06T10:15:01+00:00" }, { "name": "sentry/sentry-laravel", - "version": "2.5.1", + "version": "2.5.2", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-laravel.git", - "reference": "2af8a531f202f0ac014f5fad532815ed34f730a9" + "reference": "368a2701b3bd370a2892f1f67bfbf0cbecbaca17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/2af8a531f202f0ac014f5fad532815ed34f730a9", - "reference": "2af8a531f202f0ac014f5fad532815ed34f730a9", + "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/368a2701b3bd370a2892f1f67bfbf0cbecbaca17", + "reference": "368a2701b3bd370a2892f1f67bfbf0cbecbaca17", "shasum": "" }, "require": { @@ -6987,7 +6987,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-laravel/issues", - "source": "https://github.com/getsentry/sentry-laravel/tree/2.5.1" + "source": "https://github.com/getsentry/sentry-laravel/tree/2.5.2" }, "funding": [ { @@ -6999,20 +6999,20 @@ "type": "custom" } ], - "time": "2021-04-29T11:10:22+00:00" + "time": "2021-05-06T07:49:08+00:00" }, { "name": "stripe/stripe-php", - "version": "v7.77.0", + "version": "v7.78.0", "source": { "type": "git", "url": "https://github.com/stripe/stripe-php.git", - "reference": "f6724447481f6fb8c2e714165e092adad9ca470a" + "reference": "6ec33fa8e9de2322be93d28dfd685661c67ca549" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stripe/stripe-php/zipball/f6724447481f6fb8c2e714165e092adad9ca470a", - "reference": "f6724447481f6fb8c2e714165e092adad9ca470a", + "url": "https://api.github.com/repos/stripe/stripe-php/zipball/6ec33fa8e9de2322be93d28dfd685661c67ca549", + "reference": "6ec33fa8e9de2322be93d28dfd685661c67ca549", "shasum": "" }, "require": { @@ -7058,9 +7058,9 @@ ], "support": { "issues": "https://github.com/stripe/stripe-php/issues", - "source": "https://github.com/stripe/stripe-php/tree/v7.77.0" + "source": "https://github.com/stripe/stripe-php/tree/v7.78.0" }, - "time": "2021-04-12T17:19:16+00:00" + "time": "2021-05-05T23:55:32+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -9809,16 +9809,16 @@ }, { "name": "turbo124/laravel-gmail", - "version": "v5.0.1", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/turbo124/laravel-gmail.git", - "reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966" + "reference": "f8b8806d0b37ab5b2d4c3f402f8094d9021bd342" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/turbo124/laravel-gmail/zipball/55ca0271a54a568ebaa26febbe0790b2ce5ac966", - "reference": "55ca0271a54a568ebaa26febbe0790b2ce5ac966", + "url": "https://api.github.com/repos/turbo124/laravel-gmail/zipball/f8b8806d0b37ab5b2d4c3f402f8094d9021bd342", + "reference": "f8b8806d0b37ab5b2d4c3f402f8094d9021bd342", "shasum": "" }, "require": { @@ -9872,9 +9872,9 @@ "laravel" ], "support": { - "source": "https://github.com/turbo124/laravel-gmail/tree/v5.0.1" + "source": "https://github.com/turbo124/laravel-gmail/tree/v5.0.2" }, - "time": "2021-04-06T00:53:48+00:00" + "time": "2021-05-08T00:17:52+00:00" }, { "name": "vlucas/phpdotenv", @@ -10792,21 +10792,21 @@ }, { "name": "darkaonline/l5-swagger", - "version": "8.0.4", + "version": "8.0.5", "source": { "type": "git", "url": "https://github.com/DarkaOnLine/L5-Swagger.git", - "reference": "3477e7013daf8b6fc142c45fdcb9fe6c74d7398d" + "reference": "238e5d318b3d48a77c76b6950c51146578563853" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/DarkaOnLine/L5-Swagger/zipball/3477e7013daf8b6fc142c45fdcb9fe6c74d7398d", - "reference": "3477e7013daf8b6fc142c45fdcb9fe6c74d7398d", + "url": "https://api.github.com/repos/DarkaOnLine/L5-Swagger/zipball/238e5d318b3d48a77c76b6950c51146578563853", + "reference": "238e5d318b3d48a77c76b6950c51146578563853", "shasum": "" }, "require": { "ext-json": "*", - "laravel/framework": "^8.0 || ^7.0", + "laravel/framework": ">=8.40.0 || ^7.0", "php": "^7.2 || ^8.0", "swagger-api/swagger-ui": "^3.0", "symfony/yaml": "^5.0", @@ -10859,7 +10859,7 @@ ], "support": { "issues": "https://github.com/DarkaOnLine/L5-Swagger/issues", - "source": "https://github.com/DarkaOnLine/L5-Swagger/tree/8.0.4" + "source": "https://github.com/DarkaOnLine/L5-Swagger/tree/8.0.5" }, "funding": [ { @@ -10867,7 +10867,7 @@ "type": "github" } ], - "time": "2020-12-08T13:29:20+00:00" + "time": "2021-05-07T09:57:00+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -11112,16 +11112,16 @@ }, { "name": "facade/ignition", - "version": "2.8.4", + "version": "2.9.0", "source": { "type": "git", "url": "https://github.com/facade/ignition.git", - "reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f" + "reference": "e7db3b601ce742568b92648818ef903904d20164" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/ignition/zipball/87fb348dab0ae1a7c206c3e902a5a44ba541742f", - "reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f", + "url": "https://api.github.com/repos/facade/ignition/zipball/e7db3b601ce742568b92648818ef903904d20164", + "reference": "e7db3b601ce742568b92648818ef903904d20164", "shasum": "" }, "require": { @@ -11185,7 +11185,7 @@ "issues": "https://github.com/facade/ignition/issues", "source": "https://github.com/facade/ignition" }, - "time": "2021-04-29T13:55:26+00:00" + "time": "2021-05-05T06:45:12+00:00" }, { "name": "facade/ignition-contracts", diff --git a/resources/views/portal/ninja2020/gateways/wepay/signup/wepay-signup.blade.php b/resources/views/portal/ninja2020/gateways/wepay/signup/wepay-signup.blade.php index 93f13f435579..10cef317d17e 100644 --- a/resources/views/portal/ninja2020/gateways/wepay/signup/wepay-signup.blade.php +++ b/resources/views/portal/ninja2020/gateways/wepay/signup/wepay-signup.blade.php @@ -76,25 +76,26 @@
- + {{ ctrans('texts.accept_debit_cards') }}
@endif +
- + {!! ctrans('texts.wepay_payment_tos_agree', ['terms' => $terms, 'privacy_policy' => $privacy_policy]) !!}
@error('wepay_payment_tos_agree') @@ -104,6 +105,10 @@ @enderror
+
+ {{ ctrans('texts.standard_fees_apply')}} +
+
@@ -267,9 +272,7 @@
-
- {{ ctrans('texts.standard_fees_apply')}} -
+