add stripe subscription

This commit is contained in:
Andras Bacsai
2023-08-24 16:14:09 +02:00
parent 2d8f166e4a
commit 39890b319a
36 changed files with 753 additions and 121 deletions

View File

@@ -9,7 +9,7 @@
@env('local')
<title>Coolify - localhost</title>
<link rel="icon" href="{{ asset('favicon-dev.png') }}" type="image/x-icon" />
@else
@else
<title>{{ $title ?? 'Coolify' }}</title>
<link rel="icon" href="{{ asset('coolify-transparent.png') }}" type="image/x-icon" />
@endenv
@@ -26,7 +26,7 @@
<body>
@livewireScripts
<x-toaster-hub />
@if (isInstanceAdmin() || is_subscription_in_grace_period())
@if (isSubscriptionOnGracePeriod())
<div class="fixed top-3 left-4" id="vue">
<magic-bar></magic-bar>
</div>
@@ -68,6 +68,18 @@
window.location.reload();
}
})
Livewire.on('info', (message) => {
if (message) Toaster.info(message)
})
Livewire.on('error', (message) => {
if (message) Toaster.error(message)
})
Livewire.on('warning', (message) => {
if (message) Toaster.warning(message)
})
Livewire.on('success', (message) => {
if (message) Toaster.success(message)
})
</script>
</body>

View File

@@ -0,0 +1,80 @@
<x-slot:basic>
<x-forms.button x-show="selected === 'monthly'" x-cloak aria-describedby="tier-basic" class="w-full h-10 buyme"
x-on:click="subscribe('basic-monthly')"> Subscribe
</x-forms.button>
<x-forms.button x-show="selected === 'yearly'" x-cloak aria-describedby="tier-basic" class="w-full h-10 buyme"
x-on:click="subscribe('basic-yearly')"> Subscribe
</x-forms.button>
</x-slot:basic>
<x-slot:pro>
<x-forms.button x-show="selected === 'monthly'" x-cloak aria-describedby="tier-pro" class="w-full h-10 buyme"
x-on:click="subscribe('pro-monthly')"> Subscribe
</x-forms.button>
<x-forms.button x-show="selected === 'yearly'" x-cloak aria-describedby="tier-pro" class="w-full h-10 buyme"
x-on:click="subscribe('pro-yearly')"> Subscribe
</x-forms.button>
</x-slot:pro>
<x-slot:ultimate>
<x-forms.button x-show="selected === 'monthly'" x-cloak aria-describedby="tier-ultimate" class="w-full h-10 buyme"
x-on:click="subscribe('ultimate-monthly')"> Subscribe
</x-forms.button>
<x-forms.button x-show="selected === 'yearly'" x-cloak aria-describedby="tier-ultimate" class="w-full h-10 buyme"
x-on:click="subscribe('ultimate-yearly')"> Subscribe
</x-forms.button>
</x-slot:ultimate>
<x-slot:other>
<script src="https://cdn.paddle.com/paddle/v2/paddle.js"></script>
<script type="text/javascript">
Paddle.Environment.set("{{ is_dev() ? 'sandbox' : 'production' }}");
Paddle.Setup({
seller: {{ config('subscription.paddle_vendor_id') }},
checkout: {
settings: {
displayMode: "overlay",
theme: "light",
}
}
});
function subscribe(type) {
let priceId = null
switch (type) {
case 'basic-monthly':
priceId = "{{ config('subscription.paddle_price_id_basic_monthly') }}"
break;
case 'basic-yearly':
priceId = "{{ config('subscription.paddle_price_id_basic_yearly') }}"
break;
case 'pro-monthly':
priceId = "{{ config('subscription.paddle_price_id_pro_monthly') }}"
break;
case 'pro-yearly':
priceId = "{{ config('subscription.paddle_price_id_pro_yearly') }}"
break;
case 'ultimate-monthly':
priceId = "{{ config('subscription.paddle_price_id_ultimate_monthly') }}"
break;
case 'ultimate-yearly':
priceId = "{{ config('subscription.paddle_price_id_ultimate_yearly') }}"
break;
default:
break;
}
Paddle.Checkout.open({
customer: {
email: '{{ auth()->user()->email }}',
},
customData: {
"team_id": "{{ currentTeam()->id }}",
},
items: [{
priceId,
quantity: 1
}],
});
}
</script>
</x-slot:other>

View File

@@ -105,10 +105,9 @@
<span>billed annually</span>
</span>
@if ($showSubscribeButtons)
<a x-show="selected === 'monthly'" x-cloak aria-describedby="tier-basic" class="buyme"
href="{{ getSubscriptionLink('monthly_basic') }}">Subscribe</a>
<a x-show="selected === 'yearly'" x-cloak aria-describedby="tier-basic" class="buyme"
href="{{ getSubscriptionLink('yearly_basic') }}">Subscribe</a>
@isset($basic)
{{ $basic }}
@endisset
@endif
<p class="mt-10 text-sm leading-6 text-white h-[6.5rem]">Start self-hosting in
the cloud
@@ -168,10 +167,9 @@
<span>billed annually</span>
</span>
@if ($showSubscribeButtons)
<a x-show="selected === 'monthly'" x-cloak aria-describedby="tier-pro" class="buyme"
href="{{ getSubscriptionLink('monthly_pro') }}">Subscribe</a>
<a x-show="selected === 'yearly'" x-cloak aria-describedby="tier-pro" class="buyme"
href="{{ getSubscriptionLink('yearly_pro') }}">Subscribe</a>
@isset($pro)
{{ $pro }}
@endisset
@endif
<p class="h-20 mt-10 text-sm leading-6 text-white">Scale your business or self-hosting environment.
</p>
@@ -227,10 +225,9 @@
<span>billed annually</span>
</span>
@if ($showSubscribeButtons)
<a x-show="selected === 'monthly'" x-cloak aria-describedby="tier-ultimate" class="buyme"
href="{{ getSubscriptionLink('monthly_ultimate') }}">Subscribe</a>
<a x-show="selected === 'yearly'" x-cloak aria-describedby="tier-ultimate" class="buyme"
href="{{ getSubscriptionLink('yearly_ultimate') }}">Subscribe</a>
@isset($ultimate)
{{ $ultimate }}
@endisset
@endif
<p class="h-20 mt-10 text-sm leading-6 text-white">Deploy complex infrastuctures and
manage them easily in one place.</p>
@@ -274,3 +271,6 @@
</div>
</div>
</div>
@isset($other)
{{ $other }}
@endisset