Skip to content

Commit 3ebb35a

Browse files
committed
fix: remove lemon + paddle things
1 parent f557cd0 commit 3ebb35a

File tree

12 files changed

+21
-480
lines changed

12 files changed

+21
-480
lines changed

app/Livewire/Subscription/Actions.php

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Livewire\Subscription;
44

55
use App\Models\Team;
6-
use Illuminate\Support\Facades\Http;
76
use Livewire\Component;
87

98
class Actions extends Component
@@ -15,70 +14,6 @@ public function mount()
1514
$this->server_limits = Team::serverLimit();
1615
}
1716

18-
public function cancel()
19-
{
20-
try {
21-
$subscription_id = currentTeam()->subscription->lemon_subscription_id;
22-
if (! $subscription_id) {
23-
throw new \Exception('No subscription found');
24-
}
25-
$response = Http::withHeaders([
26-
'Accept' => 'application/vnd.api+json',
27-
'Content-Type' => 'application/vnd.api+json',
28-
'Authorization' => 'Bearer '.config('subscription.lemon_squeezy_api_key'),
29-
])->delete('https://api.lemonsqueezy.com/v1/subscriptions/'.$subscription_id);
30-
$json = $response->json();
31-
if ($response->failed()) {
32-
$error = data_get($json, 'errors.0.status');
33-
if ($error === '404') {
34-
throw new \Exception('Subscription not found.');
35-
}
36-
throw new \Exception(data_get($json, 'errors.0.title', 'Something went wrong. Please try again later.'));
37-
} else {
38-
$this->dispatch('success', 'Subscription cancelled successfully. Reloading in 5s.');
39-
$this->dispatch('reloadWindow', 5000);
40-
}
41-
} catch (\Throwable $e) {
42-
return handleError($e, $this);
43-
}
44-
}
45-
46-
public function resume()
47-
{
48-
try {
49-
$subscription_id = currentTeam()->subscription->lemon_subscription_id;
50-
if (! $subscription_id) {
51-
throw new \Exception('No subscription found');
52-
}
53-
$response = Http::withHeaders([
54-
'Accept' => 'application/vnd.api+json',
55-
'Content-Type' => 'application/vnd.api+json',
56-
'Authorization' => 'Bearer '.config('subscription.lemon_squeezy_api_key'),
57-
])->patch('https://api.lemonsqueezy.com/v1/subscriptions/'.$subscription_id, [
58-
'data' => [
59-
'type' => 'subscriptions',
60-
'id' => $subscription_id,
61-
'attributes' => [
62-
'cancelled' => false,
63-
],
64-
],
65-
]);
66-
$json = $response->json();
67-
if ($response->failed()) {
68-
$error = data_get($json, 'errors.0.status');
69-
if ($error === '404') {
70-
throw new \Exception('Subscription not found.');
71-
}
72-
throw new \Exception(data_get($json, 'errors.0.title', 'Something went wrong. Please try again later.'));
73-
} else {
74-
$this->dispatch('success', 'Subscription resumed successfully. Reloading in 5s.');
75-
$this->dispatch('reloadWindow', 5000);
76-
}
77-
} catch (\Throwable $e) {
78-
return handleError($e, $this);
79-
}
80-
}
81-
8217
public function stripeCustomerPortal()
8318
{
8419
$session = getStripeCustomerPortalSession(currentTeam());

app/Models/Subscription.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,7 @@ public function team()
1515

1616
public function type()
1717
{
18-
if (isLemon()) {
19-
$basic = explode(',', config('subscription.lemon_squeezy_basic_plan_ids'));
20-
$pro = explode(',', config('subscription.lemon_squeezy_pro_plan_ids'));
21-
$ultimate = explode(',', config('subscription.lemon_squeezy_ultimate_plan_ids'));
22-
23-
$subscription = $this->lemon_variant_id;
24-
if (in_array($subscription, $basic)) {
25-
return 'basic';
26-
}
27-
if (in_array($subscription, $pro)) {
28-
return 'pro';
29-
}
30-
if (in_array($subscription, $ultimate)) {
31-
return 'ultimate';
32-
}
33-
} elseif (isStripe()) {
18+
if (isStripe()) {
3419
if (! $this->stripe_plan_id) {
3520
return 'zero';
3621
}

bootstrap/helpers/subscriptions.php

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,8 @@
11
<?php
22

33
use App\Models\Team;
4-
use Illuminate\Support\Carbon;
54
use Stripe\Stripe;
65

7-
function getSubscriptionLink($type)
8-
{
9-
$checkout_id = config("subscription.lemon_squeezy_checkout_id_$type");
10-
if (! $checkout_id) {
11-
return null;
12-
}
13-
$user_id = auth()->user()->id;
14-
$team_id = currentTeam()->id ?? null;
15-
$email = auth()->user()->email ?? null;
16-
$name = auth()->user()->name ?? null;
17-
$url = "https://store.coollabs.io/checkout/buy/$checkout_id?";
18-
if ($user_id) {
19-
$url .= "&checkout[custom][user_id]={$user_id}";
20-
}
21-
if (isset($team_id)) {
22-
$url .= "&checkout[custom][team_id]={$team_id}";
23-
}
24-
if ($email) {
25-
$url .= "&checkout[email]={$email}";
26-
}
27-
if ($name) {
28-
$url .= "&checkout[name]={$name}";
29-
}
30-
31-
return $url;
32-
}
33-
34-
function getPaymentLink()
35-
{
36-
return currentTeam()->subscription->lemon_update_payment_menthod_url;
37-
}
38-
39-
function getRenewDate()
40-
{
41-
return Carbon::parse(currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
42-
}
43-
44-
function getEndDate()
45-
{
46-
return Carbon::parse(currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
47-
}
48-
496
function isSubscriptionActive()
507
{
518
if (! isCloud()) {
@@ -60,12 +17,6 @@ function isSubscriptionActive()
6017
if (is_null($subscription)) {
6118
return false;
6219
}
63-
if (isLemon()) {
64-
return $subscription->lemon_status === 'active';
65-
}
66-
// if (isPaddle()) {
67-
// return $subscription->paddle_status === 'active';
68-
// }
6920
if (isStripe()) {
7021
return $subscription->stripe_invoice_paid === true;
7122
}
@@ -82,12 +33,6 @@ function isSubscriptionOnGracePeriod()
8233
if (! $subscription) {
8334
return false;
8435
}
85-
if (isLemon()) {
86-
$is_still_grace_period = $subscription->lemon_ends_at &&
87-
Carbon::parse($subscription->lemon_ends_at) > Carbon::now();
88-
89-
return $is_still_grace_period;
90-
}
9136
if (isStripe()) {
9237
return $subscription->stripe_cancel_at_period_end;
9338
}
@@ -98,18 +43,10 @@ function subscriptionProvider()
9843
{
9944
return config('subscription.provider');
10045
}
101-
function isLemon()
102-
{
103-
return config('subscription.provider') === 'lemon';
104-
}
10546
function isStripe()
10647
{
10748
return config('subscription.provider') === 'stripe';
10849
}
109-
function isPaddle()
110-
{
111-
return config('subscription.provider') === 'paddle';
112-
}
11350
function getStripeCustomerPortalSession(Team $team)
11451
{
11552
Stripe::setApiKey(config('subscription.stripe_api_key'));

config/subscription.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

33
return [
4-
'provider' => env('SUBSCRIPTION_PROVIDER', null), // stripe, paddle, lemon
4+
'provider' => env('SUBSCRIPTION_PROVIDER', null), // stripe
5+
56
// Stripe
67
'stripe_api_key' => env('STRIPE_API_KEY', null),
78
'stripe_webhook_secret' => env('STRIPE_WEBHOOK_SECRET', null),
@@ -22,29 +23,4 @@
2223

2324
'stripe_price_id_dynamic_monthly' => env('STRIPE_PRICE_ID_DYNAMIC_MONTHLY', null),
2425
'stripe_price_id_dynamic_yearly' => env('STRIPE_PRICE_ID_DYNAMIC_YEARLY', null),
25-
26-
// Paddle
27-
'paddle_vendor_id' => env('PADDLE_VENDOR_ID', null),
28-
'paddle_vendor_auth_code' => env('PADDLE_VENDOR_AUTH_CODE', null),
29-
'paddle_webhook_secret' => env('PADDLE_WEBHOOK_SECRET', null),
30-
'paddle_public_key' => env('PADDLE_PUBLIC_KEY', null),
31-
'paddle_price_id_basic_monthly' => env('PADDLE_PRICE_ID_BASIC_MONTHLY', null),
32-
'paddle_price_id_basic_yearly' => env('PADDLE_PRICE_ID_BASIC_YEARLY', null),
33-
'paddle_price_id_pro_monthly' => env('PADDLE_PRICE_ID_PRO_MONTHLY', null),
34-
'paddle_price_id_pro_yearly' => env('PADDLE_PRICE_ID_PRO_YEARLY', null),
35-
'paddle_price_id_ultimate_monthly' => env('PADDLE_PRICE_ID_ULTIMATE_MONTHLY', null),
36-
'paddle_price_id_ultimate_yearly' => env('PADDLE_PRICE_ID_ULTIMATE_YEARLY', null),
37-
38-
// Lemon
39-
'lemon_squeezy_api_key' => env('LEMON_SQUEEZY_API_KEY', null),
40-
'lemon_squeezy_webhook_secret' => env('LEMON_SQUEEZY_WEBHOOK_SECRET', null),
41-
'lemon_squeezy_checkout_id_basic_monthly' => env('LEMON_SQUEEZY_CHECKOUT_ID_BASIC_MONTHLY', null),
42-
'lemon_squeezy_checkout_id_basic_yearly' => env('LEMON_SQUEEZY_CHECKOUT_ID_BASIC_YEARLY', null),
43-
'lemon_squeezy_checkout_id_pro_monthly' => env('LEMON_SQUEEZY_CHECKOUT_ID_PRO_MONTHLY', null),
44-
'lemon_squeezy_checkout_id_pro_yearly' => env('LEMON_SQUEEZY_CHECKOUT_ID_PRO_YEARLY', null),
45-
'lemon_squeezy_checkout_id_ultimate_monthly' => env('LEMON_SQUEEZY_CHECKOUT_ID_ULTIMATE_MONTHLY', null),
46-
'lemon_squeezy_checkout_id_ultimate_yearly' => env('LEMON_SQUEEZY_CHECKOUT_ID_ULTIMATE_YEARLY', null),
47-
'lemon_squeezy_basic_plan_ids' => env('LEMON_SQUEEZY_BASIC_PLAN_IDS', ''),
48-
'lemon_squeezy_pro_plan_ids' => env('LEMON_SQUEEZY_PRO_PLAN_IDS', ''),
49-
'lemon_squeezy_ultimate_plan_ids' => env('LEMON_SQUEEZY_ULTIMATE_PLAN_IDS', ''),
5026
];

docker-compose.prod.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,6 @@ services:
6969
- STRIPE_PRICE_ID_ULTIMATE_MONTHLY_OLD
7070
- STRIPE_PRICE_ID_ULTIMATE_YEARLY_OLD
7171
- STRIPE_EXCLUDED_PLANS
72-
- PADDLE_VENDOR_ID
73-
- PADDLE_WEBHOOK_SECRET
74-
- PADDLE_VENDOR_AUTH_CODE
75-
- PADDLE_PUBLIC_KEY
76-
- PADDLE_PRICE_ID_BASIC_MONTHLY
77-
- PADDLE_PRICE_ID_BASIC_YEARLY
78-
- PADDLE_PRICE_ID_PRO_MONTHLY
79-
- PADDLE_PRICE_ID_PRO_YEARLY
80-
- PADDLE_PRICE_ID_ULTIMATE_MONTHLY
81-
- PADDLE_PRICE_ID_ULTIMATE_YEARLY
82-
- LEMON_SQUEEZY_API_KEY
83-
- LEMON_SQUEEZY_WEBHOOK_SECRET
84-
- LEMON_SQUEEZY_CHECKOUT_ID_BASIC_MONTHLY
85-
- LEMON_SQUEEZY_CHECKOUT_ID_BASIC_YEARLY
86-
- LEMON_SQUEEZY_CHECKOUT_ID_PRO_MONTHLY
87-
- LEMON_SQUEEZY_CHECKOUT_ID_PRO_YEARLY
88-
- LEMON_SQUEEZY_CHECKOUT_ID_ULTIMATE_MONTHLY
89-
- LEMON_SQUEEZY_CHECKOUT_ID_ULTIMATE_YEARLY
90-
- LEMON_SQUEEZY_BASIC_PLAN_IDS
91-
- LEMON_SQUEEZY_PRO_PLAN_IDS
92-
- LEMON_SQUEEZY_ULTIMATE_PLAN_IDS
9372
ports:
9473
- "${APP_PORT:-8000}:80"
9574
expose:

resources/views/components/paddle.blade.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)