diff --git a/app/Console/Commands/WaitlistInvite.php b/app/Console/Commands/WaitlistInvite.php
index dd629d706..f3eefbcfa 100644
--- a/app/Console/Commands/WaitlistInvite.php
+++ b/app/Console/Commands/WaitlistInvite.php
@@ -92,7 +92,6 @@ class WaitlistInvite extends Command
}
private function send_email()
{
- ray($this->next_patient->email, $this->password);
$token = Crypt::encryptString("{$this->next_patient->email}@@@$this->password");
$loginLink = route('auth.link', ['token' => $token]);
$mail = new MailMessage();
diff --git a/app/Http/Livewire/Help.php b/app/Http/Livewire/Help.php
index 9f3ca434f..505224d2c 100644
--- a/app/Http/Livewire/Help.php
+++ b/app/Http/Livewire/Help.php
@@ -30,7 +30,7 @@ class Help extends Component
try {
$this->rateLimit(1, 60);
$this->validate();
- $subscriptionType = auth()->user()?->subscription?->type() ?? 'unknown';
+ $subscriptionType = auth()->user()?->subscription?->type();
$debug = "Route: {$this->path}";
$mail = new MailMessage();
$mail->view(
diff --git a/app/Http/Livewire/Subscription/PricingPlans.php b/app/Http/Livewire/Subscription/PricingPlans.php
index 80cc81dcf..d200ecd15 100644
--- a/app/Http/Livewire/Subscription/PricingPlans.php
+++ b/app/Http/Livewire/Subscription/PricingPlans.php
@@ -10,6 +10,7 @@ class PricingPlans extends Component
{
public function subscribeStripe($type)
{
+ $team = currentTeam();
Stripe::setApiKey(config('subscription.stripe_api_key'));
switch ($type) {
case 'basic-monthly':
@@ -50,10 +51,23 @@ class PricingPlans extends Component
'automatic_tax' => [
'enabled' => true,
],
+
'mode' => 'subscription',
'success_url' => route('dashboard', ['success' => true]),
'cancel_url' => route('subscription.index', ['cancelled' => true]),
];
+
+ if (!data_get($team,'subscription.stripe_trial_already_ended')) {
+ $payload['subscription_data'] = [
+ 'trial_period_days' => 30,
+ 'trial_settings' => [
+ 'end_behavior' => [
+ 'missing_payment_method' => 'cancel',
+ ]
+ ],
+ ];
+ $payload['payment_method_collection'] = 'if_required';
+ }
$customer = currentTeam()->subscription?->stripe_customer_id ?? null;
if ($customer) {
$payload['customer'] = $customer;
diff --git a/app/Jobs/SubscriptionTrialEndedJob.php b/app/Jobs/SubscriptionTrialEndedJob.php
new file mode 100755
index 000000000..39acd19a2
--- /dev/null
+++ b/app/Jobs/SubscriptionTrialEndedJob.php
@@ -0,0 +1,44 @@
+team);
+ $mail = new MailMessage();
+ $mail->subject('Action required: You trial in Coolify Cloud ended.');
+ $mail->view('emails.trial-ended', [
+ 'stripeCustomerPortal' => $session->url,
+ ]);
+ $this->team->members()->each(function ($member) use ($mail) {
+ if ($member->isAdmin()) {
+ ray('Sending trial ended email to ' . $member->email);
+ send_user_an_email($mail, $member->email);
+ send_internal_notification('Trial reminder email sent to ' . $member->email);
+ }
+ });
+ } catch (\Throwable $e) {
+ send_internal_notification('SubscriptionTrialEndsSoonJob failed with: ' . $e->getMessage());
+ ray($e->getMessage());
+ throw $e;
+ }
+ }
+}
diff --git a/app/Jobs/SubscriptionTrialEndsSoonJob.php b/app/Jobs/SubscriptionTrialEndsSoonJob.php
new file mode 100755
index 000000000..84bd8ee66
--- /dev/null
+++ b/app/Jobs/SubscriptionTrialEndsSoonJob.php
@@ -0,0 +1,44 @@
+team);
+ $mail = new MailMessage();
+ $mail->subject('You trial in Coolify Cloud ends soon.');
+ $mail->view('emails.trial-ends-soon', [
+ 'stripeCustomerPortal' => $session->url,
+ ]);
+ $this->team->members()->each(function ($member) use ($mail) {
+ if ($member->isAdmin()) {
+ ray('Sending trial ending email to ' . $member->email);
+ send_user_an_email($mail, $member->email);
+ send_internal_notification('Trial reminder email sent to ' . $member->email);
+ }
+ });
+ } catch (\Throwable $e) {
+ send_internal_notification('SubscriptionTrialEndsSoonJob failed with: ' . $e->getMessage());
+ ray($e->getMessage());
+ throw $e;
+ }
+ }
+}
diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php
index 4acd7fe8a..d69d95981 100644
--- a/app/Models/Subscription.php
+++ b/app/Models/Subscription.php
@@ -33,7 +33,7 @@ class Subscription extends Model
}
if (isStripe()) {
if (!$this->stripe_plan_id) {
- return 'unknown';
+ return 'zero';
}
$subscription = Subscription::where('id', $this->id)->first();
if (!$subscription) {
@@ -54,6 +54,6 @@ class Subscription extends Model
return Str::of($stripePlanId)->after('stripe_price_id_')->before('_')->lower();
}
}
- return 'unknown';
+ return 'zero';
}
}
diff --git a/app/Models/Team.php b/app/Models/Team.php
index 485811a17..558c8dc3b 100644
--- a/app/Models/Team.php
+++ b/app/Models/Team.php
@@ -120,4 +120,20 @@ class Team extends Model implements SendsDiscord, SendsEmail
{
return $this->hasMany(S3Storage::class);
}
+ public function trialEnded() {
+ foreach ($this->servers as $server) {
+ $server->settings()->update([
+ 'is_usable' => false,
+ 'is_reachable' => false,
+ ]);
+ }
+ }
+ public function trialEndedButSubscribed() {
+ foreach ($this->servers as $server) {
+ $server->settings()->update([
+ 'is_usable' => true,
+ 'is_reachable' => true,
+ ]);
+ }
+ }
}
diff --git a/database/migrations/2023_08_22_071059_add_stripe_trial_ended.php b/database/migrations/2023_08_22_071059_add_stripe_trial_ended.php
new file mode 100644
index 000000000..591f8382d
--- /dev/null
+++ b/database/migrations/2023_08_22_071059_add_stripe_trial_ended.php
@@ -0,0 +1,30 @@
+boolean('stripe_trial_already_ended')->default(false)->after('stripe_cancel_at_period_end');
+
+
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('subscriptions', function (Blueprint $table) {
+ $table->dropColumn('stripe_trial_already_ended');
+ });
+ }
+};
diff --git a/resources/views/components/emails/footer.blade.php b/resources/views/components/emails/footer.blade.php
index 44f47ef93..fba408cae 100644
--- a/resources/views/components/emails/footer.blade.php
+++ b/resources/views/components/emails/footer.blade.php
@@ -3,4 +3,4 @@
Thank you,
{{ config('app.name') ?? 'Coolify' }}
-{{ Illuminate\Mail\Markdown::parse('[Contact Support](https://docs.coollabs.io)') }}
+{{ Illuminate\Mail\Markdown::parse('[Contact Support](https://docs.coollabs.io/contact)') }}
diff --git a/resources/views/components/pricing-plans.blade.php b/resources/views/components/pricing-plans.blade.php
index c231f1d21..ce8d81c20 100644
--- a/resources/views/components/pricing-plans.blade.php
+++ b/resources/views/components/pricing-plans.blade.php
@@ -21,6 +21,7 @@
+