diff --git a/app/Factory/QuickbooksSDKFactory.php b/app/Factory/QuickbooksSDKFactory.php new file mode 100644 index 000000000000..128b57a97d0c --- /dev/null +++ b/app/Factory/QuickbooksSDKFactory.php @@ -0,0 +1,46 @@ +company(); + MultiDB::findAndSetDbByCompanyKey($company->company_key); + // Retrieve token from the database + if(($quickbooks = DB::table('companies')->where('id', $company->id)->select(['quickbook_refresh_token','quickbooks_realm_id'])->first())) { + $refreshTokenKey = $quickbooks->quickbooks_refresh_token; + $QBORealmID = $quickbooks->quickbooks_realm_id; + // Retrieve value from cache + $accessTokenKey = Cache::get($company->company_key); + $tokens = compact('accessTokenKey','refreskTokenKey','QBORealmID'); + } + } + + $config = $tokens + config('services.quickbooks.settings') + [ + 'state' => Str::random(12) + ]; + $sdk = DataService::Configure($config); + if (env('APP_DEBUG')) { + $sdk->setLogLocation(storage_path("logs/quickbooks.log")); + $sdk->enableLog(); + } + + $sdk->setMinorVersion("73"); + $sdk->throwExceptionOnError(true); + + return $sdk; + } +}