diff --git a/app/Http/Livewire/Subscription/Actions.php b/app/Http/Livewire/Subscription/Actions.php index 6c74880b7..7830a935b 100644 --- a/app/Http/Livewire/Subscription/Actions.php +++ b/app/Http/Livewire/Subscription/Actions.php @@ -17,7 +17,7 @@ public function cancel() $response = Http::withHeaders([ 'Accept' => 'application/vnd.api+json', 'Content-Type' => 'application/vnd.api+json', - 'Authorization' => 'Bearer ' . config('coolify.lemon_squeezy_api_key'), + 'Authorization' => 'Bearer ' . config('subscription.lemon_squeezy_api_key'), ])->delete('https://api.lemonsqueezy.com/v1/subscriptions/' . $subscription_id); $json = $response->json(); if ($response->failed()) { @@ -44,7 +44,7 @@ public function resume() $response = Http::withHeaders([ 'Accept' => 'application/vnd.api+json', 'Content-Type' => 'application/vnd.api+json', - 'Authorization' => 'Bearer ' . config('coolify.lemon_squeezy_api_key'), + 'Authorization' => 'Bearer ' . config('subscription.lemon_squeezy_api_key'), ])->patch('https://api.lemonsqueezy.com/v1/subscriptions/' . $subscription_id, [ 'data' => [ 'type' => 'subscriptions', diff --git a/app/Models/Server.php b/app/Models/Server.php index 8f70ef1f3..764c58246 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -16,11 +16,21 @@ protected static function booted() ServerSetting::create([ 'server_id' => $server->id, ]); - StandaloneDocker::create([ - 'name' => 'coolify', - 'network' => 'coolify', - 'server_id' => $server->id, - ]); + if ($server->id === 0) { + StandaloneDocker::create([ + 'id' => 0, + 'name' => 'coolify', + 'network' => 'coolify', + 'server_id' => $server->id, + ]); + } else { + StandaloneDocker::create([ + 'name' => 'coolify', + 'network' => 'coolify', + 'server_id' => $server->id, + ]); + } + }); static::deleting(function ($server) { $server->settings()->delete(); diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index 4b78c37a9..e0a52d5b1 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -14,9 +14,9 @@ public function team() } public function type() { - $basic = explode(',', config('coolify.lemon_squeezy_basic_plan_ids')); - $pro = explode(',', config('coolify.lemon_squeezy_pro_plan_ids')); - $ultimate = explode(',', config('coolify.lemon_squeezy_ultimate_plan_ids')); + $basic = explode(',', config('subscription.lemon_squeezy_basic_plan_ids')); + $pro = explode(',', config('subscription.lemon_squeezy_pro_plan_ids')); + $ultimate = explode(',', config('subscription.lemon_squeezy_ultimate_plan_ids')); $subscription = $this->lemon_variant_id; if (in_array($subscription, $basic)) { diff --git a/bootstrap/helpers/subscriptions.php b/bootstrap/helpers/subscriptions.php index 5cb17d588..b514fb5af 100644 --- a/bootstrap/helpers/subscriptions.php +++ b/bootstrap/helpers/subscriptions.php @@ -4,7 +4,7 @@ function getSubscriptionLink($type) { - $checkout_id = config("coolify.lemon_squeezy_checkout_id_$type"); + $checkout_id = config("subscription.lemon_squeezy_checkout_id_$type"); if (!$checkout_id) { return null; } diff --git a/config/coolify.php b/config/coolify.php index 0276b9a78..f3485f0da 100644 --- a/config/coolify.php +++ b/config/coolify.php @@ -4,17 +4,6 @@ 'self_hosted' => env('SELF_HOSTED', true), 'waitlist' => env('WAITLIST', false), 'license_url' => 'https://license.coolify.io', - 'lemon_squeezy_api_key' => env('LEMON_SQUEEZY_API_KEY', null), - 'lemon_squeezy_webhook_secret' => env('LEMON_SQUEEZY_WEBHOOK_SECRET', null), - 'lemon_squeezy_checkout_id_monthly_basic' => env('LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_BASIC', null), - 'lemon_squeezy_checkout_id_monthly_pro' => env('LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_PRO', null), - 'lemon_squeezy_checkout_id_monthly_ultimate' => env('LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_ULTIMATE', null), - 'lemon_squeezy_checkout_id_yearly_basic' => env('LEMON_SQUEEZY_CHECKOUT_ID_YEARLY_BASIC', null), - 'lemon_squeezy_checkout_id_yearly_pro' => env('LEMON_SQUEEZY_CHECKOUT_ID_YEARLY_PRO', null), - 'lemon_squeezy_checkout_id_yearly_ultimate' => env('LEMON_SQUEEZY_CHECKOUT_ID_YEARLY_ULTIMATE', null), - 'lemon_squeezy_basic_plan_ids' => env('LEMON_SQUEEZY_BASIC_PLAN_IDS', ""), - 'lemon_squeezy_pro_plan_ids' => env('LEMON_SQUEEZY_PRO_PLAN_IDS', ""), - 'lemon_squeezy_ultimate_plan_ids' => env('LEMON_SQUEEZY_ULTIMATE_PLAN_IDS', ""), 'mux_enabled' => env('MUX_ENABLED', true), 'dev_webhook' => env('SERVEO_URL'), 'base_config_path' => env('BASE_CONFIG_PATH', '/data/coolify'), diff --git a/config/subscription.php b/config/subscription.php new file mode 100644 index 000000000..d4e94c7d8 --- /dev/null +++ b/config/subscription.php @@ -0,0 +1,15 @@ + env('LEMON_SQUEEZY_API_KEY', null), + 'lemon_squeezy_webhook_secret' => env('LEMON_SQUEEZY_WEBHOOK_SECRET', null), + 'lemon_squeezy_checkout_id_monthly_basic' => env('LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_BASIC', null), + 'lemon_squeezy_checkout_id_monthly_pro' => env('LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_PRO', null), + 'lemon_squeezy_checkout_id_monthly_ultimate' => env('LEMON_SQUEEZY_CHECKOUT_ID_MONTHLY_ULTIMATE', null), + 'lemon_squeezy_checkout_id_yearly_basic' => env('LEMON_SQUEEZY_CHECKOUT_ID_YEARLY_BASIC', null), + 'lemon_squeezy_checkout_id_yearly_pro' => env('LEMON_SQUEEZY_CHECKOUT_ID_YEARLY_PRO', null), + 'lemon_squeezy_checkout_id_yearly_ultimate' => env('LEMON_SQUEEZY_CHECKOUT_ID_YEARLY_ULTIMATE', null), + 'lemon_squeezy_basic_plan_ids' => env('LEMON_SQUEEZY_BASIC_PLAN_IDS', ""), + 'lemon_squeezy_pro_plan_ids' => env('LEMON_SQUEEZY_PRO_PLAN_IDS', ""), + 'lemon_squeezy_ultimate_plan_ids' => env('LEMON_SQUEEZY_ULTIMATE_PLAN_IDS', ""), +]; diff --git a/database/seeders/InstanceSettingsSeeder.php b/database/seeders/InstanceSettingsSeeder.php index a00d8715c..1be6462c9 100644 --- a/database/seeders/InstanceSettingsSeeder.php +++ b/database/seeders/InstanceSettingsSeeder.php @@ -16,6 +16,7 @@ public function run(): void InstanceSettings::create([ 'id' => 0, 'is_registration_enabled' => true, + 'is_resale_license_active' => true, 'smtp_enabled' => true, 'smtp_host' => 'coolify-mail', 'smtp_port' => 1025, diff --git a/database/seeders/StandaloneDockerSeeder.php b/database/seeders/StandaloneDockerSeeder.php index 9f67de710..1e9a749dd 100644 --- a/database/seeders/StandaloneDockerSeeder.php +++ b/database/seeders/StandaloneDockerSeeder.php @@ -13,11 +13,11 @@ class StandaloneDockerSeeder extends Seeder */ public function run(): void { - StandaloneDocker::create([ - 'id' => 0, - 'name' => 'Standalone Docker 1', - 'network' => 'coolify', - 'server_id' => 0, - ]); + // StandaloneDocker::create([ + // 'id' => 0, + // 'name' => 'Standalone Docker 1', + // 'network' => 'coolify', + // 'server_id' => 0, + // ]); } } diff --git a/routes/webhooks.php b/routes/webhooks.php index 1e196181b..8d4917f17 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -208,7 +208,7 @@ })->name('webhooks.waitlist.cancel'); Route::post('/payments/events', function () { try { - $secret = config('coolify.lemon_squeezy_webhook_secret'); + $secret = config('subscription.lemon_squeezy_webhook_secret'); $payload = request()->collect(); $hash = hash_hmac('sha256', $payload, $secret); $signature = request()->header('X-Signature');