Skip to content

Commit

Permalink
Get rid of plans
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Dec 24, 2023
1 parent de60fd2 commit 15819aa
Show file tree
Hide file tree
Showing 34 changed files with 2 additions and 546 deletions.
8 changes: 0 additions & 8 deletions .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,4 @@ PUSHER_APP_SECRET=

SUGGESTION_BOX_ENABLED=false

PLANS_ENABLED=true
PLANS_STANDARD_MAXIMUM_SPACES=2
PLANS_PREMIUM_MAXIMUM_SPACES=null

STRIPE_KEY=
STRIPE_SECRET=
STRIPE_PREMIUM_PLAN_PRICE_ID=

DISABLE_REGISTRATION=false
8 changes: 0 additions & 8 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,3 @@ PUSHER_APP_KEY=
PUSHER_APP_SECRET=

SUGGESTION_BOX_ENABLED=false

PLANS_ENABLED=false
PLANS_STANDARD_MAXIMUM_SPACES=2
PLANS_PREMIUM_MAXIMUM_SPACES=null

STRIPE_KEY=
STRIPE_SECRET=
STRIPE_PREMIUM_PLAN_PRICE_ID=
8 changes: 0 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,4 @@ PUSHER_APP_SECRET=

SUGGESTION_BOX_ENABLED=false

PLANS_ENABLED=false
PLANS_STANDARD_MAXIMUM_SPACES=2
PLANS_PREMIUM_MAXIMUM_SPACES=null

STRIPE_KEY=
STRIPE_SECRET=
STRIPE_PREMIUM_PLAN_PRICE_ID=

DISABLE_REGISTRATION=false
42 changes: 0 additions & 42 deletions app/Actions/CreateStripeCheckoutAction.php

This file was deleted.

30 changes: 0 additions & 30 deletions app/Actions/CreateStripeCustomerAction.php

This file was deleted.

31 changes: 0 additions & 31 deletions app/Actions/FetchStripeSubscriptionAction.php

This file was deleted.

6 changes: 0 additions & 6 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Jobs\FetchConversionRates;
use App\Jobs\ProcessRecurrings;
use App\Jobs\SendWeeklyReports;
use App\Jobs\SyncStripeSubscriptions;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

Expand All @@ -29,11 +28,6 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->job(new SyncStripeSubscriptions())->everyMinute()->when(function () {
return Helper::arePlansEnabled();
});

// Daily
$schedule->job(new ProcessRecurrings())->daily();
$schedule->job(new FetchConversionRates())->daily();

Expand Down
10 changes: 0 additions & 10 deletions app/Exceptions/UserStripelessException.php

This file was deleted.

5 changes: 0 additions & 5 deletions app/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ public static function detectDelimiter(string $line): string

return array_search(max($delimiters), $delimiters);
}

public static function arePlansEnabled(): bool
{
return env('PLANS_ENABLED', false);
}
}
59 changes: 0 additions & 59 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace App\Http\Controllers;

use App\Actions\CreateStripeCheckoutAction;
use App\Actions\CreateStripeCustomerAction;
use App\Actions\FetchStripeSubscriptionAction;
use App\Exceptions\UserStripelessException;
use Illuminate\Http\Request;
use App\Mail\PasswordChanged;
use Auth;
Expand Down Expand Up @@ -131,59 +127,4 @@ public function getDashboard()
{
return view('settings.dashboard');
}

public function getBilling(Request $request)
{
$user = $request->user();
$stripeSubscription = null;

try {
$stripeSubscription = (new FetchStripeSubscriptionAction())->execute($user->id);
} catch (UserStripelessException $e) {
// Don't worry, $stripeSubscription will simply be `null`
}

return view('settings.billing', [
'user' => $user,
'stripeSubscription' => $stripeSubscription
]);
}

public function postUpgrade(Request $request)
{
$user = $request->user();

if (!$user->stripe_customer_id) {
(new CreateStripeCustomerAction())->execute($user->id);
}

$stripeSubscription = (new FetchStripeSubscriptionAction())->execute($user->id);

if ($stripeSubscription) {
return redirect()->route('settings.billing');
}

$stripeCheckoutId = (new CreateStripeCheckoutAction())->execute($user->id);

return view('stripe_checkout_redirect', ['stripeCheckoutId' => $stripeCheckoutId]);
}

public function postCancel(Request $request)
{
$user = $request->user();

if (!$user->stripe_customer_id) {
return redirect()->route('settings.billing');
}

$stripeSubscription = (new FetchStripeSubscriptionAction())->execute($user->id);

if (!$stripeSubscription) {
return redirect()->route('settings.billing');
}

$stripeSubscription->cancel();

return redirect()->route('settings.billing');
}
}
6 changes: 0 additions & 6 deletions app/Http/Controllers/SpaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public function store(Request $request)
'currency_id' => 'required|exists:currencies,id'
]);

if (!$request->user()->can('create', Space::class)) {
$request->session()->flash('maximum_reached', true);

return redirect()->route('spaces.create');
}

(new CreateSpaceAction())->execute($request->name, $request->currency_id, Auth::id());

return redirect()->route('settings.spaces.index');
Expand Down
9 changes: 0 additions & 9 deletions app/Http/Controllers/SpaceInviteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ public function accept(Request $request, Space $space, SpaceInvite $invite)
abort(410);
}

if (!$request->user()->can('accept', SpaceInvite::class)) {
$request->session()->flash('maximum_reached', true);

return redirect()->route('space_invites.show', [
'space' => $space->id,
'invite' => $invite->id
]);
}

(new AcceptSpaceInviteAction())->execute($invite->id);

return redirect()->route('settings.spaces.index');
Expand Down
1 change: 0 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class Kernel extends HttpKernel
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'resolve-api-key' => \App\Http\Middleware\ResolveApiKey::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'stripe' => \App\Http\Middleware\RedirectIfStripeAbsent::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
Expand Down
25 changes: 0 additions & 25 deletions app/Http/Middleware/RedirectIfStripeAbsent.php

This file was deleted.

6 changes: 0 additions & 6 deletions app/Jobs/SendWeeklyReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Helper;
use App\Mail\WeeklyReport;
use App\Models\Space;
use Illuminate\Bus\Queueable;
Expand Down Expand Up @@ -50,11 +49,6 @@ public function handle()
ORDER BY spendings.amount DESC LIMIT 1', [$space->id, $lastWeekDate, $currentDate]);

foreach ($space->users as $user) {
// If plans are enabled, weekly reports can only be sent to users with a premium plan
if (Helper::arePlansEnabled() && $user->plan === 'standard') {
continue;
}

// Only send if user wants to receive report
if ($user->weekly_report) {
Mail::to($user->email)->queue(new WeeklyReport(
Expand Down
55 changes: 0 additions & 55 deletions app/Jobs/SyncStripeSubscriptions.php

This file was deleted.

Loading

0 comments on commit 15819aa

Please sign in to comment.