1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

Merge pull request #7241 from turbo124/v5-develop

Fixes for trial plans
This commit is contained in:
David Bomba 2022-02-27 19:02:56 +11:00 committed by GitHub
commit a3e89ddf21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,7 +75,7 @@ class NinjaPlanController extends Controller
public function trial()
{
$gateway = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->first();
$gateway = CompanyGateway::on('db-ninja-01')->find(config('ninja.ninja_default_company_gateway_id'));
$data['gateway'] = $gateway;
@ -106,8 +106,7 @@ class NinjaPlanController extends Controller
$client->save();
//store payment method
$gateway = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->first();
$gateway = CompanyGateway::on('db-ninja-01')->find(config('ninja.ninja_default_company_gateway_id'));
$gateway_driver = $gateway->driver(auth()->guard('contact')->user()->client)->init();
$stripe_response = json_decode($request->input('gateway_response'));
@ -132,10 +131,16 @@ class NinjaPlanController extends Controller
$gateway_driver->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
//set free trial
$account = auth()->guard('contact')->user()->company->account;
$account->trial_started = now();
$account->trial_plan = 'pro';
$account->save();
// $account = auth()->guard('contact')->user()->company->account;
if(auth()->guard('contact')->user()->client->custom_value2){
MultiDB::findAndSetDbByAccountKey(auth()->guard('contact')->user()->client->custom_value2);
$account = Account::where('key', auth()->guard('contact')->user()->client->custom_value2);
$account->trial_started = now();
$account->trial_plan = 'pro';
$account->save();
}
MultiDB::setDB('db-ninja-01');
//create recurring invoice
$subscription_repo = new SubscriptionRepository();