2026-03-29 22:24:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\App;
|
|
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
use App\Models\Account;
|
2026-03-29 22:24:28 +00:00
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
2026-06-14 19:12:49 +00:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2026-05-03 20:26:55 +00:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
2026-03-29 22:24:28 +00:00
|
|
|
use Inertia\Inertia;
|
|
|
|
|
use Inertia\Response;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
2026-05-12 16:38:37 +00:00
|
|
|
use Throwable;
|
2026-03-29 22:24:28 +00:00
|
|
|
|
|
|
|
|
class BillingController extends Controller
|
|
|
|
|
{
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
public function subscribe(): RedirectResponse
|
2026-03-29 22:24:28 +00:00
|
|
|
{
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
return redirect()->route('app.onboarding');
|
2026-03-29 22:24:28 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-15 12:46:18 +00:00
|
|
|
public function processing(Request $request): Response|RedirectResponse
|
2026-03-29 22:24:28 +00:00
|
|
|
{
|
2026-04-15 12:46:18 +00:00
|
|
|
if (config('trypost.self_hosted')) {
|
|
|
|
|
return redirect()->route('app.calendar');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
$account = $request->user()->account;
|
2026-05-12 16:31:00 +00:00
|
|
|
$sessionId = $request->query('session_id');
|
2026-03-29 22:24:28 +00:00
|
|
|
|
2026-06-14 19:12:49 +00:00
|
|
|
// Consume the checkout session once: `fromCheckout` is true only the first
|
|
|
|
|
// time this session_id is seen, so a back-button/refresh to the success URL
|
|
|
|
|
// can't re-fire `checkout.completed`. `Cache::add` is atomic — it returns
|
|
|
|
|
// true only when the key didn't exist yet.
|
|
|
|
|
$fromCheckout = is_string($sessionId) && $sessionId !== ''
|
|
|
|
|
&& Cache::add("checkout_tracked:{$sessionId}", true, now()->addDay());
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
return Inertia::render('billing/Processing', [
|
feat: redesign billing, onboarding, sidebar, and settings architecture
- Sidebar reorganized: Workspace group (connections, hashtags, labels,
API keys, settings) and Account group (settings, usage, billing)
- Account group only visible to owner and hidden in self-hosted mode
- Onboarding simplified: role -> account (connect socials) -> completed
-> redirect to /subscribe. Removed Subscription setup step.
- Subscribe page redesigned with 4 plan cards, monthly/yearly toggle,
trial info, and per-plan features list
- Billing page redesigned following Sendkit layout (sections with
sidebar labels)
- Processing page uses usePoll with immediate watch for subscription
activation
- Cancel URL redirects directly to /subscribe
- Account settings page with name and billing_email (syncs with Stripe)
- Usage page with ring meters for all plan limits
- Settings layout tabs only for user pages (profile, password,
notifications). Workspace/API keys/billing are standalone pages.
- GoogleAuthButton extracted as reusable component
- WorkspaceRole TypeScript enum for type-safe role checks in frontend
- Trial period changed to 7 days
- Fixed onboarding loop when user confirms email
- All 1101 tests passing
2026-04-15 03:33:38 +00:00
|
|
|
'subscriptionActive' => $account && $account->subscribed(Account::SUBSCRIPTION_NAME),
|
2026-06-14 19:12:49 +00:00
|
|
|
'fromCheckout' => $fromCheckout,
|
2026-06-22 15:32:03 +00:00
|
|
|
'persona' => $request->user()->persona?->value,
|
2026-06-14 19:12:49 +00:00
|
|
|
'conversion' => $fromCheckout && $account?->stripe_id
|
2026-05-12 16:31:00 +00:00
|
|
|
? fn () => $this->buildConversionData($account, $sessionId)
|
|
|
|
|
: null,
|
2026-03-29 22:24:28 +00:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-12 16:31:00 +00:00
|
|
|
/**
|
|
|
|
|
* @return array{value: float, currency: string, transaction_id: string}|null
|
|
|
|
|
*/
|
|
|
|
|
private function buildConversionData(Account $account, string $sessionId): ?array
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$session = $account->stripe()->checkout->sessions->retrieve(
|
|
|
|
|
$sessionId,
|
|
|
|
|
['expand' => ['line_items.data.price']],
|
|
|
|
|
);
|
2026-05-12 16:38:37 +00:00
|
|
|
} catch (Throwable) {
|
2026-05-12 16:31:00 +00:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data_get($session, 'customer') !== $account->stripe_id) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$unitAmount = data_get($session, 'line_items.data.0.price.unit_amount');
|
|
|
|
|
$currency = data_get($session, 'line_items.data.0.price.currency');
|
|
|
|
|
$transactionId = data_get($session, 'id');
|
|
|
|
|
|
|
|
|
|
if (! is_int($unitAmount) || ! is_string($currency) || ! is_string($transactionId)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'value' => $unitAmount / 100,
|
|
|
|
|
'currency' => strtoupper($currency),
|
|
|
|
|
'transaction_id' => $transactionId,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 12:46:18 +00:00
|
|
|
public function index(Request $request): Response|RedirectResponse
|
2026-03-29 22:24:28 +00:00
|
|
|
{
|
2026-04-15 12:46:18 +00:00
|
|
|
if (config('trypost.self_hosted')) {
|
|
|
|
|
return redirect()->route('app.calendar');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
$account = $request->user()->account;
|
2026-03-31 03:40:18 +00:00
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
abort_unless($request->user()->isAccountOwner(), SymfonyResponse::HTTP_FORBIDDEN);
|
2026-04-14 21:22:36 +00:00
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
$subscription = $account->subscription(Account::SUBSCRIPTION_NAME);
|
2026-04-14 21:22:36 +00:00
|
|
|
|
2026-05-03 16:44:13 +00:00
|
|
|
return Inertia::render('settings/account/Billing', [
|
2026-04-15 01:22:04 +00:00
|
|
|
'hasSubscription' => $account->subscribed(Account::SUBSCRIPTION_NAME),
|
2026-05-14 22:46:34 +00:00
|
|
|
'onTrial' => $account->isOnTrial(),
|
2026-05-14 22:55:28 +00:00
|
|
|
'trialEndsAt' => $account->activeTrialEndsAt(),
|
2026-04-14 21:22:36 +00:00
|
|
|
'subscription' => $subscription?->only([
|
|
|
|
|
'stripe_status',
|
|
|
|
|
'ends_at',
|
|
|
|
|
]),
|
2026-04-15 01:22:04 +00:00
|
|
|
'plan' => $account->plan,
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
'workspaceCount' => $account->workspaces()->count(),
|
2026-04-15 01:22:04 +00:00
|
|
|
'invoices' => $account->invoices()->map(fn ($invoice) => [
|
2026-04-14 21:22:36 +00:00
|
|
|
'id' => $invoice->id,
|
2026-05-03 20:26:55 +00:00
|
|
|
'date' => $invoice->date(),
|
2026-04-14 21:22:36 +00:00
|
|
|
'total' => $invoice->total(),
|
|
|
|
|
'status' => $invoice->status,
|
|
|
|
|
'invoice_pdf' => $invoice->invoice_pdf,
|
|
|
|
|
]),
|
refactor: redesign billing settings + upgrade dialog with indies aesthetic
- Billing settings page restructured around the design system: dropped
the 280px-label / 1fr-content split for stacked HeadingSmall sections;
current plan rendered as a hero card with display-font name, price,
amber sticker tile, and an inline primary "Change plan" CTA; payment
method consolidated into a single sticker row with a violet card-icon
tile and the manage CTA on the same line; empty payment-method state
handled. Invoices keep the sticker-row treatment.
- Upgrade dialog mirrors Subscribe.vue end-to-end: planTones backgrounds
per slug, ⭐ POPULAR / CURRENT badges absolute-positioned, ink-bordered
rounded-full CTA pill, sticker check icons, "Everything in {plan}"
copy, IconInfoCircle tooltip on credits, yearly/monthly toggle pill
with rotating amber save-months badge. While a request is in flight
every plan button is disabled and the active one shows IconLoader2
spinner.
- Account model gains `displayablePaymentMethod()` returning the
card array used by the UI. Resolves the customer-level default first,
falls back to the first attached payment method (Stripe Checkout trials
anchor the card to the subscription rather than the customer, so the
customer-level lookup returns null even when a card exists).
- i18n: added `billing.subscription.expires_on` and `no_payment_method`
in en/pt-BR/es.
2026-05-06 20:00:25 +00:00
|
|
|
'defaultPaymentMethod' => $account->displayablePaymentMethod(),
|
2026-04-14 21:22:36 +00:00
|
|
|
]);
|
2026-03-29 22:24:28 +00:00
|
|
|
}
|
2026-03-31 03:40:18 +00:00
|
|
|
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
public function swapToYearly(Request $request): RedirectResponse
|
2026-03-31 03:40:18 +00:00
|
|
|
{
|
2026-04-15 12:46:18 +00:00
|
|
|
if (config('trypost.self_hosted')) {
|
|
|
|
|
return redirect()->route('app.calendar');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
$account = $request->user()->account;
|
2026-03-31 03:40:18 +00:00
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
abort_unless($request->user()->isAccountOwner(), SymfonyResponse::HTTP_FORBIDDEN);
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
abort_unless($account->subscribed(Account::SUBSCRIPTION_NAME), SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY, 'No active subscription');
|
2026-04-14 21:22:36 +00:00
|
|
|
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
$plan = $account->plan;
|
|
|
|
|
$yearlyPriceId = $plan?->stripe_yearly_price_id;
|
|
|
|
|
|
|
|
|
|
abort_if($yearlyPriceId === null, SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY, 'No annual price configured');
|
feat: redesign billing, onboarding, sidebar, and settings architecture
- Sidebar reorganized: Workspace group (connections, hashtags, labels,
API keys, settings) and Account group (settings, usage, billing)
- Account group only visible to owner and hidden in self-hosted mode
- Onboarding simplified: role -> account (connect socials) -> completed
-> redirect to /subscribe. Removed Subscription setup step.
- Subscribe page redesigned with 4 plan cards, monthly/yearly toggle,
trial info, and per-plan features list
- Billing page redesigned following Sendkit layout (sections with
sidebar labels)
- Processing page uses usePoll with immediate watch for subscription
activation
- Cancel URL redirects directly to /subscribe
- Account settings page with name and billing_email (syncs with Stripe)
- Usage page with ring meters for all plan limits
- Settings layout tabs only for user pages (profile, password,
notifications). Workspace/API keys/billing are standalone pages.
- GoogleAuthButton extracted as reusable component
- WorkspaceRole TypeScript enum for type-safe role checks in frontend
- Trial period changed to 7 days
- Fixed onboarding loop when user confirms email
- All 1101 tests passing
2026-04-15 03:33:38 +00:00
|
|
|
|
2026-05-03 19:52:28 +00:00
|
|
|
$subscription = $account->subscription(Account::SUBSCRIPTION_NAME);
|
2026-04-14 21:22:36 +00:00
|
|
|
|
2026-06-22 11:39:25 +00:00
|
|
|
abort_if($subscription === null, SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY, 'No active subscription');
|
|
|
|
|
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
if ($subscription->stripe_price === $yearlyPriceId) {
|
|
|
|
|
return redirect()->route('app.billing.index');
|
|
|
|
|
}
|
2026-04-14 21:22:36 +00:00
|
|
|
|
2026-06-22 00:28:47 +00:00
|
|
|
$authorization = Gate::inspect('swapPlan', [$account]);
|
2026-05-03 20:26:55 +00:00
|
|
|
|
|
|
|
|
if ($authorization->denied()) {
|
|
|
|
|
return back()->with('flash.error', $authorization->message());
|
|
|
|
|
}
|
|
|
|
|
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
$subscription->swap($yearlyPriceId);
|
2026-05-07 13:59:48 +00:00
|
|
|
|
2026-05-03 19:52:28 +00:00
|
|
|
return redirect()->route('app.billing.index')
|
feat: per-workspace pricing, onboarding, and billing overhaul
Pricing
- Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the
workspace count and syncs on workspace create/delete.
- 2,500 AI credits per workspace, pooled at the account level; monthly reset
on the billing anniversary, annual granted upfront (no rollover).
- One social account per network per workspace; remove all count-based limits
(workspace/social/member) and the legacy plan tiers (single Workspace plan).
Onboarding (cloud only: SELF_HOSTED=false + PostHog)
- Replace the /subscribe plan picker with /onboarding persona selection
(Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user
(users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly
price. 8-day trial so Stripe displays 7.
Billing screen
- Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade
banner for monthly subscribers (swapToYearly).
- Current-plan card shows the workspace count instead of the plan name.
System AI
- Brand analyzer / workspace autofill is always allowed and never debits credits
(system feature, not the user's usage).
Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network,
and onboarding logic.
2026-06-21 23:40:03 +00:00
|
|
|
->with('flash.success', __('billing.flash.switched_to_yearly'));
|
2026-04-14 21:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function portal(Request $request): RedirectResponse
|
|
|
|
|
{
|
2026-04-15 12:46:18 +00:00
|
|
|
if (config('trypost.self_hosted')) {
|
|
|
|
|
return redirect()->route('app.calendar');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
$account = $request->user()->account;
|
2026-04-14 21:22:36 +00:00
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
abort_unless($request->user()->isAccountOwner(), SymfonyResponse::HTTP_FORBIDDEN);
|
2026-04-14 21:22:36 +00:00
|
|
|
|
2026-04-15 01:22:04 +00:00
|
|
|
return $account->redirectToBillingPortal(
|
2026-04-14 21:22:36 +00:00
|
|
|
route('app.billing.index')
|
|
|
|
|
);
|
2026-03-31 03:40:18 +00:00
|
|
|
}
|
2026-03-29 22:24:28 +00:00
|
|
|
}
|