diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 59d2a1e30..abd93f684 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -516,9 +516,19 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted private function check_git_if_build_needed() { $this->generate_git_import_commands(); + $private_key = base64_encode($this->application->private_key->private_key); $this->execute_remote_command( [ - executeInDocker($this->deployment_uuid, "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" git ls-remote {$this->fullRepoUrl} {$this->branch}"), + executeInDocker($this->deployment_uuid, "mkdir -p /root/.ssh") + ], + [ + executeInDocker($this->deployment_uuid, "echo '{$private_key}' | base64 -d > /root/.ssh/id_rsa") + ], + [ + executeInDocker($this->deployment_uuid, "chmod 600 /root/.ssh/id_rsa") + ], + [ + executeInDocker($this->deployment_uuid, "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" git ls-remote {$this->fullRepoUrl} {$this->branch}"), "hidden" => true, "save" => "git_commit_sha" ], diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index 23ed70f8f..cd35dc477 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -39,14 +39,18 @@ class Subscription extends Model if (!$subscription) { return null; } - $subscriptionPlanId = data_get($subscription,'stripe_plan_id'); + $subscriptionPlanId = data_get($subscription, 'stripe_plan_id'); if (!$subscriptionPlanId) { return null; } + $subscriptionInvoicePaid = data_get($subscription, 'stripe_invoice_paid'); + if (!$subscriptionInvoicePaid) { + return null; + } $subscriptionConfigs = collect(config('subscription')); $stripePlanId = null; $subscriptionConfigs->map(function ($value, $key) use ($subscriptionPlanId, &$stripePlanId) { - if ($value === $subscriptionPlanId){ + if ($value === $subscriptionPlanId) { $stripePlanId = $key; }; })->first(); diff --git a/config/sentry.php b/config/sentry.php index 826794a5a..4b4820837 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.105', + 'release' => '4.0.0-beta.106', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 5bcfd4f1b..95806e408 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ id)->where('pull_request_id', $pull_request_id)->first(); if ($found) { $found->delete(); - $container_name = generateApplicationContainerName($application,$pull_request_id); + $container_name = generateApplicationContainerName($application, $pull_request_id); // ray('Stopping container: ' . $container_name); instant_remote_process(["docker rm -f $container_name"], $application->destination->server); return response('Preview Deployment closed.'); @@ -288,6 +288,14 @@ Route::post('/payments/stripe/events', function () { 'stripe_invoice_paid' => true, ]); break; + case 'payment_intent.payment_failed': + $customerId = data_get($data, 'customer'); + $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail(); + $subscription->update([ + 'stripe_invoice_paid' => false, + ]); + send_internal_notification('Subscription payment failed: ' . $subscription->team->id); + break; case 'customer.subscription.updated': $customerId = data_get($data, 'customer'); $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail(); @@ -305,11 +313,11 @@ Route::post('/payments/stripe/events', function () { 'stripe_plan_id' => $planId, 'stripe_cancel_at_period_end' => $cancelAtPeriodEnd, ]); - if ($status === 'paused') { + if ($status === 'paused' || $status === 'incomplete_expired') { $subscription->update([ 'stripe_invoice_paid' => false, ]); - send_internal_notification('Subscription paused for team: ' . $subscription->team->id); + send_internal_notification('Subscription paused or incomplete for team: ' . $subscription->team->id); } // Trial ended but subscribed, reactive servers diff --git a/versions.json b/versions.json index cf69f206f..e658db6af 100644 --- a/versions.json +++ b/versions.json @@ -4,7 +4,7 @@ "version": "3.12.36" }, "v4": { - "version": "4.0.0-beta.105" + "version": "4.0.0-beta.106" } } }