Merge pull request #7631 from turbo124/v5-develop

Apple ID Auth
This commit is contained in:
David Bomba 2022-07-11 18:48:47 +10:00 committed by GitHub
commit d4e0fc642d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 99 additions and 51 deletions

View File

@ -13,7 +13,7 @@ class PaymentFailed extends Exception
public function render($request)
{
if (auth()->user() || ($request->has('cko-session-id') && $request->query('cko-session-id') )) {
if (auth()->guard('contact')->user() || ($request->has('cko-session-id') && $request->query('cko-session-id') )) {
return render('gateways.unsuccessful', [
'message' => $this->getMessage(),
'code' => $this->getCode(),

View File

@ -94,6 +94,9 @@ class QuoteFilters extends QueryFilters
{
$sort_col = explode('|', $sort);
if($sort_col[0] == 'valid_until')
$sort_col[0] = 'due_date';
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
}

View File

@ -334,11 +334,12 @@ class LoginController extends BaseController
} elseif (request()->input('provider') == 'microsoft') {
return $this->handleMicrosoftOauth();
} elseif (request()->input('provider') == 'apple') {
// if (request()->has('token')) {
// return $this->handleSocialiteLogin('apple', request()->get('token'));
// } else {
// $message = 'Token is missing for the apple login';
// }
if (request()->has('token') || request()->has('auth_code')) {
$token = request()->has('token') ? request()->input('token') : request()->input('auth_code');
return $this->handleSocialiteLogin('apple', $token);
} else {
$message = 'Token is missing for the apple login';
}
}
return response()
@ -355,6 +356,7 @@ class LoginController extends BaseController
private function handleSocialiteLogin($provider, $token)
{
$user = $this->getSocialiteUser($provider, $token);
nlog($user);
if ($user) {
return $this->loginOrCreateFromSocialite($user, $provider);
}

View File

@ -204,10 +204,6 @@ class RecurringInvoiceController extends BaseController
{
$recurring_invoice = $this->recurring_invoice_repo->save($request->all(), RecurringInvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id));
// $offset = $recurring_invoice->client->timezone_offset();
// $recurring_invoice->next_send_date = Carbon::parse($recurring_invoice->next_send_date)->startOfDay()->addSeconds($offset);
// $recurring_invoice->saveQuietly();
$recurring_invoice->service()
->triggeredActions($request)
->save();
@ -702,6 +698,15 @@ class RecurringInvoiceController extends BaseController
$this->itemResponse($recurring_invoice);
}
break;
case 'send_now':
$recurring_invoice = $recurring_invoice->service()->sendNow();
if (! $bulk) {
$this->itemResponse($recurring_invoice);
}
break;
default:
// code...

View File

@ -21,6 +21,7 @@ use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use App\PaymentDrivers\Stripe\Connect\Account;
use App\PaymentDrivers\Stripe\Jobs\StripeWebhook;
use Exception;
use Illuminate\Http\Request;
use Stripe\Exception\ApiErrorException;
@ -119,6 +120,8 @@ class StripeConnectController extends BaseController
$company_gateway->setConfig($payload);
$company_gateway->save();
StripeWebhook::dispatch($company->company_key, $company_gateway->id);
//response here
return view('auth.connect.completed');
}

View File

@ -44,7 +44,7 @@ class ValidCreditsPresentRule implements Rule
{
//todo need to ensure the clients credits are here not random ones!
if (request()->input('credits') && is_array(request()->input('credits'))) {
if (request()->input('credits') && is_array(request()->input('credits')) && count(request()->input('credits')) > 0) {
$credit_collection = Credit::whereIn('id', $this->transformKeys(array_column(request()->input('credits'), 'credit_id')))
->count();

View File

@ -220,8 +220,8 @@ class ProcessPostmarkWebhook implements ShouldQueue
SystemLogger::dispatch($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company);
if(config('ninja.notification.slack'))
$this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja();
// if(config('ninja.notification.slack'))
// $this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja();
}

View File

@ -491,4 +491,17 @@ class Account extends BaseModel
->where('id', $this->decodePrimaryKey($value))->firstOrFail();
}
public function getTrialDays()
{
if($this->payment_id)
return 0;
$plan_expires = Carbon::parse($this->plan_expires);
if(!$this->payment_id && $plan_expires->gt(now()))
return $plan_expires->diffInDays();
return 0;
}
}

View File

@ -83,7 +83,7 @@ class PaymentRepository extends BaseRepository {
$client->service()->updatePaidToDate($data['amount'])->save();
}
// elseif($data['amount'] >0){
else{
//this fixes an edge case with unapplied payments
$client->service()->updatePaidToDate($data['amount'])->save();

View File

@ -14,6 +14,7 @@ namespace App\Services\Payment;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Jobs\Invoice\InvoiceWorkflowSettings;
use App\Jobs\Ninja\TransactionLog;
use App\Models\Client;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\PaymentHash;
@ -48,8 +49,6 @@ class UpdateInvoicePayment
collect($paid_invoices)->each(function ($paid_invoice) use ($invoices, $client) {
$client = $client->fresh();
$invoice = $invoices->first(function ($inv) use ($paid_invoice) {
return $paid_invoice->invoice_id == $inv->hashed_id;
});
@ -63,9 +62,15 @@ class UpdateInvoicePayment
$paid_amount = $paid_invoice->amount;
}
$client->paid_to_date += $paid_amount;
$client->balance -= $paid_amount;
$client->save();
\DB::connection(config('database.default'))->transaction(function () use($client, $paid_amount){
$update_client = Client::withTrashed()->where('id', $client->id)->lockForUpdate()->first();
$update_client->paid_to_date += $paid_amount;
$update_client->balance -= $paid_amount;
$update_client->save();
}, 1);
/* Need to determine here is we have an OVER payment - if YES only apply the max invoice amount */
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)

View File

@ -11,6 +11,7 @@
namespace App\Services\Recurring;
use App\Jobs\RecurringInvoice\SendRecurring;
use App\Jobs\Util\UnlinkFile;
use App\Models\RecurringInvoice;
use App\Services\Recurring\GetInvoicePdf;
@ -106,6 +107,10 @@ class RecurringService
$this->stop();
}
if ($request->has('send_now') && $request->input('send_now') == 'true' && $this->recurring_entity->invoices()->count() == 0) {
$this->sendNow();
}
if(isset($this->recurring_entity->client))
{
$offset = $this->recurring_entity->client->timezone_offset();
@ -115,6 +120,16 @@ class RecurringService
return $this;
}
public function sendNow()
{
if($this->recurring_entity instanceof RecurringInvoice)
SendRecurring::dispatchNow($this->recurring_entity, $this->recurring_entity->company->db);
return $this->recurring_entity;
}
public function fillDefaults()
{

View File

@ -86,7 +86,8 @@ class AccountTransformer extends EntityTransformer
'hosted_client_count' => (int) $account->hosted_client_count,
'hosted_company_count' => (int) $account->hosted_company_count,
'is_hosted' => (bool) Ninja::isHosted(),
'set_react_as_default_ap' => (bool) $account->set_react_as_default_ap
'set_react_as_default_ap' => (bool) $account->set_react_as_default_ap,
'trial_days_left' => Ninja::isHosted() ? (int) $account->getTrialDays() : 0,
];
}
@ -110,6 +111,5 @@ class AccountTransformer extends EntityTransformer
return $this->includeItem(auth()->user(), $transformer, User::class);
// return $this->includeItem($account->default_company->owner(), $transformer, User::class);
}
}

61
composer.lock generated
View File

@ -434,16 +434,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.230.0",
"version": "3.231.2",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "474f351aff22cc7a61016c1de79d7d2fe6c80d2b"
"reference": "9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/474f351aff22cc7a61016c1de79d7d2fe6c80d2b",
"reference": "474f351aff22cc7a61016c1de79d7d2fe6c80d2b",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab",
"reference": "9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab",
"shasum": ""
},
"require": {
@ -461,6 +461,7 @@
"andrewsville/php-token-reflection": "^1.4",
"aws/aws-php-sns-message-validator": "~1.0",
"behat/behat": "~3.0",
"composer/composer": "^1.10.22",
"doctrine/cache": "~1.4",
"ext-dom": "*",
"ext-openssl": "*",
@ -519,9 +520,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.230.0"
"source": "https://github.com/aws/aws-sdk-php/tree/3.231.2"
},
"time": "2022-07-05T18:19:42+00:00"
"time": "2022-07-08T18:16:11+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -2244,16 +2245,16 @@
},
{
"name": "gocardless/gocardless-pro",
"version": "4.17.0",
"version": "4.18.0",
"source": {
"type": "git",
"url": "https://github.com/gocardless/gocardless-pro-php.git",
"reference": "59ccdcbfbbf1a18b55c749ed121137dce6d6f3ae"
"reference": "dee046abbb7a37ef0a60bb03e2a467afc79a92a5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/gocardless/gocardless-pro-php/zipball/59ccdcbfbbf1a18b55c749ed121137dce6d6f3ae",
"reference": "59ccdcbfbbf1a18b55c749ed121137dce6d6f3ae",
"url": "https://api.github.com/repos/gocardless/gocardless-pro-php/zipball/dee046abbb7a37ef0a60bb03e2a467afc79a92a5",
"reference": "dee046abbb7a37ef0a60bb03e2a467afc79a92a5",
"shasum": ""
},
"require": {
@ -2293,9 +2294,9 @@
],
"support": {
"issues": "https://github.com/gocardless/gocardless-pro-php/issues",
"source": "https://github.com/gocardless/gocardless-pro-php/tree/v4.17.0"
"source": "https://github.com/gocardless/gocardless-pro-php/tree/v4.18.0"
},
"time": "2022-06-29T12:55:58+00:00"
"time": "2022-07-08T14:38:42+00:00"
},
{
"name": "google/apiclient",
@ -2369,16 +2370,16 @@
},
{
"name": "google/apiclient-services",
"version": "v0.256.0",
"version": "v0.257.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git",
"reference": "122e51021eb19b53f831904918460671d1e7259d"
"reference": "ae109202ee831a1fb70ba824181852e6179c848b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/122e51021eb19b53f831904918460671d1e7259d",
"reference": "122e51021eb19b53f831904918460671d1e7259d",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ae109202ee831a1fb70ba824181852e6179c848b",
"reference": "ae109202ee831a1fb70ba824181852e6179c848b",
"shasum": ""
},
"require": {
@ -2407,9 +2408,9 @@
],
"support": {
"issues": "https://github.com/googleapis/google-api-php-client-services/issues",
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.256.0"
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.257.0"
},
"time": "2022-07-04T01:10:37+00:00"
"time": "2022-07-08T01:28:13+00:00"
},
{
"name": "google/auth",
@ -5123,16 +5124,16 @@
},
{
"name": "microsoft/microsoft-graph",
"version": "1.70.0",
"version": "1.71.0",
"source": {
"type": "git",
"url": "https://github.com/microsoftgraph/msgraph-sdk-php.git",
"reference": "7d85293be037c4a2891a03cb953eb204bf68387e"
"reference": "f17ae778614d6ebf326d33292d09519d39b017a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/microsoftgraph/msgraph-sdk-php/zipball/7d85293be037c4a2891a03cb953eb204bf68387e",
"reference": "7d85293be037c4a2891a03cb953eb204bf68387e",
"url": "https://api.github.com/repos/microsoftgraph/msgraph-sdk-php/zipball/f17ae778614d6ebf326d33292d09519d39b017a8",
"reference": "f17ae778614d6ebf326d33292d09519d39b017a8",
"shasum": ""
},
"require": {
@ -5168,9 +5169,9 @@
"homepage": "https://developer.microsoft.com/en-us/graph",
"support": {
"issues": "https://github.com/microsoftgraph/msgraph-sdk-php/issues",
"source": "https://github.com/microsoftgraph/msgraph-sdk-php/tree/1.70.0"
"source": "https://github.com/microsoftgraph/msgraph-sdk-php/tree/1.71.0"
},
"time": "2022-06-21T13:37:02+00:00"
"time": "2022-07-07T10:04:08+00:00"
},
{
"name": "mollie/mollie-api-php",
@ -7659,16 +7660,16 @@
},
{
"name": "psy/psysh",
"version": "v0.11.6",
"version": "v0.11.7",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "3f5b5f8aaa979fbd0d1783173f4c82ad529fe621"
"reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/3f5b5f8aaa979fbd0d1783173f4c82ad529fe621",
"reference": "3f5b5f8aaa979fbd0d1783173f4c82ad529fe621",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/77fc7270031fbc28f9a7bea31385da5c4855cb7a",
"reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a",
"shasum": ""
},
"require": {
@ -7729,9 +7730,9 @@
],
"support": {
"issues": "https://github.com/bobthecow/psysh/issues",
"source": "https://github.com/bobthecow/psysh/tree/v0.11.6"
"source": "https://github.com/bobthecow/psysh/tree/v0.11.7"
},
"time": "2022-07-03T16:40:23+00:00"
"time": "2022-07-07T13:49:11+00:00"
},
{
"name": "ralouphie/getallheaders",

View File

@ -8,6 +8,7 @@
<meta name="google-signin-client_id" content="{{ config('services.google.client_id') }}">
<link rel="manifest" href="manifest.json?v={{ config('ninja.app_version') }}">
<script src="{{ asset('js/pdf.min.js') }}"></script>
<script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>
<script type="text/javascript">
pdfjsLib.GlobalWorkerOptions.workerSrc = "{{ asset('js/pdf.worker.min.js') }}";
</script>