Refactor subscription pricing and update server limit
This commit is contained in:
@@ -9,8 +9,9 @@ use Stripe\Checkout\Session;
|
|||||||
class PricingPlans extends Component
|
class PricingPlans extends Component
|
||||||
{
|
{
|
||||||
public bool $isTrial = false;
|
public bool $isTrial = false;
|
||||||
public function mount() {
|
public function mount()
|
||||||
$this->isTrial = !data_get(currentTeam(),'subscription.stripe_trial_already_ended');
|
{
|
||||||
|
$this->isTrial = !data_get(currentTeam(), 'subscription.stripe_trial_already_ended');
|
||||||
if (config('constants.limits.trial_period') == 0) {
|
if (config('constants.limits.trial_period') == 0) {
|
||||||
$this->isTrial = false;
|
$this->isTrial = false;
|
||||||
}
|
}
|
||||||
@@ -26,15 +27,15 @@ class PricingPlans extends Component
|
|||||||
case 'basic-yearly':
|
case 'basic-yearly':
|
||||||
$priceId = config('subscription.stripe_price_id_basic_yearly');
|
$priceId = config('subscription.stripe_price_id_basic_yearly');
|
||||||
break;
|
break;
|
||||||
case 'ultimate-monthly':
|
|
||||||
$priceId = config('subscription.stripe_price_id_ultimate_monthly');
|
|
||||||
break;
|
|
||||||
case 'pro-monthly':
|
case 'pro-monthly':
|
||||||
$priceId = config('subscription.stripe_price_id_pro_monthly');
|
$priceId = config('subscription.stripe_price_id_pro_monthly');
|
||||||
break;
|
break;
|
||||||
case 'pro-yearly':
|
case 'pro-yearly':
|
||||||
$priceId = config('subscription.stripe_price_id_pro_yearly');
|
$priceId = config('subscription.stripe_price_id_pro_yearly');
|
||||||
break;
|
break;
|
||||||
|
case 'ultimate-monthly':
|
||||||
|
$priceId = config('subscription.stripe_price_id_ultimate_monthly');
|
||||||
|
break;
|
||||||
case 'ultimate-yearly':
|
case 'ultimate-yearly':
|
||||||
$priceId = config('subscription.stripe_price_id_ultimate_yearly');
|
$priceId = config('subscription.stripe_price_id_ultimate_yearly');
|
||||||
break;
|
break;
|
||||||
@@ -64,8 +65,15 @@ class PricingPlans extends Component
|
|||||||
'success_url' => route('dashboard', ['success' => true]),
|
'success_url' => route('dashboard', ['success' => true]),
|
||||||
'cancel_url' => route('subscription.index', ['cancelled' => true]),
|
'cancel_url' => route('subscription.index', ['cancelled' => true]),
|
||||||
];
|
];
|
||||||
|
if (str($type)->contains('ultimate')) {
|
||||||
|
$payload['line_items'][0]['adjustable_quantity'] = [
|
||||||
|
'enabled' => true,
|
||||||
|
'minimum' => 10,
|
||||||
|
];
|
||||||
|
$payload['line_items'][0]['quantity'] = 10;
|
||||||
|
}
|
||||||
|
|
||||||
if (!data_get($team,'subscription.stripe_trial_already_ended')) {
|
if (!data_get($team, 'subscription.stripe_trial_already_ended')) {
|
||||||
if (config('constants.limits.trial_period') > 0) {
|
if (config('constants.limits.trial_period') > 0) {
|
||||||
$payload['subscription_data'] = [
|
$payload['subscription_data'] = [
|
||||||
'trial_period_days' => config('constants.limits.trial_period'),
|
'trial_period_days' => config('constants.limits.trial_period'),
|
||||||
|
|||||||
@@ -22,16 +22,13 @@
|
|||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
</x-slot:pro>
|
</x-slot:pro>
|
||||||
<x-slot:ultimate>
|
<x-slot:ultimate>
|
||||||
<x-forms.button x-show="selected === 'monthly'" x-cloak aria-describedby="tier-ultimate"
|
<x-forms.button x-show="selected === 'monthly'" x-cloak aria-describedby="tier-ultimate" class="w-full h-10 buyme"
|
||||||
class="w-full h-10 buyme"><a class="text-white hover:no-underline" href="{{ config('coolify.contact') }}"
|
wire:click="subscribeStripe('ultimate-monthly')">
|
||||||
target="_blank">
|
{{ $isTrial ? 'Start Trial' : 'Subscribe' }}
|
||||||
Contact us</a>
|
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
|
||||||
<x-forms.button x-show="selected === 'yearly'" x-cloak aria-describedby="tier-ultimate"
|
<x-forms.button x-show="selected === 'yearly'" x-cloak aria-describedby="tier-ultimate" class="w-full h-10 buyme"
|
||||||
class="w-full h-10 buyme"><a class="text-white hover:no-underline" href="{{ config('coolify.contact') }}"
|
wire:click="subscribeStripe('ultimate-yearly')"> {{ $isTrial ? 'Start Trial' : 'Subscribe' }}
|
||||||
target="_blank">
|
|
||||||
Contact us</a>
|
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
</x-slot:ultimate>
|
</x-slot:ultimate>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -875,6 +875,14 @@ Route::post('/payments/stripe/events', function () {
|
|||||||
$alreadyCancelAtPeriodEnd = data_get($subscription, 'stripe_cancel_at_period_end');
|
$alreadyCancelAtPeriodEnd = data_get($subscription, 'stripe_cancel_at_period_end');
|
||||||
$feedback = data_get($data, 'cancellation_details.feedback');
|
$feedback = data_get($data, 'cancellation_details.feedback');
|
||||||
$comment = data_get($data, 'cancellation_details.comment');
|
$comment = data_get($data, 'cancellation_details.comment');
|
||||||
|
$lookup_key = data_get($data, 'items.data.0.price.lookup_key');
|
||||||
|
if (str($lookup_key)->contains('ultimate')) {
|
||||||
|
$quantity = data_get($data, 'items.data.0.quantity', 10);
|
||||||
|
$team = data_get($subscription, 'team');
|
||||||
|
$team->update([
|
||||||
|
'custom_server_limit' => $quantity,
|
||||||
|
]);
|
||||||
|
}
|
||||||
$subscription->update([
|
$subscription->update([
|
||||||
'stripe_feedback' => $feedback,
|
'stripe_feedback' => $feedback,
|
||||||
'stripe_comment' => $comment,
|
'stripe_comment' => $comment,
|
||||||
|
|||||||
Reference in New Issue
Block a user