getTokenContent())) abort(400, 'Invalid token'); MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']); $data = [ 'type' => 'standard', 'email' => $request->getContact()->email, 'country' => $request->getCompany()->country()->iso_3166_2, ]; $company_gateway = CompanyGateway::query() ->where('gateway_key', 'd14dd26a47cecc30fdd65700bfb67b34') ->where('company_id', $request->getCompany()->id) ->first(); if ($company_gateway) { $config = decrypt($company_gateway->config); if(property_exists($config, 'account_id')) return render('gateways.stripe.connect.existing'); } $account = Account::create($data); nlog($account); $link = Account::link($account->id, $token); nlog($link); if(!$company_gateway) $company_gateway = CompanyGatewayFactory::create($request->getCompany()->id, $request->getContact()->id); $company_gateway->fill([ 'gateway_key' => 'd14dd26a47cecc30fdd65700bfb67b34', 'fees_and_limits' => [], 'config' => encrypt(json_encode(['account_id' => $account->id])) ]); $company_gateway->save(); return redirect($link['url']); } public function completed() { return render('gateways.stripe.connect.completed'); } }