Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

Apply offer coupons from ?offer= links at the Welcome checkout (#452)

Paulo Castellano9f2b8e7441ba
diff --git a/.ai/rules/jobs-post-hog.md b/.ai/rules/jobs-post-hog.md
index e608e1b08..6475aeaeb 100644
--- a/.ai/rules/jobs-post-hog.md
+++ b/.ai/rules/jobs-post-hog.md
@@ -7,7 +7,7 @@ paths:
# Jobs Post Hog
## Sync PostHog billing state after Cashier
-Listen to Cashier's WebhookHandled event so local subscription state is persisted before PostHog jobs are dispatched. Account group properties are the current snapshot: subscription_status is canceled as soon as an ends_at exists (including grace period), while has_active_subscription remains true until access ends. Keep first_month_offer_ends_at event-derived and set it only on subscription creation so renewals cannot extend it.
+Listen to Cashier's WebhookHandled event so local subscription state is persisted before PostHog jobs are dispatched. Account group properties are the current snapshot: subscription_status is canceled as soon as an ends_at exists (including grace period), while has_active_subscription remains true until access ends. Keep the group's offer event-derived and set it only on subscription creation so renewals cannot change it.
## Stripe webhooks without a Cashier handler go through StripeBillingSignalListener
Cashier fires `WebhookHandled` only for types with a `handle*` method. `checkout.session.expired`, `invoice.payment_failed` and `invoice.upcoming` have none, so `StripeBillingSignalListener` listens to `WebhookReceived` for them.
diff --git a/.env.example b/.env.example
index 3112b931e..193c44291 100644
--- a/.env.example
+++ b/.env.example
@@ -261,25 +261,6 @@ AI_AUDIO_PROVIDER=elevenlabs
STRIPE_KEY=
STRIPE_SECRET=
STRIPE_WEBHOOK_SECRET=
-# SaaS default (recipe A): 8-day Stripe trial with card, no coupon, no promo field.
-# REQUIRE_CARD_FOR_TRIAL=true forces Checkout before app access (no generic trial).
-REQUIRE_CARD_FOR_TRIAL=true
-# Trial length in days. Card-required Checkout uses trialDays for first-time
-# subscribers when no first-month coupon is applied; re-subscribers skip trial.
-# No-card mode uses this for accounts.trial_ends_at. 0 = off.
-CASHIER_TRIAL_DAYS=8
-# Per-plan first-month coupons (amount_off, duration=once) so month one is $1.
-# Socials $19 − $18, Workspaces $99 − $88. When set for a qualifying first-time
-# monthly checkout of that plan, applies the coupon and SKIPS trialDays.
-# Empty for that plan = trial mode above. Never reuse one coupon on the other
-# plan. Yearly prices never get a coupon. XOR with CASHIER_ALLOW_PROMOTION_CODES
-# only when the coupon would apply — Stripe forbids both on one session
-# (ConfigureSubscriptionCheckout throws).
-STRIPE_SOCIALS_FIRST_MONTH_COUPON_ID=
-STRIPE_WORKSPACES_FIRST_MONTH_COUPON_ID=
-# Show Stripe Checkout promotion-code field when no coupon is applied.
-# Defaults to false (recipe A). Must be false when a first-month coupon applies.
-CASHIER_ALLOW_PROMOTION_CODES=false
# Stripe Plan Price IDs (one per plan × interval). Used by PlanSeeder.
STRIPE_WORKSPACE_MONTHLY=
diff --git a/AGENTS.md b/AGENTS.md
index 6f41460d0..4f32723a0 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -286,25 +286,20 @@ Every lang string is rendered in all 16 locales, and the longest one decides the
- A rewrite of existing text (shorten, rephrase, tone) keeps the text's own language; only new text is written in `{{ $language }}`.
- AI is web only: no REST API endpoint and no MCP tool calls an AI agent.
-## Stripe Checkout (env knobs)
+## Stripe Checkout (offers)
-Checkout options are configured only via env — do not hardcode trial/coupon/promo behavior in controllers. All of it goes through `App\Support\Billing\ConfigureSubscriptionCheckout` (called from `StartSubscriptionCheckout`).
+Everything that is not the full price is an offer (owner decision October 2026): the discount, the trial and the promotion code field live on the `offers` row (see "Offers"), never in env or in controllers. All of it goes through `App\Support\Billing\ConfigureSubscriptionCheckout` (called from `StartSubscriptionCheckout`).
-| Env | Config | Default | Effect |
-| --- | --- | --- | --- |
-| `REQUIRE_CARD_FOR_TRIAL` | `trypost.billing.require_card_for_trial` | `true` | `true`: app access only after Stripe Checkout (no generic signup trial). `false`: generic `accounts.trial_ends_at` trial without a card |
-| `CASHIER_TRIAL_DAYS` | `cashier.trial_days` | `8` | Card-required Checkout: `trialDays(N)` for **first-time** subscribers when no first-month coupon is applied (`0` = off). Re-subscribers skip trial. No-card mode: length of the generic signup trial |
-| `STRIPE_SOCIALS_FIRST_MONTH_COUPON_ID` | `cashier.first_month_coupon_ids.socials` | empty | Optional. `$18` off Socials monthly (`$19` → `$1`). When set for a qualifying first-time **monthly** checkout of that plan, applies `withCoupon` and **skips** trial. Empty = trial mode |
-| `STRIPE_WORKSPACES_FIRST_MONTH_COUPON_ID` | `cashier.first_month_coupon_ids.workspaces` | empty | Optional. `$88` off Workspaces monthly (`$99` → `$1`). Same qualification as the Socials coupon. Never reuse one coupon on the other plan |
-| `CASHIER_ALLOW_PROMOTION_CODES` | `cashier.allow_promotion_codes` | `false` | When `true` and no coupon is applied, show the Checkout promo-code field |
+There is no checkout env (owner decision October 2026; `REQUIRE_CARD_FOR_TRIAL` and `CASHIER_TRIAL_DAYS` were removed, so a forgotten env value can never override an offer). An account has app access with a subscription, or during a generic trial an offer started (see below). Signup alone never grants a trial.
Standing constraints:
-- Stripe rejects `discounts` (coupon) and `allow_promotion_codes` on the same session — if both would apply, `ConfigureSubscriptionCheckout` must throw (fail loud). Never “prefer one silently.” Envs may both be set when the account does **not** qualify for the coupon (no throw).
-- A set first-month coupon wins over trial (`trialDays` is skipped for that checkout).
-- Empty coupon + card required + first-time must use `trialDays` — do **not** reintroduce a required-coupon throw.
-- Coupon qualification stays: card required, no prior real subscription (`incomplete` / `incomplete_expired` still qualify), **and** the checkout price is that plan's **monthly** price. Workspace count is irrelevant — Socials is already capped at one, and a first-time Workspaces subscriber qualifies the same way.
-- First-month coupons are **per plan**. Socials is `$18` off, Workspaces is `$88` off. Never apply one plan's coupon to the other price, and never apply either coupon to a yearly price — `$190 − $18` is not `$1`.
-- Welcome checkout is the last Welcome step, the plan step (`app.welcome.plan.store`): it shows only **Socials**, monthly, with the first-month offer, and always opens Stripe Checkout on the **Socials monthly** price. Yearly and Workspaces stay on the billing change-plan picker for existing subscribers (they do not get a first-month coupon).
+- Without an offer the checkout charges the full price at once, with no coupon and no trial, and shows the promotion code field (owner decision October 2026), so a code from support or a partner still works. With an offer, the field shows only when its row has `allow_promotion_codes`.
+- An offer applies what its row sets: `stripe_coupon_id` (the discount), `trial_days` (clamped to Stripe's 2-day minimum), `allow_promotion_codes` and `requires_card`. Stripe rejects a coupon and promotion codes on one session but accepts a trial with either, so a coupon wins and the field is left off; a trial goes with both.
+- There are no fm1 coupon or promotion code envs any more (`STRIPE_*_FIRST_MONTH_COUPON_ID` and `CASHIER_ALLOW_PROMOTION_CODES` were removed in October 2026). Every offer reaches an account through its link: the 7-day trial (`ft7d`, `trial_days` 8 because Stripe Checkout counts the trial one day short and shows 8 as 7 days, `first_subscription_only`), the 7-day trial without a card (`ft7dnc`, `first_subscription_only`, so a former customer can never take free days again, `trial_days` 7: it never opens Stripe, so the generic trial lasts exactly what the row says), the `$1` first month (`fm1`, `first_subscription_only`) and Black Friday (`bf26`). There is no default offer: a signup without a link pays the full price. Do not reintroduce a checkout env.
+- First-subscription offers skip an account with a prior real subscription (`incomplete` / `incomplete_expired` still qualify).
+- An owner without app access is always sent to the plan step (`EnsureAccountReady`, the MCP step, the old subscribe route): it sends them back to the first unanswered step, so a new owner still starts at persona while a former customer lands on the plan directly.
+- Welcome checkout is the last Welcome step, the plan step (`app.welcome.plan.store`): it shows only **Socials**, monthly, and always opens Stripe Checkout on the **Socials monthly** price. Offers apply there and, coupons only, at **Subscribe now** on billing. Yearly and Workspaces stay on the billing change-plan picker for existing subscribers (no offer).
+- An offer with `requires_card = false` and `trial_days` (`Offer::startsWithoutCard()`) never opens Stripe: the Welcome plan step starts Cashier's generic trial (`StartGenericTrial`: `accounts.trial_ends_at`, the Socials `plan_id`, the redemption, `trial.started`) and goes on to the MCP step (owner decision October 2026). The account has app access while it lasts (`Account::hasAppAccess()` = subscribed or `onGenericTrial()`), billing shows the trial and **Subscribe now** (`app.billing.checkout`), a Checkout on the plan's monthly price charged at once, without carrying the days left of the trial (owner decision October 2026), applies a coupon offer claimed meanwhile (never a trial) and returns to billing after paying (`app.billing.processing?from=billing`, read through `CheckoutOrigin`). Changing plan during the trial (the workspace upgrade picker; billing shows only Subscribe now) opens the same Checkout on the picked plan and interval, under the same `swapPlan` rules, which allow a generic trial. Only Socials monthly gets an offer (`StartSubscriptionCheckout::qualifiesForOffer()`). An old subscription ending during the trial leaves its plan alone, and a second submit of the no-card trial starts nothing. The Welcome no-card trial goes through Processing too (`from=welcome`, ready at once), so phones skip the MCP step like a paid checkout. Cashier's `customer.subscription.created` handler clears `trial_ends_at`. When the trial ends without a subscription, access stops and the owner is back at Welcome. Every other offer goes through Stripe Checkout and asks for a card.
- Prefer documenting durable billing decisions here (and in `AGENTS.md`) — do **not** create a `.ai/` rules folder for this project.
## Plans and the workspace limit
@@ -338,19 +333,19 @@ used** — `syncWorkspaceQuantity()` was removed with the per-workspace model.
`workspaces.limit_reached`. Without a subscription it still goes to billing.
- POST at the cap is refused the same way (to the list, not 403'd, never to create),
tracked once by `store` itself after its transaction.
-- First-month coupon qualification is card required + first-time subscriber +
- that plan's monthly price. Workspace count is not part of it.
- (`incomplete` / `incomplete_expired` still qualify; coupon +
- `allow_promotion_codes` still throws.) Each plan has its own coupon.
-- Welcome checks out Socials monthly only so the `$1` first month can exist.
- Billing keeps yearly and Workspaces for subscribers changing plan.
+- Welcome checks out Socials monthly only, so an offer's price is always about
+ Socials monthly. Billing keeps yearly and Workspaces for subscribers changing
+ plan.
- The legacy plan is archived: it never appears in the picker, so nobody can move
back to it. Its `workspace_limit` is 1 because it costs less than Socials.
- Welcome's plan step (`app.welcome.plan`, after the current-tool step) shows
only Socials (owner decision October 2026): new owners always start on
Socials. The same `PlanPicker` drives upgrade/downgrade on the billing page
(`app.billing.change-plan`).
- A change is a `swap()` to another price id. `accounts.plan_id` is written by
+ A change is a `swap()` to another price id. A swap to a yearly price drops the
+ subscription's discount (`ChangePlan`, `discounts: ''`; owner decision October
+ 2026): an offer's coupon would otherwise take its percentage off a whole year.
+ A monthly swap keeps it, so an owner who upgrades mid-offer keeps what is left. `accounts.plan_id` is written by
`changePlan` after a successful `swap()` only when the subscription is
`active` or `trialing` (so create works before the webhook). Welcome checkout
never writes it — `StartSubscriptionCheckout` **clears** a leftover `plan_id`
@@ -363,6 +358,87 @@ used** — `syncWorkspaceQuantity()` was removed with the per-workspace model.
`AccountPolicy::useAi` checks app access and nothing else. Do not
reintroduce per-call usage recording.
+## Offers (`?offer=` links)
+
+An offer is anything the Welcome checkout gives instead of the full price
+(owner decision October 2026): a Stripe coupon, a trial, the promotion code
+field, or a mix. The 7-day trial (`ft7d`), the `$1` first month
+(`fm1`) and campaigns such as Black Friday (`bf26`) are all offers. It
+lives in `offers` (`slug` and `starts_at` required; `stripe_coupon_id`,
+`trial_days`, `ends_at` and `max_redemptions` nullable: no coupon, no trial, no
+end, no limit; `allow_promotion_codes`, `first_subscription_only` and
+`show_banner` false by default; `requires_card` true by default) and reaches an account through the pivot
+`account_offer` (`claimed_at`, `redeemed_at`).
+
+- **Capture.** `CaptureOffer` (web middleware) reads `?offer=<slug>` on any page.
+ A signed-in owner claims it at once (`ClaimOffer`). A guest's slug waits in the
+ session, only when it names an available offer, and the first authenticated
+ request claims it, so email signup, Google, GitHub and login need no code of
+ their own; moving between register and login keeps it. Slugs match exactly on
+ both engines through `Offer::findAvailable()` (MySQL compares without case). Ads and landing pages link to `/register?offer=<slug>`, win-back emails to
+ `/login?offer=<slug>`. There is no offer page or route.
+- **Who gets it.** Only an account owner whose account has no active
+ subscription: new signups and former customers alike, unless the offer is
+ `first_subscription_only`, which skips an account that was ever billed or
+ already redeemed an offer, a no-card trial included
+ (`Account::isFirstTimeSubscriber()`; Cashier clears `trial_ends_at` on any new
+ subscription, so the redemption is the lasting record), so trials and
+ the `$1` month never stack. `Offer::scopeAvailableTo()` holds both rules
+ and drops offers the account redeemed. An unknown, not yet started, ended or
+ full offer is ignored silently and nothing is kept for later. A redeemed offer
+ is never offered to that account again.
+- **The `offers` row is the only source of truth for dates and places.** The
+ Stripe coupon has no `redeem_by` and no `max_redemptions`. Only redemptions use
+ up a place (`Offer::scopeAvailable`), never a claim; two checkouts racing for the
+ last place may both get it (accepted).
+- A trial means `trial_days > 0` (`Offer::hasTrial()`); `0` is no trial.
+- **Checkout.** `Account::currentOffer()` picks the latest claim the account may
+ still use, else none (full price).
+ `ConfigureSubscriptionCheckout::apply()` applies it. Validity is checked again
+ when checkout starts. The controller resolves the offer once (`Account::currentOffer()`) and
+ hands the same one to `StartSubscriptionCheckout` and `apply()`, so the coupon,
+ the metadata and the tracked events agree. The offer id and slug go in the
+ subscription metadata (`trypost_offer_id`, `trypost_offer_slug`) and the slug in
+ the session metadata; the `customer.subscription.created` / `updated` webhook
+ writes `redeemed_at` (`RedeemOffer`) only once the subscription is `active` or
+ `trialing`, so an incomplete checkout never uses up a place. Offers apply at the
+ Welcome checkout (Socials monthly) and, coupons only, at Subscribe now on
+ billing (`currentOffer(withTrial: false)`).
+- **Revenue is counted once.** `conversion_*` goes on the event of the charge: `checkout.completed` for a Checkout charged at once, `trial.converted` for a trial charged when it ends. A trial without a card that subscribes active sends both events, and its `trial.converted` carries no `conversion_*` (`TrackTrialConverted` `withRevenue: false`).
+- **Tracking.** `checkout.started` is sent by `StartSubscriptionCheckout` itself, on the owner, for every Checkout (Welcome, Subscribe now, plan change), never by a controller. The offer goes to PostHog only with the checkout, as the property
+ `offer` holding its slug (`bf26`, `ft7d`, null without one) on
+ `checkout.started`, `checkout.completed`, `checkout.expired` and the account
+ group (set on subscription creation). There is no offer event of its own. The old `is_first_month_offer`,
+ `first_month_coupon_id` and `first_month_offer_ends_at` are gone.
+- **Copy.** Each offer's copy lives in `lang/<locale>/offers.php` under the
+ slug with dashes as underscores (`free-trial-14-days` → `free_trial_14_days`; the short slugs `ft7d`, `fm1`, `ft7dnc` and `bf26` keep theirs): `name` (the
+ banner's tag), `headline` (the banner's sentence), `price`, `period` and an
+ optional `unit` shown next to the price (`/month` for Black Friday; a trial or
+ the `$1` first month has none, so their copy decides it, never the code), in all
+ 16 locales, plus an optional `terms` for the line under the button (a trial
+ without a card says no card is needed; without it the line is
+ `welcome.plan_terms`, "Then :price/month"); the price is display text per locale, like
+ `billing.subscribe.prices.socials.monthly`. Nothing about the discount is
+ stored in the database, and the banner (`name`, `headline`) is optional: an
+ offer has both or neither, while `price`, `period` and `checkout_button` are required
+ (`OfferCopyTest`). Each trial length is its own offer with its own copy
+ (`ft7d`, `free-trial-14-days`), so several can run at once. The page has no fallback language, so `OfferResource`
+ checks each key in the current locale only. The Welcome plan step shows the
+ banner (a `bg-foreground` pill, the name in a `bg-background` uppercase tag) only when the row has `show_banner` and `name` and `headline` exist, and the offer price only when `price` and `period` exist; it never
+ prints a raw key. The button that opens Stripe Checkout is
+ the offer's `checkout_button` (required, like `price` and `period`), or
+ `welcome.plan_checkout_button` without an offer; without an offer the step
+ shows the full price.
+ `tests/Feature/Offer/OfferCopyTest.php` fails when an offer misses its copy in
+ any locale.
+- **Adding an offer.** Create its coupon in Stripe when it has one (no dates, no
+ limit), add its
+ copy to all 16 locales and deploy, then insert the `offers` row in each
+ environment's database by hand (owner decision October 2026: no data
+ migration, since the coupon id differs between Stripe test and live). Locally,
+ `php artisan db:seed --class=OfferSeeder` adds the test-mode offers; it is not
+ part of `DatabaseSeeder`, so tests never start with them.
+
## Multiple social accounts per network
A workspace may connect as many accounts of the same network as it wants (two
@@ -753,6 +829,7 @@ view turns a forgotten variable into a runtime-only failure.
- This project uses `@tabler/icons-vue` for all icons. NEVER use `lucide-vue-next`.
- Brand logos come from `@thesvg/vue`, one import per logo (`import Canva from '@thesvg/vue/canva'`). A one-color logo that must follow the theme goes through `inTextColor()` (`resources/js/lib/brandLogos.ts`).
+- **Exception — card brand logos on billing** (owner decision October 2026): the full-color card artwork lives in `public/images/card-brands/*.svg`, mapped by Stripe's `card.brand` in `resources/js/lib/cardBrands.ts` (a brand without its own art uses `generic.svg`).
- All Tabler icons are prefixed with `Icon`, e.g. `IconCheck`, `IconChevronRight`, `IconMail`.
- Import icons from `@tabler/icons-vue`: `import { IconCheck, IconX } from '@tabler/icons-vue'`.
- Browse available icons at https://tabler.io/icons
@@ -778,6 +855,7 @@ view turns a forgotten variable into a runtime-only failure.
- **Exception — the per-post table on the channel insights page** (owner decision 2026-10-05): it is page-based with numbered pages, 10 posts per page (`ListChannelPublicationPerformance::INSIGHTS_PAGE_SIZE`, through `insightsPage()`), and keeps `?page=` in the URL; a sort, period or filter change goes back to page 1. The API endpoint and the MCP tool for the same list keep the config page size through `handle()`.
- **Exception — the ideas board columns** (owner decision 2026-10-06): each stage column (and Unassigned) is its own scroll prop, `columns.<stage id|unassigned>`, with its own page name, and loads 10 ideas per page (`ListIdeas::BOARD_PAGE_SIZE`) as the column scrolls. A label filter change resets every column to page 1. Column counts come from the database (`stages.*.ideas_count`, `unassigned_count`), never from the loaded cards. The web board moves a card with `after_idea_id` (`MoveIdea::after()`), since a partly loaded column cannot send the full order; the API and MCP keep the full `idea_ids` contract. The gallery keeps the config page size.
- **Exception — the "What's New" modal** (owner decision 2026-10-14): it loads 5 entries per page, enough to fill the modal (capped at 640px) and the next one loads only when the user scrolls (`ListChangelogEntries::PAGE_SIZE`) under the page name `changelog_page`, as the shared optional scroll prop `changelogEntries` (built with the `changelog` card prop by `BuildChangelogProps`, which `HandleInertiaRequests` only spreads), requested by a partial reload when the modal opens.
+ - **Exception — the invoices tab on the billing page** (October 2026): invoices live in Stripe, which only pages by cursor, so `BillingController@index` sends `Inertia::scroll()` over Cashier's `cursorPaginateInvoices()` (paid invoices only, config page size). It is the one cursor paginator in the app; database lists keep `paginate()`.
- **This includes the public REST API** (`app/Http/Controllers/Api`). It used to pin its own page size of 15 as a stable contract; that exception is gone, so a list endpoint reads the same config as everything else. Changing `app.pagination.default` therefore changes the API's page size too — deliberate, and the reason a list response always carries `meta.per_page` for clients to read rather than assume.
## Changelog ("What's New")
diff --git a/app/Actions/Billing/ChangePlan.php b/app/Actions/Billing/ChangePlan.php
new file mode 100644
index 000000000..a91dab4f9
--- /dev/null
+++ b/app/Actions/Billing/ChangePlan.php
@@ -0,0 +1,74 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Actions\Billing;
+
+use App\Enums\Billing\CheckoutOrigin;
+use App\Enums\Billing\Interval;
+use App\Models\Account;
+use App\Models\Plan;
+use App\Support\Billing\SubscriptionPlanSync;
+use Illuminate\Support\Facades\Gate;
+use Laravel\Cashier\Exceptions\IncompletePayment;
+use Symfony\Component\HttpFoundation\Response;
+
+class ChangePlan
+{
+ public function __construct(private StartSubscriptionCheckout $checkout) {}
+
+ /**
+ * Moves the account to a plan's price, once `swapPlan` allows it. A
+ * subscription swaps its price; a generic trial subscribes through Stripe
+ * Checkout, charged at once, with a coupon offer the owner claimed meanwhile.
+ * A swap to a yearly price drops the subscription's discount: an offer is
+ * written for Socials monthly, and Stripe would take it off a whole year.
+ */
+ public function execute(Account $account, Plan $plan, Interval $interval): Response
+ {
+ $authorization = Gate::inspect('swapPlan', [$account, $plan]);
+
+ if ($authorization->denied()) {
+ return back()->with('flash.error', $authorization->message());
+ }
+
+ $priceId = $interval->priceIdFor($plan);
+
+ abort_if(blank($priceId), Response::HTTP_UNPROCESSABLE_ENTITY, 'No price configured for this interval');
+
+ if (! $account->subscribed(Account::SUBSCRIPTION_NAME)) {
+ return $this->checkout->redirect(
+ $account,
+ $priceId,
+ route('app.billing.index'),
+ $plan,
+ $account->currentOffer(withTrial: false),
+ CheckoutOrigin::Billing,
+ );
+ }
+
+ $subscription = $account->subscription(Account::SUBSCRIPTION_NAME);
+
+ try {
+ if ($subscription->stripe_price !== $priceId) {
+ $subscription->swap($priceId, $interval === Interval::Yearly ? ['discounts' => ''] : []);
+ }
+ } catch (IncompletePayment $exception) {
+ return redirect()->route('cashier.payment', [
+ $exception->payment->id,
+ 'redirect' => route('app.billing.index'),
+ ]);
+ }
+
+ $subscription->refresh();
+
+ if (! SubscriptionPlanSync::allows($subscription->stripe_status)) {
+ return redirect()->route('app.billing.index');
+ }
+
+ $account->update(['plan_id' => $plan->id]);
+
+ return redirect()->route('app.billing.index')
+ ->with('flash.success', __('billing.flash.plan_changed', ['plan' => $plan->name]));
+ }
+}
diff --git a/app/Actions/Billing/ListAccountCards.php b/app/Actions/Billing/ListAccountCards.php
new file mode 100644
index 000000000..5a4e85331
--- /dev/null
+++ b/app/Actions/Billing/ListAccountCards.php
@@ -0,0 +1,54 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Actions\Billing;
+
+use App\Http\Resources\App\PaymentMethodResource;
+use App\Models\Account;
+use App\Models\Subscription;
+use Laravel\Cashier\PaymentMethod;
+
+class ListAccountCards
+{
+ /**
+ * The customer's cards from Stripe, the default one first: the customer's
+ * default, else the subscription's (Stripe Checkout anchors the card
+ * there), whichever is a card in the list, else the first card. Nothing
+ * without a valid subscription.
+ *
+ * @return list<array{id: string, brand: string, last4: string, exp_month: int, exp_year: int, is_default: bool}>
+ */
+ public static function execute(Account $account, ?Subscription $subscription): array
+ {
+ if (blank($subscription)) {
+ return [];
+ }
+
+ $cards = $account->paymentMethods('card');
+
+ if ($cards->isEmpty()) {
+ return [];
+ }
+
+ $defaultId = collect([$account->defaultPaymentMethod()?->id, self::subscriptionPaymentMethodId($subscription)])
+ ->first(fn (?string $id): bool => $cards->contains(fn (PaymentMethod $card): bool => $card->id === $id))
+ ?? $cards->first()->id;
+
+ return $cards
+ ->sortByDesc(fn (PaymentMethod $card): bool => $card->id === $defaultId)
+ ->map(fn (PaymentMethod $card): array => PaymentMethodResource::make($card, $card->id === $defaultId)->resolve())
+ ->values()
+ ->all();
+ }
+
+ /**
+ * The card Stripe Checkout attached to the subscription, which renewals
+ * charge when the customer has no default of its own. Not expanded, so
+ * Stripe sends its id.
+ */
+ private static function subscriptionPaymentMethodId(Subscription $subscription): ?string
+ {
+ return $subscription->asStripeSubscription()->default_payment_method;
+ }
+}
diff --git a/app/Actions/Billing/ShowSubscriptionDiscount.php b/app/Actions/Billing/ShowSubscriptionDiscount.php
new file mode 100644
index 000000000..a92fdb6e3
--- /dev/null
+++ b/app/Actions/Billing/ShowSubscriptionDiscount.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Actions\Billing;
+
+use App\Http\Resources\App\SubscriptionDiscountResource;
+use App\Models\Account;
+use App\Models\Subscription;
+use Laravel\Cashier\Discount;
+
+class ShowSubscriptionDiscount
+{
+ /**
+ * The coupon on the valid subscription (`Account::validSubscription()`),
+ * read from Stripe, so billing can say why the invoice is lower than the
+ * plan price.
+ *
+ * @return array{value: string, duration: string, ends_at: string|null}|null
+ */
+ public static function execute(Account $account, ?Subscription $subscription): ?array
+ {
+ if (blank($subscription) || ! $account->hasStripeId()) {
+ return null;
+ }
+
+ return transform($subscription->discount(), fn (Discount $discount): array => SubscriptionDiscountResource::make($discount)->resolve());
+ }
+}
diff --git a/app/Actions/Billing/StartGenericTrial.php b/app/Actions/Billing/StartGenericTrial.php
new file mode 100644
index 000000000..eb7df5969
--- /dev/null
+++ b/app/Actions/Billing/StartGenericTrial.php
@@ -0,0 +1,66 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Actions\Billing;
+
+use App\Actions\Offer\RedeemOffer;
+use App\Enums\Billing\Interval;
+use App\Enums\PostHog\TrialEvent;
+use App\Jobs\PostHog\CaptureAccountEvent;
+use App\Jobs\PostHog\SyncUser;
+use App\Models\Account;
+use App\Models\Offer;
+use App\Models\Plan;
+use App\Models\User;
+use App\Services\PostHogService;
+use Illuminate\Support\Facades\DB;
+
+class StartGenericTrial
+{
+ /**
+ * Starts an offer's trial without a card: Cashier's generic trial on
+ * `accounts.trial_ends_at`, with nothing created in Stripe. The account
+ * has app access until it ends, and subscribes through Checkout from
+ * billing to keep it. A second submit while it runs starts nothing.
+ */
+ public static function execute(User $user, Plan $plan, Offer $offer): void
+ {
+ $account = DB::transaction(function () use ($user, $plan, $offer): ?Account {
+ $account = Account::query()->lockForUpdate()->find($user->account_id);
+
+ if ($account->onGenericTrial() || $account->subscribed(Account::SUBSCRIPTION_NAME)) {
+ return null;
+ }
+
+ $account->forceFill([
+ 'plan_id' => $plan->id,
+ 'trial_ends_at' => now()->addDays($offer->trial_days),
+ ])->save();
+
+ RedeemOffer::execute($account, $offer->id);
+
+ return $account;
+ });
+
+ if (blank($account)) {
+ return;
+ }
+
+ rescue(function () use ($user, $account, $plan, $offer): void {
+ SyncUser::dispatchIf(PostHogService::isEnabled(), (string) $user->id);
+ CaptureAccountEvent::dispatchIf(
+ PostHogService::isEnabled(),
+ (string) $user->id,
+ (string) $account->id,
+ TrialEvent::Started,
+ [
+ 'plan_name' => $plan->name,
+ 'interval' => Interval::Monthly->value,
+ 'offer' => $offer->slug,
+ 'trial_ends_at' => $account->trial_ends_at?->toIso8601String(),
+ ],
+ );
+ });
+ }
+}
diff --git a/app/Actions/Billing/StartSubscriptionCheckout.php b/app/Actions/Billing/StartSubscriptionCheckout.php
index 95c484288..cd20006bc 100644
--- a/app/Actions/Billing/StartSubscriptionCheckout.php
+++ b/app/Actions/Billing/StartSubscriptionCheckout.php
@@ -4,48 +4,78 @@ declare(strict_types=1);
namespace App\Actions\Billing;
+use App\Enums\Billing\CheckoutOrigin;
use App\Enums\Billing\Interval;
+use App\Enums\Plan\Slug;
+use App\Enums\PostHog\CheckoutEvent;
+use App\Jobs\PostHog\CaptureAccountEvent;
use App\Models\Account;
+use App\Models\Offer;
use App\Models\Plan;
+use App\Services\PostHogService;
use App\Support\Billing\ConfigureSubscriptionCheckout;
use Inertia\Inertia;
use Symfony\Component\HttpFoundation\Response;
class StartSubscriptionCheckout
{
- public function redirect(Account $account, string $priceId, string $cancelUrl, ?Plan $plan = null): Response
+ public function redirect(Account $account, string $priceId, string $cancelUrl, ?Plan $plan = null, ?Offer $offer = null, CheckoutOrigin $origin = CheckoutOrigin::Welcome): Response
{
// A leftover Workspaces row (unpaid/canceled without `deleted`) would
// let Processing treat auth.plan as checkout-complete and skip the wait.
- if ($account->plan_id !== null) {
+ if (filled($account->plan_id) && ! $account->onGenericTrial()) {
$account->update(['plan_id' => null]);
}
$account->syncOrCreateStripeCustomer();
- $monthlyPlan = $this->monthlyPlan($plan, $priceId);
$subscription = $account->newSubscription(Account::SUBSCRIPTION_NAME, $priceId);
- ConfigureSubscriptionCheckout::apply($subscription, $account, $monthlyPlan);
- $subscription->withMetadata(array_filter([
- ConfigureSubscriptionCheckout::FIRST_MONTH_COUPON_METADATA_KEY => $subscription->couponId,
- ], filled(...)));
+ $offer = $this->qualifiesForOffer($plan, $priceId) ? $offer : null;
+
+ $offerMetadata = array_filter([
+ ConfigureSubscriptionCheckout::OFFER_METADATA_KEY => $offer?->id,
+ ConfigureSubscriptionCheckout::OFFER_SLUG_METADATA_KEY => $offer?->slug,
+ ], filled(...));
+
+ ConfigureSubscriptionCheckout::apply($subscription, $offer);
+
+ $subscription->withMetadata($offerMetadata);
+
+ $interval = filled($plan) ? Interval::forPrice($plan, $priceId) : Interval::Monthly;
$session = $subscription->checkout([
- 'success_url' => route('app.billing.processing').'?session_id={CHECKOUT_SESSION_ID}',
+ 'success_url' => route('app.billing.processing', ['from' => $origin->value]).'&session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => $cancelUrl,
'metadata' => array_filter([
ConfigureSubscriptionCheckout::PLAN_METADATA_KEY => $plan?->slug->value,
- ConfigureSubscriptionCheckout::INTERVAL_METADATA_KEY => (filled($plan) ? Interval::forPrice($plan, $priceId) : Interval::Monthly)->value,
- ConfigureSubscriptionCheckout::FIRST_MONTH_OFFER_METADATA_KEY => filled($subscription->couponId) ? 'true' : 'false',
+ ConfigureSubscriptionCheckout::INTERVAL_METADATA_KEY => $interval->value,
+ ConfigureSubscriptionCheckout::OFFER_SLUG_METADATA_KEY => $offer?->slug,
], filled(...)),
]);
+ rescue(function () use ($account, $plan, $interval, $offer): void {
+ CaptureAccountEvent::dispatchIf(
+ PostHogService::isEnabled() && filled($account->owner_id),
+ (string) $account->owner_id,
+ (string) $account->id,
+ CheckoutEvent::Started,
+ [
+ 'plan_name' => $plan?->name,
+ 'interval' => $interval->value,
+ 'offer' => $offer?->slug,
+ ],
+ );
+ });
+
return Inertia::location($session->url);
}
- private function monthlyPlan(?Plan $plan, string $priceId): ?Plan
+ /**
+ * Offers are written for Socials monthly, so no other price gets one.
+ */
+ private function qualifiesForOffer(?Plan $plan, string $priceId): bool
{
- return $plan?->stripe_monthly_price_id === $priceId ? $plan : null;
+ return $plan?->slug === Slug::Socials && $plan->stripe_monthly_price_id === $priceId;
}
}
diff --git a/app/Actions/Offer/ClaimOffer.php b/app/Actions/Offer/ClaimOffer.php
new file mode 100644
index 000000000..69d09e1f0
--- /dev/null
+++ b/app/Actions/Offer/ClaimOffer.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Actions\Offer;
+
+use App\Models\Account;
+use App\Models\Offer;
+use Illuminate\Database\UniqueConstraintViolationException;
+
+class ClaimOffer
+{
+ /**
+ * Ties an available offer to an account without an active subscription.
+ * An unknown, unavailable or already redeemed offer is ignored. A request
+ * racing another one for the same claim finds it already written.
+ */
+ public static function execute(Account $account, string $slug): ?Offer
+ {
+ if ($account->hasActiveSubscription()) {
+ return null;
+ }
+
+ $offer = Offer::findAvailable($slug, $account);
+
+ if (blank($offer)) {
+ return null;
+ }
+
+ try {
+ $account->offers()->syncWithoutDetaching([$offer->id => ['claimed_at' => now()]]);
+ } catch (UniqueConstraintViolationException) {
+ }
+
+ return $offer;
+ }
+}
diff --git a/app/Actions/Offer/RedeemOffer.php b/app/Actions/Offer/RedeemOffer.php
new file mode 100644
index 000000000..f23e8d368
--- /dev/null
+++ b/app/Actions/Offer/RedeemOffer.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Actions\Offer;
+
+use App\Models\Account;
+use Illuminate\Support\Str;
+
+class RedeemOffer
+{
+ /**
+ * Records that the account used the offer it claimed: its subscription
+ * became active or trialing with it, or its trial without a card started.
+ * Only the first redemption counts; an offer the account never claimed is
+ * ignored. The redemption is what makes an offer a first subscription
+ * (`Account::isFirstTimeSubscriber()`).
+ */
+ public static function execute(Account $account, ?string $offerId): void
+ {
+ if (! Str::isUuid($offerId)) {
+ return;
+ }
+
+ $account->offers()
+ ->wherePivotNull('redeemed_at')
+ ->updateExistingPivot($offerId, ['redeemed_at' => now()]);
+ }
+}
diff --git a/app/Actions/User/CreateUser.php b/app/Actions/User/CreateUser.php
index 61e85fc0e..1fde89b37 100644
--- a/app/Actions/User/CreateUser.php
+++ b/app/Actions/User/CreateUser.php
@@ -6,14 +6,12 @@ namespace App\Actions\User;
use App\Actions\Workspace\CreateWorkspace;
use App\Enums\Account\LifecycleStage;
-use App\Enums\Plan\Slug;
use App\Enums\PostHog\UserEvent;
use App\Enums\User\Locale;
use App\Enums\User\TimeFormat;
use App\Enums\User\WeekStart;
use App\Jobs\PostHog\SyncUser;
use App\Models\Account;
-use App\Models\Plan;
use App\Models\User;
use App\Services\PostHogService;
use App\Support\Timezone;
@@ -30,16 +28,10 @@ class CreateUser
$isInviteRegistration = (bool) data_get($data, 'is_invite', false);
$user = DB::transaction(function () use ($data, $attributionParameters, $isInviteRegistration): User {
- $requiresCardForTrial = (bool) config('trypost.billing.require_card_for_trial', true);
$accountAttributes = [
'name' => data_get($data, 'name')."'s Account",
];
- if (! $requiresCardForTrial) {
- $accountAttributes['plan_id'] = Plan::where('slug', Slug::Socials)->value('id');
- $accountAttributes['trial_ends_at'] = now()->addDays(config('cashier.trial_days'));
- }
-
if (PostHogService::isEnabled()) {
$accountAttributes['lifecycle_stage'] = LifecycleStage::SignedUp;
$accountAttributes['lifecycle_stage_changed_at'] = now();
diff --git a/app/Enums/Billing/CheckoutOrigin.php b/app/Enums/Billing/CheckoutOrigin.php
new file mode 100644
index 000000000..f92340dfd
--- /dev/null
+++ b/app/Enums/Billing/CheckoutOrigin.php
@@ -0,0 +1,14 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Enums\Billing;
+
+/**
+ * Where a Stripe Checkout started, so Processing returns the owner there.
+ */
+enum CheckoutOrigin: string
+{
+ case Welcome = 'welcome';
+ case Billing = 'billing';
+}
diff --git a/app/Http/Controllers/App/BillingController.php b/app/Http/Controllers/App/BillingController.php
index 0aec8ad03..9e93b9322 100644
--- a/app/Http/Controllers/App/BillingController.php
+++ b/app/Http/Controllers/App/BillingController.php
@@ -4,25 +4,27 @@ declare(strict_types=1);
namespace App\Http\Controllers\App;
+use App\Actions\Billing\ChangePlan;
+use App\Actions\Billing\ListAccountCards;
+use App\Actions\Billing\ShowSubscriptionDiscount;
+use App\Enums\Billing\CheckoutOrigin;
use App\Enums\Billing\Interval;
use App\Http\Requests\App\Billing\ChangePlanRequest;
+use App\Http\Resources\App\InvoiceResource;
use App\Http\Resources\App\PlanResource;
use App\Models\Account;
use App\Models\Plan;
-use App\Support\Billing\SubscriptionPlanSync;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Gate;
use Inertia\Inertia;
use Inertia\Response;
-use Laravel\Cashier\Exceptions\IncompletePayment;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class BillingController extends Controller
{
public function subscribe(): RedirectResponse
{
- return redirect()->route('app.welcome.persona');
+ return redirect()->route('app.welcome.plan');
}
public function processing(Request $request): Response|RedirectResponse
@@ -32,9 +34,11 @@ class BillingController extends Controller
}
$account = $request->user()->accountOrFail();
+ $returnsToBilling = $request->query('from') === CheckoutOrigin::Billing->value;
return Inertia::render('billing/Processing', [
- 'subscriptionActive' => $account->subscribed(Account::SUBSCRIPTION_NAME),
+ 'ready' => $returnsToBilling ? $account->planMatchesSubscription() : $account->hasAppAccess(),
+ 'returnsToBilling' => $returnsToBilling,
]);
}
@@ -48,75 +52,55 @@ class BillingController extends Controller
abort_unless($request->user()->isAccountOwner(), SymfonyResponse::HTTP_FORBIDDEN);
- $subscription = $account->subscription(Account::SUBSCRIPTION_NAME);
+ $subscription = $account->validSubscription();
return Inertia::render('settings/account/Billing', [
- 'hasSubscription' => $account->subscribed(Account::SUBSCRIPTION_NAME),
+ 'hasSubscription' => filled($subscription),
'onTrial' => $account->isOnTrial(),
'trialEndsAt' => $account->activeTrialEndsAt(),
- 'subscription' => $subscription?->only([
- 'stripe_status',
- 'ends_at',
- ]),
- 'plan' => $account->plan ? PlanResource::make($account->plan)->resolve() : null,
+ 'subscription' => $subscription?->only(['stripe_status', 'ends_at']),
+ 'plan' => transform($account->plan, fn (Plan $plan): array => PlanResource::make($plan)->resolve()),
'workspaceCount' => $account->workspaces()->count(),
- 'workspaceLimit' => $account->workspaceLimit(),
- 'invoices' => $account->invoices()->map(fn ($invoice) => [
- 'id' => $invoice->id,
- 'date' => $invoice->date(),
- 'total' => $invoice->total(),
- 'status' => $invoice->status,
- 'invoice_pdf' => $invoice->invoice_pdf,
- ]),
- 'defaultPaymentMethod' => $account->displayablePaymentMethod(),
+ 'invoices' => Inertia::scroll(fn () => InvoiceResource::collection(
+ $account->cursorPaginateInvoices((int) config('app.pagination.default'), ['status' => 'paid']),
+ ))->matchOn('data.id'),
+ 'paymentMethods' => fn (): array => ListAccountCards::execute($account, $subscription),
+ 'discount' => fn (): ?array => ShowSubscriptionDiscount::execute($account, $subscription),
]);
}
- public function changePlan(ChangePlanRequest $request): RedirectResponse
+ public function changePlan(ChangePlanRequest $request, ChangePlan $changePlan): SymfonyResponse
{
if (config('trypost.self_hosted')) {
return redirect()->route('app.calendar');
}
- $account = $request->user()->account;
- $plan = Plan::active()->findOrFail($request->validated('plan_id'));
- $interval = Interval::from($request->validated('interval'));
-
- $authorization = Gate::inspect('swapPlan', [$account, $plan]);
+ return $changePlan->execute(
+ $request->user()->account,
+ Plan::active()->findOrFail($request->validated('plan_id')),
+ Interval::from($request->validated('interval')),
+ );
+ }
- if ($authorization->denied()) {
- return back()->with('flash.error', $authorization->message());
+ /**
+ * Subscribe now on billing: a generic trial subscribes to its plan's
+ * monthly price.
+ */
+ public function checkout(Request $request, ChangePlan $changePlan): SymfonyResponse
+ {
+ if (config('trypost.self_hosted')) {
+ return redirect()->route('app.calendar');
}
- $priceId = $interval->priceIdFor($plan);
-
- abort_if($priceId === null, SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY, 'No price configured for this interval');
-
- $subscription = $account->subscription(Account::SUBSCRIPTION_NAME);
-
- abort_if($subscription === null, SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY, 'No active subscription');
-
- try {
- if ($subscription->stripe_price !== $priceId) {
- $subscription->swap($priceId);
- }
- } catch (IncompletePayment $exception) {
- return redirect()->route('cashier.payment', [
- $exception->payment->id,
- 'redirect' => route('app.billing.index'),
- ]);
- }
+ $account = $request->user()->accountOrFail();
- $subscription->refresh();
+ $plan = Plan::active()->find($account->plan_id);
- if (! SubscriptionPlanSync::allows($subscription->stripe_status)) {
+ if ($account->subscribed(Account::SUBSCRIPTION_NAME) || blank($plan)) {
return redirect()->route('app.billing.index');
}
- $account->update(['plan_id' => $plan->id]);
-
- return redirect()->route('app.billing.index')
- ->with('flash.success', __('billing.flash.plan_changed', ['plan' => $plan->name]));
+ return $changePlan->execute($account, $plan, Interval::Monthly);
}
public function portal(Request $request): RedirectResponse
diff --git a/app/Http/Controllers/App/WelcomeController.php b/app/Http/Controllers/App/WelcomeController.php
index aa06d57a3..3e61d6d70 100644
--- a/app/Http/Controllers/App/WelcomeController.php
+++ b/app/Http/Controllers/App/WelcomeController.php
@@ -5,10 +5,11 @@ declare(strict_types=1);
namespace App\Http\Controllers\App;
use App\Actions\AccessToken\ListConnectedMcpClients;
+use App\Actions\Billing\StartGenericTrial;
use App\Actions\Billing\StartSubscriptionCheckout;
+use App\Enums\Billing\CheckoutOrigin;
use App\Enums\Billing\Interval;
use App\Enums\Plan\Slug;
-use App\Enums\PostHog\CheckoutEvent;
use App\Enums\PostHog\WelcomeEvent;
use App\Enums\User\Goal;
use App\Enums\User\Persona;
@@ -17,16 +18,15 @@ use App\Http\Requests\App\Welcome\StoreWelcomeGoalsRequest;
use App\Http\Requests\App\Welcome\StoreWelcomeMcpConnectClickRequest;
use App\Http\Requests\App\Welcome\StoreWelcomePersonaRequest;
use App\Http\Requests\App\Welcome\StoreWelcomeSoftwareRequest;
+use App\Http\Resources\App\OfferResource;
use App\Http\Resources\App\PlanResource;
use App\Models\Plan;
use App\Services\PostHogService;
-use App\Support\Billing\ConfigureSubscriptionCheckout;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response as InertiaResponse;
use Symfony\Component\HttpFoundation\Response;
-use Throwable;
class WelcomeController extends Controller
{
@@ -154,17 +154,17 @@ class WelcomeController extends Controller
}
$plan = Plan::active()->where('slug', Slug::Socials)->firstOrFail();
+ $offer = $request->user()->account->currentOffer();
return Inertia::render('welcome/Plan', [
'plan' => PlanResource::make($plan)->resolve(),
- 'firstMonthOffer' => ConfigureSubscriptionCheckout::offersFirstMonthCoupon($request->user()->account, $plan),
+ 'offer' => filled($offer) ? OfferResource::make($offer)->resolve() : null,
]);
}
public function storePlan(
Request $request,
StartSubscriptionCheckout $checkout,
- PostHogService $postHog,
): Response|RedirectResponse {
if ($redirect = $this->redirectIfStepIncomplete($request, requireGoals: true, requireSoftware: true)) {
return $redirect;
@@ -174,27 +174,17 @@ class WelcomeController extends Controller
$plan = Plan::active()->where('slug', Slug::Socials)->firstOrFail();
$priceId = Interval::Monthly->priceIdFor($plan);
- abort_if($priceId === null, Response::HTTP_INTERNAL_SERVER_ERROR, 'Price is not configured.');
-
- $firstMonthOffer = ConfigureSubscriptionCheckout::offersFirstMonthCoupon($user->account, $plan);
- $response = $checkout->redirect($user->account, $priceId, route('app.welcome.plan'), $plan);
-
- try {
- $postHog->capture(
- $user->id,
- CheckoutEvent::Started->value,
- [
- 'plan_name' => $plan->name,
- 'interval' => Interval::Monthly->value,
- 'is_first_month_offer' => $firstMonthOffer,
- ],
- $user->account,
- );
- } catch (Throwable $e) {
- report($e);
+ abort_if(blank($priceId), Response::HTTP_INTERNAL_SERVER_ERROR, 'Price is not configured.');
+
+ $offer = $user->account->currentOffer();
+
+ if ($offer?->startsWithoutCard()) {
+ StartGenericTrial::execute($user, $plan, $offer);
+
+ return redirect()->route('app.billing.processing', ['from' => CheckoutOrigin::Welcome->value]);
}
- return $response;
+ return $checkout->redirect($user->account, $priceId, route('app.welcome.plan'), $plan, $offer);
}
public function mcp(Request $request): InertiaResponse|RedirectResponse
@@ -202,7 +192,7 @@ class WelcomeController extends Controller
$user = $request->user();
if (! $user->account?->hasAppAccess()) {
- return redirect()->route('app.welcome.persona');
+ return redirect()->route('app.welcome.plan');
}
$workspace = $user->currentWorkspace;
@@ -238,7 +228,7 @@ class WelcomeController extends Controller
$user = $request->user();
if (! $user->account?->hasAppAccess()) {
- return redirect()->route('app.welcome.persona');
+ return redirect()->route('app.welcome.plan');
}
$postHog->capture(
@@ -260,7 +250,7 @@ class WelcomeController extends Controller
}
if ($user->isAccountOwner()) {
- return redirect()->route('app.welcome.persona');
+ return redirect()->route('app.welcome.plan');
}
return Inertia::render('welcome/SubscriptionRequired', [
diff --git a/app/Http/Middleware/Api/LoadWorkspaceFromToken.php b/app/Http/Middleware/Api/LoadWorkspaceFromToken.php
index 87e5ddb5f..fe2425df4 100644
--- a/app/Http/Middleware/Api/LoadWorkspaceFromToken.php
+++ b/app/Http/Middleware/Api/LoadWorkspaceFromToken.php
@@ -62,8 +62,7 @@ class LoadWorkspaceFromToken
}
}
- // Match web access (EnsureAccountReady): Stripe subscription OR generic
- // no-card trial when REQUIRE_CARD_FOR_TRIAL is disabled.
+ // Match web access (EnsureAccountReady).
if (! config('trypost.self_hosted') && ! $workspace->account?->hasAppAccess()) {
return response()->json(['message' => 'Active subscription required.'], Response::HTTP_PAYMENT_REQUIRED);
}
diff --git a/app/Http/Middleware/App/CaptureOffer.php b/app/Http/Middleware/App/CaptureOffer.php
new file mode 100644
index 000000000..ca78feedd
--- /dev/null
+++ b/app/Http/Middleware/App/CaptureOffer.php
@@ -0,0 +1,57 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Http\Middleware\App;
+
+use App\Actions\Offer\ClaimOffer;
+use App\Models\Offer;
+use Closure;
+use Illuminate\Http\Request;
+use Symfony\Component\HttpFoundation\Response;
+
+class CaptureOffer
+{
+ public const string SESSION_KEY = 'pending_offer';
+
+ /**
+ * Claims an `?offer=` for a signed-in owner at once. A guest's slug waits
+ * in the session until they sign in as the owner: signup (email, Google,
+ * GitHub) and login all land on an authenticated request, so none of them
+ * handles it. When that request carries a slug of its own that cannot be
+ * claimed, the waiting one is claimed instead.
+ *
+ * @param Closure(Request): (Response) $next
+ */
+ public function handle(Request $request, Closure $next): Response
+ {
+ $slug = $this->offerSlug($request);
+ $user = $request->user();
+
+ if (blank($user)) {
+ if (filled($slug) && filled(Offer::findAvailable($slug))) {
+ $request->session()->put(self::SESSION_KEY, $slug);
+ }
+ } elseif ($user->isAccountOwner()) {
+ $pendingSlug = $request->session()->pull(self::SESSION_KEY);
+ $claimed = filled($slug) ? ClaimOffer::execute($user->account, $slug) : null;
+
+ if (blank($claimed) && filled($pendingSlug)) {
+ ClaimOffer::execute($user->account, $pendingSlug);
+ }
+ }
+
+ return $next($request);
+ }
+
+ /**
+ * The `?offer=` slug, or null when it is missing, blank or not a string
+ * (`?offer[]=`), which a page must ignore instead of failing on.
+ */
+ private function offerSlug(Request $request): ?string
+ {
+ $slug = $request->query('offer');
+
+ return is_string($slug) && filled($slug) ? $slug : null;
+ }
+}
diff --git a/app/Http/Middleware/App/EnsureAccountReady.php b/app/Http/Middleware/App/EnsureAccountReady.php
index 9e41604bd..c4f6c2204 100644
--- a/app/Http/Middleware/App/EnsureAccountReady.php
+++ b/app/Http/Middleware/App/EnsureAccountReady.php
@@ -26,12 +26,12 @@ class EnsureAccountReady
if (! $account?->hasAppAccess()) {
// Members can't finish Welcome checkout — send them straight to
- // the hold screen instead of hopping through persona first.
+ // the hold screen instead of the Welcome steps.
if (! $user->isAccountOwner()) {
return redirect()->route('app.welcome.subscription-required');
}
- return redirect()->route('app.welcome.persona');
+ return redirect()->route('app.welcome.plan');
}
}
diff --git a/app/Http/Resources/App/InvoiceResource.php b/app/Http/Resources/App/InvoiceResource.php
new file mode 100644
index 000000000..d7640325e
--- /dev/null
+++ b/app/Http/Resources/App/InvoiceResource.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Http\Resources\App;
+
+use Illuminate\Http\Request;
+use Illuminate\Http\Resources\Json\JsonResource;
+use Laravel\Cashier\Invoice;
+
+/**
+ * A paid invoice on the billing page's invoices tab.
+ *
+ * @mixin Invoice
+ */
+class InvoiceResource extends JsonResource
+{
+ /**
+ * @return array{id: string, date: string, total: string, status: string, invoice_pdf: string|null}
+ */
+ public function toArray(Request $request): array
+ {
+ return [
+ 'id' => $this->id,
+ 'date' => $this->date()->toIso8601String(),
+ 'total' => $this->total(),
+ 'status' => $this->status,
+ 'invoice_pdf' => $this->invoice_pdf,
+ ];
+ }
+}
diff --git a/app/Http/Resources/App/OfferResource.php b/app/Http/Resources/App/OfferResource.php
new file mode 100644
index 000000000..b84ec2997
--- /dev/null
+++ b/app/Http/Resources/App/OfferResource.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Http\Resources\App;
+
+use App\Models\Offer;
+use Illuminate\Http\Request;
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\Lang;
+
+/**
+ * The offer's copy lives in lang/<locale>/offers.php. The page has no
+ * fallback language, so each key is checked in the current locale only and
+ * the page never prints a raw key.
+ *
+ * @mixin Offer
+ */
+class OfferResource extends JsonResource
+{
+ /**
+ * @return array{key: string, has_banner: bool, has_checkout_copy: bool, has_unit: bool, has_terms: bool}
+ */
+ public function toArray(Request $request): array
+ {
+ $key = $this->langKey();
+
+ return [
+ 'key' => $key,
+ 'has_banner' => $this->show_banner && $this->hasCopy("offers.{$key}.name") && $this->hasCopy("offers.{$key}.headline"),
+ 'has_checkout_copy' => $this->hasCopy("offers.{$key}.price") && $this->hasCopy("offers.{$key}.period") && $this->hasCopy("offers.{$key}.checkout_button"),
+ 'has_unit' => $this->hasCopy("offers.{$key}.unit"),
+ 'has_terms' => $this->hasCopy("offers.{$key}.terms"),
+ ];
+ }
+
+ private function hasCopy(string $key): bool
+ {
+ return Lang::has($key, null, false);
+ }
+}
diff --git a/app/Http/Resources/App/PaymentMethodResource.php b/app/Http/Resources/App/PaymentMethodResource.php
new file mode 100644
index 000000000..9b8ca531c
--- /dev/null
+++ b/app/Http/Resources/App/PaymentMethodResource.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Http\Resources\App;
+
+use Illuminate\Http\Request;
+use Illuminate\Http\Resources\Json\JsonResource;
+use Laravel\Cashier\PaymentMethod;
+
+/**
+ * A card saved on the Stripe customer, as the billing page lists it.
+ *
+ * @mixin PaymentMethod
+ */
+class PaymentMethodResource extends JsonResource
+{
+ public function __construct(PaymentMethod $resource, private bool $isDefault = false)
+ {
+ parent::__construct($resource);
+ }
+
+ /**
+ * @return array{id: string, brand: string, last4: string, exp_month: int, exp_year: int, is_default: bool}
+ */
+ public function toArray(Request $request): array
+ {
+ return [
+ 'id' => $this->id,
+ 'brand' => $this->card->brand,
+ 'last4' => $this->card->last4,
+ 'exp_month' => $this->card->exp_month,
+ 'exp_year' => $this->card->exp_year,
+ 'is_default' => $this->isDefault,
+ ];
+ }
+}
diff --git a/app/Http/Resources/App/SubscriptionDiscountResource.php b/app/Http/Resources/App/SubscriptionDiscountResource.php
new file mode 100644
index 000000000..26739f3d9
--- /dev/null
+++ b/app/Http/Resources/App/SubscriptionDiscountResource.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Http\Resources\App;
+
+use Illuminate\Http\Request;
+use Illuminate\Http\Resources\Json\JsonResource;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Number;
+use Laravel\Cashier\Cashier;
+use Laravel\Cashier\Discount;
+
+/**
+ * The coupon on the subscription, so the billing page can say why the
+ * invoice is lower than the plan price.
+ *
+ * @mixin Discount
+ */
+class SubscriptionDiscountResource extends JsonResource
+{
+ /**
+ * @return array{value: string, duration: string, ends_at: string|null}
+ */
+ public function toArray(Request $request): array
+ {
+ $coupon = $this->coupon();
+
+ return [
+ 'value' => $coupon->isPercentage()
+ ? Number::percentage($coupon->percentOff(), maxPrecision: 2, locale: App::currentLocale())
+ : Cashier::formatAmount($coupon->rawAmountOff(), $coupon->asStripeCoupon()->currency, App::currentLocale()),
+ 'duration' => $coupon->duration(),
+ 'ends_at' => $this->end()?->toIso8601String(),
+ ];
+ }
+}
diff --git a/app/Jobs/PostHog/TrackBilling.php b/app/Jobs/PostHog/TrackBilling.php
index 9e9d63834..b388583da 100644
--- a/app/Jobs/PostHog/TrackBilling.php
+++ b/app/Jobs/PostHog/TrackBilling.php
@@ -64,7 +64,7 @@ class TrackBilling implements ShouldQueue
'subscription_status' => $account->subscriptionStatus(),
'has_active_subscription' => $account->hasActiveSubscription(),
...$this->currentCancellationProperties($account),
- ...$this->firstMonthOfferProperties(),
+ ...$this->offerProperties(),
]);
SyncUser::dispatch((string) $account->owner_id);
@@ -113,14 +113,14 @@ class TrackBilling implements ShouldQueue
/**
* @return array<string, mixed>
*/
- private function firstMonthOfferProperties(): array
+ private function offerProperties(): array
{
if ($this->event !== BillingEvent::Created) {
return [];
}
return [
- 'first_month_offer_ends_at' => StripeSubscriptionConversion::firstMonthOfferEndsAt($this->payload),
+ 'offer' => StripeSubscriptionConversion::offerSlug($this->payload),
];
}
}
diff --git a/app/Jobs/PostHog/TrackCheckoutExpired.php b/app/Jobs/PostHog/TrackCheckoutExpired.php
index 16c093922..7b77583ad 100644
--- a/app/Jobs/PostHog/TrackCheckoutExpired.php
+++ b/app/Jobs/PostHog/TrackCheckoutExpired.php
@@ -22,7 +22,7 @@ class TrackCheckoutExpired extends AbstractTrackStripeEvent
}
/**
- * @return array{plan_name: string|null, interval: string|null, is_first_month_offer: bool, checkout_session_id: string|null}
+ * @return array{plan_name: string|null, interval: string|null, offer: string|null, checkout_session_id: string|null}
*/
protected function properties(Account $account): array
{
@@ -32,7 +32,7 @@ class TrackCheckoutExpired extends AbstractTrackStripeEvent
return [
'plan_name' => filled($planSlug) ? Plan::where('slug', $planSlug)->value('name') : null,
'interval' => data_get($metadata, ConfigureSubscriptionCheckout::INTERVAL_METADATA_KEY),
- 'is_first_month_offer' => data_get($metadata, ConfigureSubscriptionCheckout::FIRST_MONTH_OFFER_METADATA_KEY) === 'true',
+ 'offer' => data_get($metadata, ConfigureSubscriptionCheckout::OFFER_SLUG_METADATA_KEY),
'checkout_session_id' => data_get($this->payload, 'data.object.id'),
];
}
diff --git a/app/Jobs/PostHog/TrackTrialConverted.php b/app/Jobs/PostHog/TrackTrialConverted.php
index e6fbd4435..92c75ef0b 100644
--- a/app/Jobs/PostHog/TrackTrialConverted.php
+++ b/app/Jobs/PostHog/TrackTrialConverted.php
@@ -10,6 +10,23 @@ use App\Support\StripeSubscriptionConversion;
class TrackTrialConverted extends AbstractTrackStripeEvent
{
+ /**
+ * False when checkout.completed reports the same payment (a trial without
+ * a card subscribing through Checkout), so revenue is counted once. A
+ * default, not a promoted property, so jobs queued before it still run.
+ */
+ public bool $withRevenue = true;
+
+ /**
+ * @param array<string, mixed> $payload
+ */
+ public function __construct(string $accountId, array $payload, bool $withRevenue = true)
+ {
+ parent::__construct($accountId, $payload);
+
+ $this->withRevenue = $withRevenue;
+ }
+
protected function shouldCapture(Account $account): bool
{
return filled($account->plan);
@@ -25,6 +42,9 @@ class TrackTrialConverted extends AbstractTrackStripeEvent
*/
protected function properties(Account $account): array
{
- return StripeSubscriptionConversion::propertiesFor($account, $this->payload);
+ return match ($this->withRevenue) {
+ true => StripeSubscriptionConversion::propertiesFor($account, $this->payload),
+ false => StripeSubscriptionConversion::baseProperties($account, $this->payload),
+ };
}
}
diff --git a/app/Label/UpdateLabelRequest.php b/app/Label/UpdateLabelRequest.php
index f3d2b2228..a3ef7d4b2 100644
--- a/app/Label/UpdateLabelRequest.php
+++ b/app/Label/UpdateLabelRequest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace App\Label;
use Illuminate\Contracts\Validation\ValidationRule;
diff --git a/app/Listeners/StripeEventListener.php b/app/Listeners/StripeEventListener.php
index fa3f754e9..7218b6451 100644
--- a/app/Listeners/StripeEventListener.php
+++ b/app/Listeners/StripeEventListener.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Listeners;
+use App\Actions\Offer\RedeemOffer;
use App\Enums\PostHog\BillingEvent;
use App\Jobs\PostHog\TrackBilling;
use App\Jobs\PostHog\TrackCheckoutCompleted;
@@ -13,6 +14,8 @@ use App\Jobs\PostHog\TrackTrialStarted;
use App\Models\Account;
use App\Models\Plan;
use App\Services\PostHogService;
+use App\Support\Billing\ConfigureSubscriptionCheckout;
+use App\Support\Billing\StripeValue;
use App\Support\Billing\SubscriptionPlanSync;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
@@ -61,7 +64,7 @@ class StripeEventListener
/**
* A subscription is born either `trialing` (card-required trial, no charge
- * yet) or `active` (first-month coupon or no trial, charged at once): two
+ * yet) or `active` (an offer without a trial, or no offer, charged at once): two
* business events, see App\Support\StripeSubscriptionConversion.
*
* @param array<string, mixed> $payload
@@ -69,11 +72,14 @@ class StripeEventListener
protected function handleSubscriptionCreated(Account $account, array $payload): void
{
$previousPlan = $account->plan?->name;
+ $convertsTrialWithoutCard = $this->convertsTrialWithoutCard($account, $payload);
- $this->syncPlanFromSubscription($account, $payload, clearGenericTrial: true);
+ $this->syncPlanFromSubscription($account, $payload);
$this->recordFirstPayment($account, $payload);
+ $this->redeemOffer($account, $payload);
TrackBilling::dispatchIf(PostHogService::shouldTrack(), (string) $account->id, BillingEvent::Created, $payload, $previousPlan);
+ TrackTrialConverted::dispatchIf(PostHogService::shouldTrack() && $convertsTrialWithoutCard, (string) $account->id, $payload, withRevenue: false);
TrackTrialStarted::dispatchIf(PostHogService::shouldTrack() && $this->currentStatus($payload) === StripeSubscription::STATUS_TRIALING, (string) $account->id, $payload);
TrackCheckoutCompleted::dispatchIf(PostHogService::shouldTrack() && $this->currentStatus($payload) === StripeSubscription::STATUS_ACTIVE, (string) $account->id, $payload);
}
@@ -84,12 +90,14 @@ class StripeEventListener
protected function handleSubscriptionUpdated(Account $account, array $payload): void
{
$previousPlan = $account->plan?->name;
+ $convertsTrialWithoutCard = $this->convertsTrialWithoutCard($account, $payload);
$this->syncPlanFromSubscription($account, $payload);
$this->recordFirstPayment($account, $payload);
+ $this->redeemOffer($account, $payload);
TrackBilling::dispatchIf(PostHogService::shouldTrack(), (string) $account->id, BillingEvent::Updated, $payload, $previousPlan);
- TrackTrialConverted::dispatchIf(PostHogService::shouldTrack() && $this->convertedFromTrial($payload) && $this->isNowActive($payload), (string) $account->id, $payload);
+ TrackTrialConverted::dispatchIf(PostHogService::shouldTrack() && (($this->convertedFromTrial($payload) && $this->isNowActive($payload)) || $convertsTrialWithoutCard), (string) $account->id, $payload);
TrackPlanChanged::dispatchIf(PostHogService::shouldTrack() && $this->priceChanged($payload), (string) $account->id, $payload);
}
@@ -98,13 +106,13 @@ class StripeEventListener
*/
protected function handleSubscriptionDeleted(Account $account, array $payload): void
{
- if ($account->plan_id === null && ! $account->hasPaidSubscription()) {
+ if (blank($account->plan_id) && ! $account->hasPaidSubscription()) {
return;
}
$previousPlan = $account->plan?->name;
- if ($account->plan_id !== null) {
+ if (filled($account->plan_id) && ! $account->onGenericTrial()) {
$account->update(['plan_id' => null]);
}
@@ -147,6 +155,42 @@ class StripeEventListener
return ! Cache::add("stripe_webhook_event:{$eventId}", true, now()->addDay());
}
+ /**
+ * A subscription created during a trial without a card the account took
+ * from an offer (`Account::subscribedDuringTrialWithoutCard()`) turns
+ * active: on created, or when an incomplete one is paid. The conversion is
+ * claimed atomically per subscription, so its created and updated webhooks
+ * handled at the same time count it once.
+ *
+ * @param array<string, mixed> $payload
+ */
+ private function convertsTrialWithoutCard(Account $account, array $payload): bool
+ {
+ if (! $this->startsActive($payload)) {
+ return false;
+ }
+
+ $subscriptionId = data_get($payload, 'data.object.id', $account->id);
+ $subscribedAt = StripeValue::timestamp(data_get($payload, 'data.object.created')) ?? now();
+
+ return $account->subscribedDuringTrialWithoutCard($subscribedAt)
+ && Cache::add("posthog:trial_converted:{$subscriptionId}", true, now()->addDay());
+ }
+
+ /**
+ * The subscription turns active now: created active, or paid after it was
+ * created incomplete. A renewal or a plan change of an active one is not.
+ *
+ * @param array<string, mixed> $payload
+ */
+ private function startsActive(array $payload): bool
+ {
+ return $this->isNowActive($payload) && (
+ data_get($payload, 'type') === StripeEvent::TYPE_CUSTOMER_SUBSCRIPTION_CREATED
+ || data_get($payload, 'data.previous_attributes.status') === StripeSubscription::STATUS_INCOMPLETE
+ );
+ }
+
/**
* The first time a subscription is active the account has been charged:
* kept on the account because Cashier clears `trial_ends_at` on delete.
@@ -165,7 +209,7 @@ class StripeEventListener
/**
* @param array<string, mixed> $payload
*/
- private function syncPlanFromSubscription(Account $account, array $payload, bool $clearGenericTrial = false): void
+ private function syncPlanFromSubscription(Account $account, array $payload): void
{
$status = $this->currentStatus($payload);
@@ -176,18 +220,12 @@ class StripeEventListener
return;
}
- $attributes = ['plan_id' => $plan->id];
-
- if ($clearGenericTrial) {
- $attributes['trial_ends_at'] = null;
- }
-
- $account->update($attributes);
+ $account->update(['plan_id' => $plan->id]);
return;
}
- if (SubscriptionPlanSync::clears($status) && $account->plan_id !== null) {
+ if (SubscriptionPlanSync::clears($status) && filled($account->plan_id) && ! $account->onGenericTrial()) {
$account->update(['plan_id' => null]);
}
}
@@ -218,6 +256,21 @@ class StripeEventListener
return $plan;
}
+ /**
+ * An offer is used once its subscription is active or trialing: an
+ * incomplete one may never be paid, and would use up a place for nothing.
+ *
+ * @param array<string, mixed> $payload
+ */
+ private function redeemOffer(Account $account, array $payload): void
+ {
+ if (! SubscriptionPlanSync::allows($this->currentStatus($payload))) {
+ return;
+ }
+
+ RedeemOffer::execute($account, data_get($payload, ['data', 'object', 'metadata', ConfigureSubscriptionCheckout::OFFER_METADATA_KEY]));
+ }
+
/**
* @param array<string, mixed> $payload
*/
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 0a683e7f3..ba5c6276f 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -7,6 +7,7 @@ namespace App\Models;
use App\Enums\Account\LifecycleStage;
use App\Models\Traits\BillsOwnerAsStripeCustomer;
use App\Models\Traits\HasUsage;
+use Carbon\Carbon;
use Carbon\CarbonInterface;
use Database\Factories\AccountFactory;
use Illuminate\Database\Eloquent\Builder;
@@ -14,6 +15,7 @@ use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
@@ -72,6 +74,34 @@ class Account extends Model
return $this->hasMany(Invite::class);
}
+ public function offers(): BelongsToMany
+ {
+ return $this->belongsToMany(Offer::class)->withPivot('claimed_at', 'redeemed_at');
+ }
+
+ /**
+ * The offers this account used: a checkout with them became active or
+ * trialing, or their trial without a card started.
+ */
+ public function redeemedOffers(): BelongsToMany
+ {
+ return $this->offers()->wherePivotNotNull('redeemed_at');
+ }
+
+ /**
+ * The offer a checkout uses: the most recently claimed one the account may
+ * still use. Without one it pays the full price. Subscribing from billing
+ * leaves trials out, since it charges at once.
+ */
+ public function currentOffer(bool $withTrial = true): ?Offer
+ {
+ return $this->offers()
+ ->availableTo($this)
+ ->unless($withTrial, fn (Builder $query): Builder => $query->withoutTrial())
+ ->orderByPivot('claimed_at', 'desc')
+ ->first();
+ }
+
public function posts(): HasManyThrough
{
return $this->hasManyThrough(Post::class, Workspace::class);
@@ -101,6 +131,29 @@ class Account extends Model
]);
}
+ /**
+ * A subscription created at that moment falls inside a trial without a
+ * card the account redeemed from an offer, whenever its webhook arrives.
+ */
+ public function subscribedDuringTrialWithoutCard(CarbonInterface $subscribedAt): bool
+ {
+ return $this->redeemedOffers()
+ ->where('offers.requires_card', false)
+ ->get()
+ ->contains(fn (Offer $offer): bool => $subscribedAt->lessThan(Carbon::parse($offer->pivot->redeemed_at)->addDays($offer->trial_days)));
+ }
+
+ /**
+ * Never billed and never redeemed an offer: a no-card trial is a redeemed
+ * offer, so it counts as the first subscription and trials do not stack.
+ * Cashier clears `trial_ends_at` on any new subscription, so the
+ * redemption is the record that lasts.
+ */
+ public function isFirstTimeSubscriber(): bool
+ {
+ return ! $this->hasHadBillableSubscription() && $this->redeemedOffers()->doesntExist();
+ }
+
public function hasHadBillableSubscription(): bool
{
return $this->subscriptions->contains(fn (Subscription $subscription): bool => $subscription->becameBillable());
@@ -136,16 +189,37 @@ class Account extends Model
return $subscription->canceled() ? 'canceled' : $subscription->stripe_status;
}
+ /**
+ * The plan holds the price of the current subscription: what a billing
+ * checkout waits for, so Processing never returns to billing on the
+ * plan the account had before.
+ */
+ public function planMatchesSubscription(): bool
+ {
+ $subscription = $this->validSubscription();
+
+ return filled($subscription)
+ && Plan::forStripePrices([$subscription->stripe_price])->whereKey($this->plan_id)->exists();
+ }
+
+ /**
+ * The subscription while it still gives access (what `subscribed()`
+ * checks): active, trialing or in its grace period.
+ */
+ public function validSubscription(): ?Subscription
+ {
+ $subscription = $this->subscription(self::SUBSCRIPTION_NAME);
+
+ return $subscription?->valid() ? $subscription : null;
+ }
+
public function hasAppAccess(): bool
{
if (config('trypost.self_hosted')) {
return true;
}
- $requiresCardForTrial = (bool) config('trypost.billing.require_card_for_trial', true);
-
- return $this->subscribed(self::SUBSCRIPTION_NAME)
- || (! $requiresCardForTrial && $this->isOnTrial());
+ return $this->subscribed(self::SUBSCRIPTION_NAME) || $this->onGenericTrial();
}
public function workspaceLimit(): ?int
@@ -187,49 +261,17 @@ class Account extends Model
public function isOnTrial(): bool
{
- if (! (bool) config('trypost.billing.require_card_for_trial', true) && $this->onGenericTrial()) {
- return true;
- }
-
- return (bool) $this->subscription(self::SUBSCRIPTION_NAME)?->onTrial();
+ return $this->onGenericTrial() || (bool) $this->subscription(self::SUBSCRIPTION_NAME)?->onTrial();
}
public function activeTrialEndsAt(): ?CarbonInterface
{
$subscription = $this->subscription(self::SUBSCRIPTION_NAME);
- if (! $subscription?->onTrial()) {
- if (! (bool) config('trypost.billing.require_card_for_trial', true) && $this->onGenericTrial()) {
- return $this->trial_ends_at;
- }
-
- return null;
- }
-
- return $subscription->trial_ends_at;
- }
-
- /**
- * Returns the displayable card for the billing UI. Falls back to the first
- * attached payment method when the customer has no `invoice_settings.default_payment_method`
- * (Stripe Checkout trials anchor the card to the subscription, not the customer).
- *
- * @return array{brand: string, last4: string, exp_month: int, exp_year: int}|null
- */
- public function displayablePaymentMethod(): ?array
- {
- $paymentMethod = $this->defaultPaymentMethod() ?? $this->paymentMethods()->first();
- $card = $paymentMethod?->card;
-
- if (! $card) {
- return null;
+ if ($subscription?->onTrial()) {
+ return $subscription->trial_ends_at;
}
- return [
- 'brand' => $card->brand,
- 'last4' => $card->last4,
- 'exp_month' => $card->exp_month,
- 'exp_year' => $card->exp_year,
- ];
+ return $this->onGenericTrial() ? $this->trial_ends_at : null;
}
}
diff --git a/app/Models/Offer.php b/app/Models/Offer.php
new file mode 100644
index 000000000..0c7d0639b
--- /dev/null
+++ b/app/Models/Offer.php
@@ -0,0 +1,127 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Models;
+
+use Database\Factories\OfferFactory;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Concerns\HasUuids;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Str;
+
+class Offer extends Model
+{
+ /** @use HasFactory<OfferFactory> */
+ use HasFactory, HasUuids;
+
+ protected $fillable = [
+ 'slug',
+ 'stripe_coupon_id',
+ 'trial_days',
+ 'allow_promotion_codes',
+ 'requires_card',
+ 'starts_at',
+ 'ends_at',
+ 'max_redemptions',
+ 'first_subscription_only',
+ 'show_banner',
+ ];
+
+ protected function casts(): array
+ {
+ return [
+ 'starts_at' => 'datetime',
+ 'ends_at' => 'datetime',
+ 'trial_days' => 'integer',
+ 'allow_promotion_codes' => 'boolean',
+ 'requires_card' => 'boolean',
+ 'max_redemptions' => 'integer',
+ 'first_subscription_only' => 'boolean',
+ 'show_banner' => 'boolean',
+ ];
+ }
+
+ public function accounts(): BelongsToMany
+ {
+ return $this->belongsToMany(Account::class)->withPivot('claimed_at', 'redeemed_at');
+ }
+
+ /**
+ * The accounts that redeemed the offer. Each one uses up a place.
+ */
+ public function redemptions(): BelongsToMany
+ {
+ return $this->accounts()->wherePivotNotNull('redeemed_at');
+ }
+
+ /**
+ * Started, not ended, and with a place left. Only redemptions use up a
+ * place; a claim alone never does.
+ */
+ public function scopeAvailable(Builder $query): Builder
+ {
+ return $query
+ ->whereNowOrPast('offers.starts_at')
+ ->where(fn (Builder $query): Builder => $query->whereNull('offers.ends_at')->orWhereFuture('offers.ends_at'))
+ ->where(fn (Builder $query): Builder => $query->whereNull('offers.max_redemptions')->orHas('redemptions', '<', DB::raw('offers.max_redemptions')));
+ }
+
+ /**
+ * Available offers the account may still use: never one it redeemed, and
+ * a first-subscription offer only while it has never subscribed or
+ * started a trial.
+ */
+ public function scopeAvailableTo(Builder $query, Account $account): Builder
+ {
+ return $query
+ ->available()
+ ->whereDoesntHave('redemptions', fn (Builder $query): Builder => $query->whereKey($account->id))
+ ->when(! $account->isFirstTimeSubscriber(), fn (Builder $query): Builder => $query->where('offers.first_subscription_only', false));
+ }
+
+ /**
+ * A trial that needs no card starts in the app (Cashier's generic trial)
+ * instead of at Stripe Checkout.
+ */
+ public function startsWithoutCard(): bool
+ {
+ return ! $this->requires_card && $this->hasTrial();
+ }
+
+ public function hasTrial(): bool
+ {
+ return $this->trial_days > 0;
+ }
+
+ /**
+ * Offers without a trial: a coupon, the promotion code field, or both.
+ */
+ public function scopeWithoutTrial(Builder $query): Builder
+ {
+ return $query->where(fn (Builder $query): Builder => $query->whereNull('offers.trial_days')->orWhere('offers.trial_days', 0));
+ }
+
+ /**
+ * The available offer with exactly this slug, for an account when one is
+ * given. MySQL compares strings without case, so the match is confirmed
+ * here, where both engines agree.
+ */
+ public static function findAvailable(string $slug, ?Account $account = null): ?self
+ {
+ $offers = filled($account) ? self::availableTo($account) : self::available();
+
+ return $offers->where('slug', $slug)->get()->firstWhere('slug', $slug);
+ }
+
+ /**
+ * The key of the offer's copy in lang/<locale>/offers.php.
+ */
+ public function langKey(): string
+ {
+ return Str::replace('-', '_', $this->slug);
+ }
+}
diff --git a/app/Policies/AccountPolicy.php b/app/Policies/AccountPolicy.php
index 94ba8edfc..561f252fc 100644
--- a/app/Policies/AccountPolicy.php
+++ b/app/Policies/AccountPolicy.php
@@ -40,7 +40,7 @@ class AccountPolicy
return Response::deny(__('billing.flash.cannot_manage'));
}
- if (! $account->subscribed(Account::SUBSCRIPTION_NAME)) {
+ if (! $account->subscribed(Account::SUBSCRIPTION_NAME) && ! $account->onGenericTrial()) {
return Response::deny(__('billing.flash.subscription_required'));
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 64d6b0d56..c459d837c 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -19,6 +19,7 @@ use App\Models\Invite;
use App\Models\Media;
use App\Models\MediaSourceConnection;
use App\Models\NotificationPreference;
+use App\Models\Offer;
use App\Models\Plan;
use App\Models\Post;
use App\Models\PostNote;
@@ -117,6 +118,7 @@ class AppServiceProvider extends ServiceProvider
'media' => Media::class,
'mediaSourceConnection' => MediaSourceConnection::class,
'notificationPreference' => NotificationPreference::class,
+ 'offer' => Offer::class,
'plan' => Plan::class,
'post' => Post::class,
'repurpose' => Repurpose::class,
diff --git a/app/PublicationDetailResource.php b/app/PublicationDetailResource.php
index 4b8e3229b..9aa45516b 100644
--- a/app/PublicationDetailResource.php
+++ b/app/PublicationDetailResource.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace App;
use Illuminate\Http\Request;
diff --git a/app/Support/Billing/ConfigureSubscriptionCheckout.php b/app/Support/Billing/ConfigureSubscriptionCheckout.php
index 4bf0b7336..58ba89463 100644
--- a/app/Support/Billing/ConfigureSubscriptionCheckout.php
+++ b/app/Support/Billing/ConfigureSubscriptionCheckout.php
@@ -4,20 +4,18 @@ declare(strict_types=1);
namespace App\Support\Billing;
-use App\Models\Account;
-use App\Models\Plan;
+use App\Models\Offer;
use Laravel\Cashier\SubscriptionBuilder;
-use RuntimeException;
final class ConfigureSubscriptionCheckout
{
- public const FIRST_MONTH_COUPON_METADATA_KEY = 'trypost_first_month_coupon_id';
-
public const PLAN_METADATA_KEY = 'trypost_plan_slug';
public const INTERVAL_METADATA_KEY = 'trypost_interval';
- public const FIRST_MONTH_OFFER_METADATA_KEY = 'trypost_first_month_offer';
+ public const OFFER_METADATA_KEY = 'trypost_offer_id';
+
+ public const OFFER_SLUG_METADATA_KEY = 'trypost_offer_slug';
/**
* Stripe Checkout rejects subscription trials shorter than 48 hours.
@@ -25,68 +23,27 @@ final class ConfigureSubscriptionCheckout
public const MIN_CHECKOUT_TRIAL_DAYS = 2;
/**
- * @throws RuntimeException when a coupon would apply with allow_promotion_codes enabled
+ * The offer decides the discount, the trial and the promotion code field;
+ * without one the account pays the full price and may enter a promotion
+ * code. A coupon wins over the field: Stripe rejects both on one session,
+ * never a trial with it.
+ * The caller resolves the offer once with the account's current offer, so the coupon, the
+ * checkout metadata and the tracked events agree.
*/
- public static function apply(SubscriptionBuilder $subscription, Account $account, ?Plan $plan = null): SubscriptionBuilder
+ public static function apply(SubscriptionBuilder $subscription, ?Offer $offer = null): SubscriptionBuilder
{
- $couponId = self::firstMonthCouponId($account, $plan);
-
- if ($couponId !== null) {
- if ((bool) config('cashier.allow_promotion_codes', false)) {
- throw new RuntimeException(
- 'Cannot apply a first-month coupon while CASHIER_ALLOW_PROMOTION_CODES is enabled: '
- .'Stripe Checkout rejects discounts and allow_promotion_codes on the same session.'
- );
- }
-
- return $subscription->withCoupon($couponId);
+ if ($offer?->hasTrial()) {
+ $subscription->trialDays(max(self::MIN_CHECKOUT_TRIAL_DAYS, $offer->trial_days));
}
- if (
- (bool) config('trypost.billing.require_card_for_trial', true)
- && self::isFirstTimeSubscriber($account)
- ) {
- $trialDays = (int) config('cashier.trial_days');
-
- if ($trialDays > 0) {
- $subscription->trialDays(max(self::MIN_CHECKOUT_TRIAL_DAYS, $trialDays));
- }
+ if (filled($offer?->stripe_coupon_id)) {
+ return $subscription->withCoupon($offer->stripe_coupon_id);
}
- if ((bool) config('cashier.allow_promotion_codes', false)) {
+ if (blank($offer) || $offer->allow_promotion_codes) {
$subscription->allowPromotionCodes();
}
return $subscription;
}
-
- public static function offersFirstMonthCoupon(Account $account, Plan $plan): bool
- {
- return self::firstMonthCouponId($account, $plan) !== null;
- }
-
- private static function firstMonthCouponId(Account $account, ?Plan $plan): ?string
- {
- if ($plan === null || ! (bool) config('trypost.billing.require_card_for_trial', true)) {
- return null;
- }
-
- if (! self::isFirstTimeSubscriber($account)) {
- return null;
- }
-
- $couponId = config("cashier.first_month_coupon_ids.{$plan->slug->value}");
-
- if (! is_string($couponId) || $couponId === '') {
- return null;
- }
-
- return $couponId;
- }
-
- /** Incomplete / incomplete_expired never became billable, so retries still count as first-time. */
- private static function isFirstTimeSubscriber(Account $account): bool
- {
- return ! $account->hasHadBillableSubscription();
- }
}
diff --git a/app/Support/StripeSubscriptionConversion.php b/app/Support/StripeSubscriptionConversion.php
index 76c4f9c97..025eddd69 100644
--- a/app/Support/StripeSubscriptionConversion.php
+++ b/app/Support/StripeSubscriptionConversion.php
@@ -8,7 +8,6 @@ use App\Enums\Billing\Interval;
use App\Models\Account;
use App\Support\Billing\ConfigureSubscriptionCheckout;
use App\Support\Billing\StripeValue;
-use Illuminate\Support\Carbon;
final class StripeSubscriptionConversion
{
@@ -54,56 +53,26 @@ final class StripeSubscriptionConversion
}
/**
+ * propertiesFor() plus the slug of the offer the checkout applied.
+ *
* @param array<string, mixed> $payload
* @return array<string, mixed>
*/
public static function checkoutPropertiesFor(Account $account, array $payload): array
{
- $properties = self::propertiesFor($account, $payload);
- $firstMonthCouponId = self::firstMonthCouponId($payload);
-
- $properties['is_first_month_offer'] = $firstMonthCouponId !== null;
-
- if ($firstMonthCouponId === null) {
- return $properties;
- }
-
- $properties['first_month_coupon_id'] = $firstMonthCouponId;
- $firstMonthOfferEndsAt = self::firstMonthOfferEndsAt($payload);
-
- if ($firstMonthOfferEndsAt !== null) {
- $properties['first_month_offer_ends_at'] = $firstMonthOfferEndsAt;
- }
-
- return $properties;
- }
-
- /**
- * @param array<string, mixed> $payload
- */
- public static function firstMonthOfferEndsAt(array $payload): ?string
- {
- if (self::firstMonthCouponId($payload) === null) {
- return null;
- }
-
- $currentPeriodEnd = data_get($payload, 'data.object.items.data.0.current_period_end');
-
- return is_int($currentPeriodEnd)
- ? Carbon::createFromTimestamp($currentPeriodEnd)->toIso8601String()
- : null;
+ return [
+ ...self::propertiesFor($account, $payload),
+ 'offer' => self::offerSlug($payload),
+ ];
}
/**
* @param array<string, mixed> $payload
*/
- private static function firstMonthCouponId(array $payload): ?string
+ public static function offerSlug(array $payload): ?string
{
- $couponId = data_get(
- $payload,
- 'data.object.metadata.'.ConfigureSubscriptionCheckout::FIRST_MONTH_COUPON_METADATA_KEY,
- );
+ $slug = data_get($payload, ['data', 'object', 'metadata', ConfigureSubscriptionCheckout::OFFER_SLUG_METADATA_KEY]);
- return is_string($couponId) && $couponId !== '' ? $couponId : null;
+ return is_string($slug) && filled($slug) ? $slug : null;
}
}
diff --git a/bootstrap/app.php b/bootstrap/app.php
index df4c31d6b..e30eb12c1 100644
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -3,6 +3,7 @@
declare(strict_types=1);
use App\Http\Middleware\Api\LoadWorkspaceFromToken;
+use App\Http\Middleware\App\CaptureOffer;
use App\Http\Middleware\App\EnsureRegistrationEnabled;
use App\Http\Middleware\App\HandleInertiaRequests;
use App\Http\Middleware\App\SetLocale;
@@ -28,6 +29,7 @@ return Application::configure(basePath: dirname(__DIR__))
$middleware->web(append: [
SetLocale::class,
+ CaptureOffer::class,
HandleInertiaRequests::class,
AddLinkHeadersForPreloadedAssets::class,
]);
diff --git a/bootstrap/providers.php b/bootstrap/providers.php
index 55339d1c6..a704eb7cf 100644
--- a/bootstrap/providers.php
+++ b/bootstrap/providers.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use App\Providers\AppServiceProvider;
use App\Providers\HorizonServiceProvider;
use App\Providers\PassportServiceProvider;
diff --git a/config/cashier.php b/config/cashier.php
index 48020b121..174158d46 100644
--- a/config/cashier.php
+++ b/config/cashier.php
@@ -130,56 +130,4 @@ return [
'logger' => env('CASHIER_LOGGER'),
- /*
- |--------------------------------------------------------------------------
- | Trial Period
- |--------------------------------------------------------------------------
- |
- | Days of trial. With REQUIRE_CARD_FOR_TRIAL=true and no first-month coupon
- | applied, first-time checkouts get Stripe trialDays (status trialing).
- | Re-subscribers (any prior real subscription) skip trial. With
- | REQUIRE_CARD_FOR_TRIAL=false, it is the generic signup trial length on
- | accounts.trial_ends_at. Set to 0 to disable trials. Stripe Checkout
- | rejects trials shorter than 48 hours — values of 1 are clamped to 2.
- |
- */
-
- 'trial_days' => env('CASHIER_TRIAL_DAYS', 8),
-
- /*
- |--------------------------------------------------------------------------
- | Paid First Month Coupons
- |--------------------------------------------------------------------------
- |
- | Per-plan Stripe Coupon IDs (amount_off, duration=once) so the first
- | monthly invoice is $1: Socials $19 − $18, Workspaces $99 − $88. When
- | the matching coupon is set and the account qualifies (card required,
- | first-time, monthly price), checkout applies withCoupon and skips
- | trialDays. Empty for that plan = trial_days instead. Never reuse one
- | coupon on the other plan — the amounts are different. Yearly prices
- | never get a coupon. Cannot be combined with allow_promotion_codes on
- | the same checkout.
- |
- */
-
- 'first_month_coupon_ids' => [
- 'socials' => env('STRIPE_SOCIALS_FIRST_MONTH_COUPON_ID'),
- 'workspaces' => env('STRIPE_WORKSPACES_FIRST_MONTH_COUPON_ID'),
- ],
-
- /*
- |--------------------------------------------------------------------------
- | Allow Promotion Codes
- |--------------------------------------------------------------------------
- |
- | When true and no first-month coupon is applied on the session, Stripe
- | Checkout shows the redeemable promotion-code field. Defaults to false
- | (SaaS recipe A). Stripe rejects a session that sets both discounts
- | (coupon) and allow_promotion_codes — ConfigureSubscriptionCheckout
- | throws if both would apply on the same checkout.
- |
- */
-
- 'allow_promotion_codes' => (bool) env('CASHIER_ALLOW_PROMOTION_CODES', false),
-
];
diff --git a/config/cors.php b/config/cors.php
index 05ef3a8d6..5cda1fb86 100644
--- a/config/cors.php
+++ b/config/cors.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/config/passport.php b/config/passport.php
index aed435890..ebfe824ef 100644
--- a/config/passport.php
+++ b/config/passport.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/config/trypost.php b/config/trypost.php
index 69c3fb12d..8ded5b003 100644
--- a/config/trypost.php
+++ b/config/trypost.php
@@ -121,22 +121,6 @@ return [
'allow_private_network' => (bool) env('TRYPOST_ALLOW_PRIVATE_NETWORK', false),
],
- /*
- |--------------------------------------------------------------------------
- | Billing
- |--------------------------------------------------------------------------
- |
- | Control whether signup requires a card before app access:
- | - true: no generic trial at signup; access only after Stripe Checkout
- | (trialDays and/or first-month coupon come from cashier.* env knobs)
- | - false: grant generic trial at signup without a card
- |
- */
-
- 'billing' => [
- 'require_card_for_trial' => (bool) env('REQUIRE_CARD_FOR_TRIAL', true),
- ],
-
/*
|--------------------------------------------------------------------------
| Media Size Limits
diff --git a/database/factories/OfferFactory.php b/database/factories/OfferFactory.php
new file mode 100644
index 000000000..582445cfe
--- /dev/null
+++ b/database/factories/OfferFactory.php
@@ -0,0 +1,130 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Database\Factories;
+
+use App\Models\Offer;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+/**
+ * @extends Factory<Offer>
+ */
+class OfferFactory extends Factory
+{
+ /**
+ * Define the model's default state.
+ *
+ * @return array<string, mixed>
+ */
+ public function definition(): array
+ {
+ return [
+ 'slug' => fake()->unique()->slug(3),
+ 'stripe_coupon_id' => fake()->unique()->bothify('coupon_????????'),
+ 'starts_at' => now()->subDay(),
+ 'ends_at' => null,
+ 'max_redemptions' => null,
+ 'trial_days' => null,
+ 'allow_promotion_codes' => false,
+ 'requires_card' => true,
+ 'first_subscription_only' => false,
+ 'show_banner' => false,
+ ];
+ }
+
+ public function upcoming(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'starts_at' => now()->addDay(),
+ ]);
+ }
+
+ public function expired(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'starts_at' => now()->subDays(10),
+ 'ends_at' => now()->subDay(),
+ ]);
+ }
+
+ public function limitedTo(int $places): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'max_redemptions' => $places,
+ ]);
+ }
+
+ public function trial(int $days): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'stripe_coupon_id' => null,
+ 'trial_days' => $days,
+ ]);
+ }
+
+ public function withoutCard(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'requires_card' => false,
+ ]);
+ }
+
+ public function allowingPromotionCodes(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'allow_promotion_codes' => true,
+ ]);
+ }
+
+ /**
+ * The Black Friday 2026 offer: 50% off the first 3 months, with its banner.
+ */
+ public function blackFriday(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'slug' => 'bf26',
+ 'stripe_coupon_id' => 'BF26_50_3M',
+ 'show_banner' => true,
+ ]);
+ }
+
+ /**
+ * The $1 first month, for accounts that never subscribed.
+ */
+ public function firstMonth(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'slug' => 'fm1',
+ 'stripe_coupon_id' => 'SOCIALS_18USD',
+ 'first_subscription_only' => true,
+ ]);
+ }
+
+ /**
+ * The 7-day free trial. Stripe Checkout shows 8 trial days as 7.
+ */
+ public function freeTrial(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'slug' => 'ft7d',
+ 'stripe_coupon_id' => null,
+ 'trial_days' => 8,
+ 'first_subscription_only' => true,
+ ]);
+ }
+
+ public function withBanner(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'show_banner' => true,
+ ]);
+ }
+
+ public function firstSubscriptionOnly(): static
+ {
+ return $this->state(fn (array $attributes): array => [
+ 'first_subscription_only' => true,
+ ]);
+ }
+}
diff --git a/database/migrations/2026_05_03_210117_create_oauth_auth_codes_table.php b/database/migrations/2026_05_03_210117_create_oauth_auth_codes_table.php
index 8eefa44db..244fcbc80 100644
--- a/database/migrations/2026_05_03_210117_create_oauth_auth_codes_table.php
+++ b/database/migrations/2026_05_03_210117_create_oauth_auth_codes_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_05_03_210118_create_oauth_access_tokens_table.php b/database/migrations/2026_05_03_210118_create_oauth_access_tokens_table.php
index 89b86562b..677e635fe 100644
--- a/database/migrations/2026_05_03_210118_create_oauth_access_tokens_table.php
+++ b/database/migrations/2026_05_03_210118_create_oauth_access_tokens_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_05_03_210119_create_oauth_refresh_tokens_table.php b/database/migrations/2026_05_03_210119_create_oauth_refresh_tokens_table.php
index afb3c55c9..5c926f4db 100644
--- a/database/migrations/2026_05_03_210119_create_oauth_refresh_tokens_table.php
+++ b/database/migrations/2026_05_03_210119_create_oauth_refresh_tokens_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_05_03_210120_create_oauth_clients_table.php b/database/migrations/2026_05_03_210120_create_oauth_clients_table.php
index 9794dc860..393ce8a03 100644
--- a/database/migrations/2026_05_03_210120_create_oauth_clients_table.php
+++ b/database/migrations/2026_05_03_210120_create_oauth_clients_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_05_03_210121_create_oauth_device_codes_table.php b/database/migrations/2026_05_03_210121_create_oauth_device_codes_table.php
index 236c4694e..2e0df198d 100644
--- a/database/migrations/2026_05_03_210121_create_oauth_device_codes_table.php
+++ b/database/migrations/2026_05_03_210121_create_oauth_device_codes_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_06_22_162523_drop_features_table.php b/database/migrations/2026_06_22_162523_drop_features_table.php
index f93f11ba9..7f568bd65 100644
--- a/database/migrations/2026_06_22_162523_drop_features_table.php
+++ b/database/migrations/2026_06_22_162523_drop_features_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_06_25_232554_add_goals_to_users_table.php b/database/migrations/2026_06_25_232554_add_goals_to_users_table.php
index 677aa592d..20ae27278 100644
--- a/database/migrations/2026_06_25_232554_add_goals_to_users_table.php
+++ b/database/migrations/2026_06_25_232554_add_goals_to_users_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_07_18_184130_add_referral_source_to_users_table.php b/database/migrations/2026_07_18_184130_add_referral_source_to_users_table.php
index bc97aab66..78fdd0ac6 100644
--- a/database/migrations/2026_07_18_184130_add_referral_source_to_users_table.php
+++ b/database/migrations/2026_07_18_184130_add_referral_source_to_users_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_09_30_154338_create_idea_stages_table.php b/database/migrations/2026_09_30_154338_create_idea_stages_table.php
index 2f9ce6c2d..e70edf27c 100644
--- a/database/migrations/2026_09_30_154338_create_idea_stages_table.php
+++ b/database/migrations/2026_09_30_154338_create_idea_stages_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use App\Enums\User\Locale;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
diff --git a/database/migrations/2026_09_30_154339_create_ideas_table.php b/database/migrations/2026_09_30_154339_create_ideas_table.php
index d6a25915b..8840b09c4 100644
--- a/database/migrations/2026_09_30_154339_create_ideas_table.php
+++ b/database/migrations/2026_09_30_154339_create_ideas_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_09_30_154340_create_idea_workspace_label_table.php b/database/migrations/2026_09_30_154340_create_idea_workspace_label_table.php
index 96ffa4210..f33953a06 100644
--- a/database/migrations/2026_09_30_154340_create_idea_workspace_label_table.php
+++ b/database/migrations/2026_09_30_154340_create_idea_workspace_label_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_09_30_182543_create_post_templates_table.php b/database/migrations/2026_09_30_182543_create_post_templates_table.php
index d19b9440d..cf4c86901 100644
--- a/database/migrations/2026_09_30_182543_create_post_templates_table.php
+++ b/database/migrations/2026_09_30_182543_create_post_templates_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_09_30_185403_add_position_to_social_accounts_table.php b/database/migrations/2026_09_30_185403_add_position_to_social_accounts_table.php
index 875a688b1..b5681b6fa 100644
--- a/database/migrations/2026_09_30_185403_add_position_to_social_accounts_table.php
+++ b/database/migrations/2026_09_30_185403_add_position_to_social_accounts_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
diff --git a/database/migrations/2026_09_30_191954_create_rss_feed_collections_table.php b/database/migrations/2026_09_30_191954_create_rss_feed_collections_table.php
index 0043beec4..fa440d537 100644
--- a/database/migrations/2026_09_30_191954_create_rss_feed_collections_table.php
+++ b/database/migrations/2026_09_30_191954_create_rss_feed_collections_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_09_30_191955_create_rss_feeds_table.php b/database/migrations/2026_09_30_191955_create_rss_feeds_table.php
index faaa851ef..167e25fc6 100644
--- a/database/migrations/2026_09_30_191955_create_rss_feeds_table.php
+++ b/database/migrations/2026_09_30_191955_create_rss_feeds_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_09_30_191957_create_rss_feed_items_table.php b/database/migrations/2026_09_30_191957_create_rss_feed_items_table.php
index 478e3f754..54260410e 100644
--- a/database/migrations/2026_09_30_191957_create_rss_feed_items_table.php
+++ b/database/migrations/2026_09_30_191957_create_rss_feed_items_table.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
diff --git a/database/migrations/2026_10_26_232641_create_offers_table.php b/database/migrations/2026_10_26_232641_create_offers_table.php
new file mode 100644
index 000000000..03401bd6a
--- /dev/null
+++ b/database/migrations/2026_10_26_232641_create_offers_table.php
@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ public function up(): void
+ {
+ Schema::create('offers', function (Blueprint $table): void {
+ $table->uuid('id')->primary();
+ $table->string('slug')->unique();
+ $table->string('stripe_coupon_id')->nullable();
+ $table->unsignedSmallInteger('trial_days')->nullable();
+ $table->boolean('allow_promotion_codes')->default(false);
+ $table->boolean('requires_card')->default(true);
+ $table->timestamp('starts_at');
+ $table->timestamp('ends_at')->nullable();
+ $table->unsignedInteger('max_redemptions')->nullable();
+ $table->boolean('first_subscription_only')->default(false);
+ $table->boolean('show_banner')->default(false);
+ $table->timestamps();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('offers');
+ }
+};
diff --git a/database/migrations/2026_10_26_232642_create_account_offer_table.php b/database/migrations/2026_10_26_232642_create_account_offer_table.php
new file mode 100644
index 000000000..02a655cb0
--- /dev/null
+++ b/database/migrations/2026_10_26_232642_create_account_offer_table.php
@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ public function up(): void
+ {
+ Schema::create('account_offer', function (Blueprint $table): void {
+ $table->foreignUuid('account_id')->constrained()->cascadeOnDelete();
+ $table->foreignUuid('offer_id')->constrained()->cascadeOnDelete();
+ $table->timestamp('claimed_at');
+ $table->timestamp('redeemed_at')->nullable();
+
+ $table->primary(['account_id', 'offer_id']);
+ $table->index(['offer_id', 'redeemed_at']);
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists('account_offer');
+ }
+};
diff --git a/database/seeders/OfferSeeder.php b/database/seeders/OfferSeeder.php
new file mode 100644
index 000000000..4c3d39a6c
--- /dev/null
+++ b/database/seeders/OfferSeeder.php
@@ -0,0 +1,39 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Database\Seeders;
+
+use App\Models\Offer;
+use Illuminate\Database\Seeder;
+
+class OfferSeeder extends Seeder
+{
+ /**
+ * Local offers to try the Welcome checkout with, run by hand with
+ * `php artisan db:seed --class=OfferSeeder`. Their coupons live in Stripe
+ * test mode; other environments add their offers by hand.
+ */
+ public function run(): void
+ {
+ Offer::updateOrCreate(
+ ['slug' => 'ft7d'],
+ ['starts_at' => now(), 'trial_days' => 8, 'first_subscription_only' => true],
+ );
+
+ Offer::updateOrCreate(
+ ['slug' => 'ft7dnc'],
+ ['starts_at' => now(), 'trial_days' => 7, 'requires_card' => false, 'first_subscription_only' => true],
+ );
+
+ Offer::updateOrCreate(
+ ['slug' => 'bf26'],
+ ['starts_at' => now(), 'stripe_coupon_id' => 'TRYPOST_TEST_BF_50_3M', 'show_banner' => true],
+ );
+
+ Offer::updateOrCreate(
+ ['slug' => 'fm1'],
+ ['starts_at' => now(), 'stripe_coupon_id' => 'SOCIALS_18USD', 'first_subscription_only' => true],
+ );
+ }
+}
diff --git a/lang/ar/accounts.php b/lang/ar/accounts.php
index 3bf8963a2..9773a01ea 100644
--- a/lang/ar/accounts.php
+++ b/lang/ar/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'ربط Bluesky',
diff --git a/lang/ar/analytics.php b/lang/ar/analytics.php
index 2fab54a97..c33338c30 100644
--- a/lang/ar/analytics.php
+++ b/lang/ar/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/ar/auth.php b/lang/ar/auth.php
index aa4596663..14e5434ab 100644
--- a/lang/ar/auth.php
+++ b/lang/ar/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ar/billing.php b/lang/ar/billing.php
index 431f07977..b44bc7bba 100644
--- a/lang/ar/billing.php
+++ b/lang/ar/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'الفوترة',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'فوترة شهرية',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'سنوي',
'save_two_months' => 'شهران مجانًا',
'per_month' => '/شهر',
+ 'per_year' => '/سنة',
'workspaces_one' => 'مساحة عمل واحدة',
'workspaces_unlimited' => 'مساحات عمل غير محدودة',
'workspaces_tooltip' => 'مساحة العمل هي علامة تجارية أو عميل واحد، منفصلة عن البقية: بحساباتها الاجتماعية وتوقيعاتها وتصنيفاتها وتحليلاتها وصلاحيات أعضائها واتصال MCP الخاص بها.',
@@ -33,7 +35,6 @@ return [
'select' => 'اختر :plan',
'upgrade' => 'الترقية إلى :plan',
'downgrade' => 'الرجوع إلى :plan',
- 'start_first_month' => 'فعّل مقابل :price',
'billed_yearly_total' => 'فوترة سنوية · :price (شهران مجانًا)',
'socials_tagline' => 'مناسب لمنشئي المحتوى والعلامات الصغيرة.',
'workspaces_tagline' => 'مناسب للوكالات والأعمال الكبيرة.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'نشطة',
+ 'trial' => 'تجربة مجانية',
+ 'cancelling' => 'ملغاة',
+ 'past_due' => 'متأخرة',
+ ],
'change' => 'تغيير الخطة',
- 'price_monthly' => ':price/شهر',
- 'price_yearly' => ':price/سنة',
+ 'subscribe' => 'اشترك الآن',
'trial_until' => 'فترة تجريبية حتى :date',
- 'renews' => 'يتجدد تلقائيًا',
'cancelled' => 'تم الإلغاء، ينتهي في :date',
- 'workspaces_usage' => 'مساحات العمل: :count من :limit',
+ 'discount_until' => 'خصم :discount حتى :date',
+ 'discount_forever' => 'خصم :discount على كل دفعة',
+ 'discount_once' => 'خصم :discount على دفعتك القادمة',
],
'subscription' => [
- 'title' => 'طريقة الدفع',
+ 'title' => 'طرق الدفع',
+ 'default' => 'افتراضية',
'description' => 'حدّث بطاقتك أو بيانات الفوترة على Stripe.',
'no_payment_method' => 'لا توجد طريقة دفع مسجّلة بعد.',
'expires_on' => 'تنتهي في :month/:year',
'manage_stripe' => 'الإدارة عبر Stripe',
],
+ 'tabs' => [
+ 'plan' => 'الخطة',
+ 'invoices' => 'الفواتير',
+ ],
+
'invoices' => [
- 'title' => 'الفواتير',
- 'description' => 'نزّل فواتيرك السابقة.',
+ 'columns' => [
+ 'date' => 'التاريخ',
+ 'amount' => 'المبلغ',
+ 'status' => 'الحالة',
+ ],
+ 'empty_title' => 'لا توجد فواتير بعد',
+ 'empty_description' => 'ستظهر فواتيرك هنا بعد أول دفعة.',
'paid' => 'مدفوعة',
'download' => 'تنزيل الفاتورة',
],
diff --git a/lang/ar/calendar.php b/lang/ar/calendar.php
index f58cd20d0..fa5d11f81 100644
--- a/lang/ar/calendar.php
+++ b/lang/ar/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'التقويم',
'today' => 'اليوم',
diff --git a/lang/ar/create.php b/lang/ar/create.php
index 9914edec3..556394482 100644
--- a/lang/ar/create.php
+++ b/lang/ar/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'إنشاء',
'tabs' => [
diff --git a/lang/ar/integrations.php b/lang/ar/integrations.php
index 407d0f6f8..687af10c0 100644
--- a/lang/ar/integrations.php
+++ b/lang/ar/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'تم استلام التصميم',
diff --git a/lang/ar/labels.php b/lang/ar/labels.php
index 84afdaf40..e81f4b8e4 100644
--- a/lang/ar/labels.php
+++ b/lang/ar/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'التسميات',
'description' => 'نظّم منشوراتك باستخدام التسميات.',
diff --git a/lang/ar/notes.php b/lang/ar/notes.php
index 4ede94313..61f205a52 100644
--- a/lang/ar/notes.php
+++ b/lang/ar/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'اكتب ملاحظة...',
'title' => 'ملاحظات',
diff --git a/lang/ar/offers.php b/lang/ar/offers.php
new file mode 100644
index 000000000..1902f18ed
--- /dev/null
+++ b/lang/ar/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'الجمعة السوداء',
+ 'headline' => 'خصم 50% على أول 3 أشهر',
+ 'price' => '$9.50',
+ 'unit' => '/شهر',
+ 'period' => 'لأول 3 أشهر',
+ 'checkout_button' => 'فعّل حسابي',
+ ],
+ 'fm1' => [
+ 'name' => 'الشهر الأول',
+ 'headline' => 'شهرك الأول مقابل $1',
+ 'price' => '$1',
+ 'period' => 'للشهر الأول',
+ 'checkout_button' => 'فعّل حسابي',
+ ],
+ 'ft7d' => [
+ 'price' => 'مجانًا',
+ 'period' => 'لمدة 7 أيام',
+ 'checkout_button' => 'ابدأ التجربة المجانية',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'مجانًا',
+ 'period' => 'لمدة 7 أيام',
+ 'checkout_button' => 'ابدأ التجربة المجانية',
+ 'terms' => 'لا حاجة إلى بطاقة ائتمان',
+ ],
+];
diff --git a/lang/ar/pagination.php b/lang/ar/pagination.php
index 2eee353ef..67534907d 100644
--- a/lang/ar/pagination.php
+++ b/lang/ar/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ar/passwords.php b/lang/ar/passwords.php
index 8a6a5e329..3f03a941a 100644
--- a/lang/ar/passwords.php
+++ b/lang/ar/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ar/posts.php b/lang/ar/posts.php
index c17e2c9ed..f2f23f00b 100644
--- a/lang/ar/posts.php
+++ b/lang/ar/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'قائمة',
'view_switcher' => 'عرض الجدول',
diff --git a/lang/ar/settings.php b/lang/ar/settings.php
index e7ec52bbc..23c848fd4 100644
--- a/lang/ar/settings.php
+++ b/lang/ar/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'الإعدادات',
'description' => 'إدارة ملفك الشخصي وإعدادات حسابك',
diff --git a/lang/ar/signatures.php b/lang/ar/signatures.php
index 2c9b351af..4e6248e7a 100644
--- a/lang/ar/signatures.php
+++ b/lang/ar/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'التوقيعات',
'description' => 'نصوص جاهزة لإضافتها إلى منشوراتك.',
diff --git a/lang/ar/template_library.php b/lang/ar/template_library.php
index 8ff245335..d1a68188f 100644
--- a/lang/ar/template_library.php
+++ b/lang/ar/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'الحل في خمس دقائق',
diff --git a/lang/ar/validation.php b/lang/ar/validation.php
index 7cde7426c..138a90416 100644
--- a/lang/ar/validation.php
+++ b/lang/ar/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ar/welcome.php b/lang/ar/welcome.php
index a9178e0a5..018e26e18 100644
--- a/lang/ar/welcome.php
+++ b/lang/ar/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'فعّل حسابك',
'plan_description' => 'اربط حساباتك وجدول أول منشور لك اليوم.',
- 'plan_first_month' => 'للشهر الأول',
- 'plan_terms' => 'ثم :price/شهر. ألغِ في أي وقت.',
- 'plan_per_month' => 'شهريًا',
- 'plan_cancel_anytime' => 'ألغِ في أي وقت.',
+ 'plan_terms' => 'ثم :price/شهر. ألغِ في أي وقت',
+ 'plan_checkout_button' => 'فعّل حسابي',
+ 'plan_cancel_anytime' => 'ألغِ في أي وقت',
'mcp' => [
'title' => 'أدِر حساباتك الاجتماعية من الدردشة',
'description' => 'أنشئ منشوراتك في TryPost وجدولها وحللها باستخدام ذكائك الاصطناعي المفضل.',
diff --git a/lang/de/billing.php b/lang/de/billing.php
index 36a9e3b8a..b76ed6d25 100644
--- a/lang/de/billing.php
+++ b/lang/de/billing.php
@@ -14,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Monatlich abgerechnet',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -26,6 +25,7 @@ return [
'yearly' => 'Jährlich',
'save_two_months' => '2 Monate gratis',
'per_month' => '/Monat',
+ 'per_year' => '/Jahr',
'workspaces_one' => 'Ein Workspace',
'workspaces_unlimited' => 'Unbegrenzte Workspaces',
'workspaces_tooltip' => 'Ein Workspace ist eine Marke oder ein Kunde, getrennt von allen anderen: mit eigenen Social-Media-Konten, Signaturen, Labels, Analytics, Mitgliederrechten und MCP-Verbindung.',
@@ -35,7 +35,6 @@ return [
'select' => ':plan wählen',
'upgrade' => 'Auf :plan upgraden',
'downgrade' => 'Auf :plan downgraden',
- 'start_first_month' => 'Für :price aktivieren',
'billed_yearly_total' => 'Jährlich abgerechnet · :price (2 Monate gratis)',
'socials_tagline' => 'Ideal für Creator und kleine Marken.',
'workspaces_tagline' => 'Ideal für Agenturen und größere Unternehmen.',
@@ -63,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Aktiv',
+ 'trial' => 'Kostenloser Test',
+ 'cancelling' => 'Gekündigt',
+ 'past_due' => 'Überfällig',
+ ],
'change' => 'Tarif ändern',
- 'price_monthly' => ':price/Monat',
- 'price_yearly' => ':price/Jahr',
+ 'subscribe' => 'Jetzt abonnieren',
'trial_until' => 'Testphase bis :date',
- 'renews' => 'Verlängert sich automatisch',
'cancelled' => 'Gekündigt, endet am :date',
- 'workspaces_usage' => 'Workspaces: :count von :limit',
+ 'discount_until' => ':discount Rabatt bis :date',
+ 'discount_forever' => ':discount Rabatt auf jede Zahlung',
+ 'discount_once' => ':discount Rabatt auf deine nächste Zahlung',
],
'subscription' => [
- 'title' => 'Zahlungsmethode',
+ 'title' => 'Zahlungsmethoden',
+ 'default' => 'Standard',
'description' => 'Aktualisiere deine Karte oder Rechnungsdaten bei Stripe.',
'no_payment_method' => 'Noch keine Zahlungsmethode hinterlegt.',
'expires_on' => 'Läuft ab :month/:year',
'manage_stripe' => 'Bei Stripe verwalten',
],
+ 'tabs' => [
+ 'plan' => 'Tarif',
+ 'invoices' => 'Rechnungen',
+ ],
+
'invoices' => [
- 'title' => 'Rechnungen',
- 'description' => 'Lade deine bisherigen Rechnungen herunter.',
+ 'columns' => [
+ 'date' => 'Datum',
+ 'amount' => 'Betrag',
+ 'status' => 'Status',
+ ],
+ 'empty_title' => 'Noch keine Rechnungen',
+ 'empty_description' => 'Deine Rechnungen erscheinen hier nach deiner ersten Zahlung.',
'paid' => 'Bezahlt',
'download' => 'Rechnung herunterladen',
],
diff --git a/lang/de/create.php b/lang/de/create.php
index c606f7138..9aa0d1ec4 100644
--- a/lang/de/create.php
+++ b/lang/de/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Erstellen',
'tabs' => [
diff --git a/lang/de/integrations.php b/lang/de/integrations.php
index cc2bcfc07..712676014 100644
--- a/lang/de/integrations.php
+++ b/lang/de/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Design empfangen',
diff --git a/lang/de/offers.php b/lang/de/offers.php
new file mode 100644
index 000000000..bd1d4a163
--- /dev/null
+++ b/lang/de/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50 % Rabatt in den ersten 3 Monaten',
+ 'price' => '$9.50',
+ 'unit' => '/Monat',
+ 'period' => 'in den ersten 3 Monaten',
+ 'checkout_button' => 'Mein Konto aktivieren',
+ ],
+ 'fm1' => [
+ 'name' => 'Erster Monat',
+ 'headline' => 'Dein erster Monat für $1',
+ 'price' => '$1',
+ 'period' => 'im ersten Monat',
+ 'checkout_button' => 'Mein Konto aktivieren',
+ ],
+ 'ft7d' => [
+ 'price' => 'Kostenlos',
+ 'period' => 'für 7 Tage',
+ 'checkout_button' => 'Kostenlos testen',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Kostenlos',
+ 'period' => 'für 7 Tage',
+ 'checkout_button' => 'Kostenlos testen',
+ 'terms' => 'Keine Kreditkarte nötig',
+ ],
+];
diff --git a/lang/de/template_library.php b/lang/de/template_library.php
index e2bdb33af..c838d987d 100644
--- a/lang/de/template_library.php
+++ b/lang/de/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'Die Fünf-Minuten-Lösung',
diff --git a/lang/de/welcome.php b/lang/de/welcome.php
index 38c55cefa..ae9b14a9a 100644
--- a/lang/de/welcome.php
+++ b/lang/de/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Aktiviere dein Konto',
'plan_description' => 'Verbinde deine Kanäle und plane noch heute deinen ersten Post.',
- 'plan_first_month' => 'im ersten Monat',
- 'plan_terms' => 'Danach :price/Monat. Jederzeit kündbar.',
- 'plan_per_month' => 'pro Monat',
- 'plan_cancel_anytime' => 'Jederzeit kündbar.',
+ 'plan_terms' => 'Danach :price/Monat. Jederzeit kündbar',
+ 'plan_checkout_button' => 'Mein Konto aktivieren',
+ 'plan_cancel_anytime' => 'Jederzeit kündbar',
'mcp' => [
'title' => 'Social Media per Chat steuern',
'description' => 'Erstelle, plane und analysiere Posts in TryPost mit deiner Lieblings-KI.',
diff --git a/lang/el/accounts.php b/lang/el/accounts.php
index 454823fc2..e76e7d837 100644
--- a/lang/el/accounts.php
+++ b/lang/el/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Σύνδεση Bluesky',
diff --git a/lang/el/analytics.php b/lang/el/analytics.php
index 9b966c3c5..88628209c 100644
--- a/lang/el/analytics.php
+++ b/lang/el/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/el/auth.php b/lang/el/auth.php
index 31a3dfc38..26bd58038 100644
--- a/lang/el/auth.php
+++ b/lang/el/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/el/billing.php b/lang/el/billing.php
index c6ecf655a..59c2c7417 100644
--- a/lang/el/billing.php
+++ b/lang/el/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Χρέωση',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Μηνιαία χρέωση',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Ετήσια',
'save_two_months' => '2 μήνες δωρεάν',
'per_month' => '/μήνα',
+ 'per_year' => '/έτος',
'workspaces_one' => 'Ένα workspace',
'workspaces_unlimited' => 'Απεριόριστα workspaces',
'workspaces_tooltip' => 'Ένα workspace είναι ένα brand ή ένας πελάτης, ξεχωριστά από τα υπόλοιπα: με δικούς του λογαριασμούς social, υπογραφές, ετικέτες, analytics, δικαιώματα μελών και σύνδεση MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Επιλέξτε :plan',
'upgrade' => 'Αναβάθμιση σε :plan',
'downgrade' => 'Υποβάθμιση σε :plan',
- 'start_first_month' => 'Ενεργοποίηση με :price',
'billed_yearly_total' => 'Ετήσια χρέωση · :price (2 μήνες δωρεάν)',
'socials_tagline' => 'Ιδανικό για creators και μικρά brands.',
'workspaces_tagline' => 'Ιδανικό για agencies και μεγαλύτερες επιχειρήσεις.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Ενεργό',
+ 'trial' => 'Δωρεάν δοκιμή',
+ 'cancelling' => 'Ακυρώθηκε',
+ 'past_due' => 'Ληξιπρόθεσμο',
+ ],
'change' => 'Αλλαγή πλάνου',
- 'price_monthly' => ':price/μήνα',
- 'price_yearly' => ':price/έτος',
+ 'subscribe' => 'Εγγραφή τώρα',
'trial_until' => 'Δοκιμαστική περίοδος έως :date',
- 'renews' => 'Ανανεώνεται αυτόματα',
'cancelled' => 'Ακυρώθηκε, λήγει στις :date',
- 'workspaces_usage' => 'Workspaces: :count από :limit',
+ 'discount_until' => 'Έκπτωση :discount έως :date',
+ 'discount_forever' => 'Έκπτωση :discount σε κάθε πληρωμή',
+ 'discount_once' => 'Έκπτωση :discount στην επόμενη πληρωμή',
],
'subscription' => [
- 'title' => 'Μέθοδος πληρωμής',
+ 'title' => 'Μέθοδοι πληρωμής',
+ 'default' => 'Προεπιλογή',
'description' => 'Ενημερώστε την κάρτα ή τα στοιχεία χρέωσης στο Stripe.',
'no_payment_method' => 'Δεν υπάρχει καταχωρημένη μέθοδος πληρωμής ακόμη.',
'expires_on' => 'Λήγει :month/:year',
'manage_stripe' => 'Διαχείριση στο Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Πλάνο',
+ 'invoices' => 'Τιμολόγια',
+ ],
+
'invoices' => [
- 'title' => 'Τιμολόγια',
- 'description' => 'Κατεβάστε τα προηγούμενα τιμολόγιά σας.',
+ 'columns' => [
+ 'date' => 'Ημερομηνία',
+ 'amount' => 'Ποσό',
+ 'status' => 'Κατάσταση',
+ ],
+ 'empty_title' => 'Δεν υπάρχουν ακόμη τιμολόγια',
+ 'empty_description' => 'Τα τιμολόγιά σας θα εμφανίζονται εδώ μετά την πρώτη σας πληρωμή.',
'paid' => 'Πληρωμένο',
'download' => 'Λήψη τιμολογίου',
],
diff --git a/lang/el/calendar.php b/lang/el/calendar.php
index 7d79d3e13..6b2519101 100644
--- a/lang/el/calendar.php
+++ b/lang/el/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Ημερολόγιο',
'today' => 'Σήμερα',
diff --git a/lang/el/create.php b/lang/el/create.php
index 6632381f9..987903a2b 100644
--- a/lang/el/create.php
+++ b/lang/el/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Δημιουργία',
'tabs' => [
diff --git a/lang/el/integrations.php b/lang/el/integrations.php
index 74b74b8c7..dbfccf316 100644
--- a/lang/el/integrations.php
+++ b/lang/el/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Το σχέδιο ελήφθη',
diff --git a/lang/el/labels.php b/lang/el/labels.php
index 528be6740..380a33571 100644
--- a/lang/el/labels.php
+++ b/lang/el/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Ετικέτες',
'description' => 'Οργανώστε τις αναρτήσεις με ετικέτες.',
diff --git a/lang/el/notes.php b/lang/el/notes.php
index 40485cb32..5e848e1f3 100644
--- a/lang/el/notes.php
+++ b/lang/el/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Γράψτε μια σημείωση...',
'title' => 'Σημειώσεις',
diff --git a/lang/el/offers.php b/lang/el/offers.php
new file mode 100644
index 000000000..c863279bd
--- /dev/null
+++ b/lang/el/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => 'Έκπτωση 50% για τους πρώτους 3 μήνες',
+ 'price' => '$9.50',
+ 'unit' => '/μήνα',
+ 'period' => 'για τους πρώτους 3 μήνες',
+ 'checkout_button' => 'Ενεργοποίηση λογαριασμού',
+ ],
+ 'fm1' => [
+ 'name' => 'Πρώτος μήνας',
+ 'headline' => 'Ο πρώτος σας μήνας με $1',
+ 'price' => '$1',
+ 'period' => 'για τον πρώτο μήνα',
+ 'checkout_button' => 'Ενεργοποίηση λογαριασμού',
+ ],
+ 'ft7d' => [
+ 'price' => 'Δωρεάν',
+ 'period' => 'για 7 ημέρες',
+ 'checkout_button' => 'Δωρεάν δοκιμή',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Δωρεάν',
+ 'period' => 'για 7 ημέρες',
+ 'checkout_button' => 'Δωρεάν δοκιμή',
+ 'terms' => 'Δεν απαιτείται πιστωτική κάρτα',
+ ],
+];
diff --git a/lang/el/pagination.php b/lang/el/pagination.php
index 3f186c7a6..b31904f32 100644
--- a/lang/el/pagination.php
+++ b/lang/el/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/el/passwords.php b/lang/el/passwords.php
index 7f67588f8..7701e08eb 100644
--- a/lang/el/passwords.php
+++ b/lang/el/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/el/posts.php b/lang/el/posts.php
index 833fe88b1..1ced4d237 100644
--- a/lang/el/posts.php
+++ b/lang/el/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Λίστα',
'view_switcher' => 'Προβολή προγράμματος',
diff --git a/lang/el/settings.php b/lang/el/settings.php
index 9e3b79e6b..1b192c0da 100644
--- a/lang/el/settings.php
+++ b/lang/el/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Ρυθμίσεις',
'description' => 'Διαχειριστείτε το προφίλ και τις ρυθμίσεις του λογαριασμού σας',
diff --git a/lang/el/signatures.php b/lang/el/signatures.php
index 668b44c8b..e0a8b357c 100644
--- a/lang/el/signatures.php
+++ b/lang/el/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Υπογραφές',
'description' => 'Έτοιμα κείμενα για τις αναρτήσεις σας.',
diff --git a/lang/el/template_library.php b/lang/el/template_library.php
index d4ff90e2e..4eda16285 100644
--- a/lang/el/template_library.php
+++ b/lang/el/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'Η διόρθωση των πέντε λεπτών',
diff --git a/lang/el/validation.php b/lang/el/validation.php
index a1936931d..d29ed0b76 100644
--- a/lang/el/validation.php
+++ b/lang/el/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/el/welcome.php b/lang/el/welcome.php
index 515353d7d..1f9ada8d9 100644
--- a/lang/el/welcome.php
+++ b/lang/el/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Ενεργοποιήστε τον λογαριασμό σας',
'plan_description' => 'Συνδέστε τα κανάλια σας και προγραμματίστε την πρώτη σας ανάρτηση σήμερα.',
- 'plan_first_month' => 'για τον πρώτο μήνα',
- 'plan_terms' => 'Μετά :price/μήνα. Ακύρωση οποτεδήποτε.',
- 'plan_per_month' => 'τον μήνα',
- 'plan_cancel_anytime' => 'Ακύρωση οποτεδήποτε.',
+ 'plan_terms' => 'Μετά :price/μήνα. Ακύρωση οποτεδήποτε',
+ 'plan_checkout_button' => 'Ενεργοποίηση λογαριασμού',
+ 'plan_cancel_anytime' => 'Ακύρωση οποτεδήποτε',
'mcp' => [
'title' => 'Διαχειριστείτε τα social μέσω chat',
'description' => 'Φτιάξτε, προγραμματίστε και αναλύστε posts στο TryPost με την AI σας.',
diff --git a/lang/en/accounts.php b/lang/en/accounts.php
index 7eec47f24..3d6a1dc4b 100644
--- a/lang/en/accounts.php
+++ b/lang/en/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Connect Bluesky',
diff --git a/lang/en/analytics.php b/lang/en/analytics.php
index 96a52bb40..25e85541e 100644
--- a/lang/en/analytics.php
+++ b/lang/en/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/en/auth.php b/lang/en/auth.php
index 65d2b2fc2..276759ceb 100644
--- a/lang/en/auth.php
+++ b/lang/en/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/en/billing.php b/lang/en/billing.php
index 10fea5dda..842d46b5e 100644
--- a/lang/en/billing.php
+++ b/lang/en/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Billing',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Billed monthly',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Yearly',
'save_two_months' => '2 months free',
'per_month' => '/month',
+ 'per_year' => '/year',
'workspaces_one' => 'One workspace',
'workspaces_unlimited' => 'Unlimited workspaces',
'workspaces_tooltip' => 'A workspace is one brand or client, kept separate from the rest: its own social accounts, signatures, labels, analytics, member permissions, and MCP connection.',
@@ -33,7 +35,6 @@ return [
'select' => 'Choose :plan',
'upgrade' => 'Upgrade to :plan',
'downgrade' => 'Downgrade to :plan',
- 'start_first_month' => 'Activate for :price',
'billed_yearly_total' => 'Billed annually · :price (2 months free)',
'socials_tagline' => 'Best for creators and small brands.',
'workspaces_tagline' => 'Best for agencies and larger businesses.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Active',
+ 'trial' => 'Free trial',
+ 'cancelling' => 'Cancelled',
+ 'past_due' => 'Past due',
+ ],
'change' => 'Change plan',
- 'price_monthly' => ':price/month',
- 'price_yearly' => ':price/year',
+ 'subscribe' => 'Subscribe now',
'trial_until' => 'Trial until :date',
- 'renews' => 'Renews automatically',
'cancelled' => 'Cancelled, ends on :date',
- 'workspaces_usage' => 'Workspaces: :count of :limit',
+ 'discount_until' => ':discount off until :date',
+ 'discount_forever' => ':discount off on every payment',
+ 'discount_once' => ':discount off your next payment',
],
'subscription' => [
- 'title' => 'Payment method',
+ 'title' => 'Payment methods',
+ 'default' => 'Default',
'description' => 'Update your card or billing details on Stripe.',
'no_payment_method' => 'No payment method on file yet.',
'expires_on' => 'Expires :month/:year',
'manage_stripe' => 'Manage on Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Plan',
+ 'invoices' => 'Invoices',
+ ],
+
'invoices' => [
- 'title' => 'Invoices',
- 'description' => 'Download your past invoices.',
+ 'columns' => [
+ 'date' => 'Date',
+ 'amount' => 'Amount',
+ 'status' => 'Status',
+ ],
+ 'empty_title' => 'No invoices yet',
+ 'empty_description' => 'Your invoices show up here after your first payment.',
'paid' => 'Paid',
'download' => 'Download invoice',
],
diff --git a/lang/en/calendar.php b/lang/en/calendar.php
index ed4c562c7..54b5c7bce 100644
--- a/lang/en/calendar.php
+++ b/lang/en/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Calendar',
'today' => 'Today',
diff --git a/lang/en/create.php b/lang/en/create.php
index 6767ac8e3..238fcdf5e 100644
--- a/lang/en/create.php
+++ b/lang/en/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Create',
'tabs' => [
diff --git a/lang/en/integrations.php b/lang/en/integrations.php
index cf2421d12..d7403fa45 100644
--- a/lang/en/integrations.php
+++ b/lang/en/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Design received',
diff --git a/lang/en/labels.php b/lang/en/labels.php
index 1ad6e232b..95b6fcbbc 100644
--- a/lang/en/labels.php
+++ b/lang/en/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Labels',
'description' => 'Organize and filter your posts with labels.',
diff --git a/lang/en/notes.php b/lang/en/notes.php
index 036afe674..e96013da9 100644
--- a/lang/en/notes.php
+++ b/lang/en/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Write a note...',
'title' => 'Notes',
diff --git a/lang/en/offers.php b/lang/en/offers.php
new file mode 100644
index 000000000..07443508e
--- /dev/null
+++ b/lang/en/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50% off your first 3 months',
+ 'price' => '$9.50',
+ 'unit' => '/month',
+ 'period' => 'for your first 3 months',
+ 'checkout_button' => 'Activate my account',
+ ],
+ 'fm1' => [
+ 'name' => 'First month',
+ 'headline' => 'Your first month for $1',
+ 'price' => '$1',
+ 'period' => 'for your first month',
+ 'checkout_button' => 'Activate my account',
+ ],
+ 'ft7d' => [
+ 'price' => 'Free',
+ 'period' => 'for 7 days',
+ 'checkout_button' => 'Start free trial',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Free',
+ 'period' => 'for 7 days',
+ 'checkout_button' => 'Start free trial',
+ 'terms' => 'No credit card required',
+ ],
+];
diff --git a/lang/en/pagination.php b/lang/en/pagination.php
index d48141187..f03c42c6b 100644
--- a/lang/en/pagination.php
+++ b/lang/en/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/en/passwords.php b/lang/en/passwords.php
index fad3a7d72..ebc28fd27 100644
--- a/lang/en/passwords.php
+++ b/lang/en/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/en/posts.php b/lang/en/posts.php
index 4b7f5a5b0..2d2728e7d 100644
--- a/lang/en/posts.php
+++ b/lang/en/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'List',
'view_switcher' => 'Schedule view',
diff --git a/lang/en/settings.php b/lang/en/settings.php
index cff92b961..9769c6d53 100644
--- a/lang/en/settings.php
+++ b/lang/en/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Settings',
'description' => 'Manage your profile and account settings',
diff --git a/lang/en/signatures.php b/lang/en/signatures.php
index 7f0808193..2f026e5db 100644
--- a/lang/en/signatures.php
+++ b/lang/en/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Signatures',
'description' => 'Reusable text to append to your posts.',
diff --git a/lang/en/template_library.php b/lang/en/template_library.php
index d3b23f758..1a4d6f084 100644
--- a/lang/en/template_library.php
+++ b/lang/en/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'The five-minute fix',
diff --git a/lang/en/validation.php b/lang/en/validation.php
index 63ec29a14..f1d8dcf42 100644
--- a/lang/en/validation.php
+++ b/lang/en/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/en/welcome.php b/lang/en/welcome.php
index 3737cd2db..b7ead8d74 100644
--- a/lang/en/welcome.php
+++ b/lang/en/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Activate your account',
'plan_description' => 'Connect your channels and schedule your first post today.',
- 'plan_first_month' => 'for your first month',
- 'plan_terms' => 'Then :price/month. Cancel anytime.',
- 'plan_per_month' => 'per month',
- 'plan_cancel_anytime' => 'Cancel anytime.',
+ 'plan_terms' => 'Then :price/month. Cancel anytime',
+ 'plan_checkout_button' => 'Activate my account',
+ 'plan_cancel_anytime' => 'Cancel anytime',
'mcp' => [
'title' => 'Run your social media from a chat',
'description' => 'Create, schedule and analyze your TryPost posts with your favorite AI.',
diff --git a/lang/es/accounts.php b/lang/es/accounts.php
index fbfdf276f..7490e4195 100644
--- a/lang/es/accounts.php
+++ b/lang/es/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Conectar Bluesky',
diff --git a/lang/es/analytics.php b/lang/es/analytics.php
index f1314911c..0cebff7e6 100644
--- a/lang/es/analytics.php
+++ b/lang/es/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/es/auth.php b/lang/es/auth.php
index 8f9703e53..0ca676904 100644
--- a/lang/es/auth.php
+++ b/lang/es/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'failed' => 'Estas credenciales no coinciden con nuestros registros.',
'password' => 'La contraseña proporcionada es incorrecta.',
diff --git a/lang/es/billing.php b/lang/es/billing.php
index 3ea50e820..083b26448 100644
--- a/lang/es/billing.php
+++ b/lang/es/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Facturación',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Facturado mensualmente',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Anual',
'save_two_months' => '2 meses gratis',
'per_month' => '/mes',
+ 'per_year' => '/año',
'workspaces_one' => 'Un workspace',
'workspaces_unlimited' => 'Workspaces ilimitados',
'workspaces_tooltip' => 'Un workspace es una marca o cliente, separado del resto: con sus propias redes sociales, firmas, etiquetas, analíticas, permisos de miembros y conexión MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Elegir :plan',
'upgrade' => 'Mejorar a :plan',
'downgrade' => 'Bajar a :plan',
- 'start_first_month' => 'Activar por :price',
'billed_yearly_total' => 'Facturación anual · :price (2 meses gratis)',
'socials_tagline' => 'Ideal para creadores y marcas pequeñas.',
'workspaces_tagline' => 'Ideal para agencias y negocios grandes.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Activo',
+ 'trial' => 'Prueba gratis',
+ 'cancelling' => 'Cancelado',
+ 'past_due' => 'Vencido',
+ ],
'change' => 'Cambiar plan',
- 'price_monthly' => ':price/mes',
- 'price_yearly' => ':price/año',
+ 'subscribe' => 'Suscribirse ahora',
'trial_until' => 'Prueba hasta el :date',
- 'renews' => 'Se renueva automáticamente',
'cancelled' => 'Cancelado, termina el :date',
- 'workspaces_usage' => 'Workspaces: :count de :limit',
+ 'discount_until' => ':discount de descuento hasta el :date',
+ 'discount_forever' => ':discount de descuento en todos los pagos',
+ 'discount_once' => ':discount de descuento en tu próximo pago',
],
'subscription' => [
- 'title' => 'Método de pago',
+ 'title' => 'Métodos de pago',
+ 'default' => 'Predeterminado',
'description' => 'Actualiza tu tarjeta o datos de facturación en Stripe.',
'no_payment_method' => 'Aún no hay método de pago registrado.',
'expires_on' => 'Vence el :month/:year',
'manage_stripe' => 'Gestionar en Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Plan',
+ 'invoices' => 'Facturas',
+ ],
+
'invoices' => [
- 'title' => 'Facturas',
- 'description' => 'Descarga tus facturas anteriores.',
+ 'columns' => [
+ 'date' => 'Fecha',
+ 'amount' => 'Importe',
+ 'status' => 'Estado',
+ ],
+ 'empty_title' => 'Aún no hay facturas',
+ 'empty_description' => 'Tus facturas aparecerán aquí después de tu primer pago.',
'paid' => 'Pagado',
'download' => 'Descargar factura',
],
diff --git a/lang/es/calendar.php b/lang/es/calendar.php
index 8ed30dbf6..5c9c52e8a 100644
--- a/lang/es/calendar.php
+++ b/lang/es/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Calendario',
'today' => 'Hoy',
diff --git a/lang/es/create.php b/lang/es/create.php
index fa2c594dc..9cba24bba 100644
--- a/lang/es/create.php
+++ b/lang/es/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Crear',
'tabs' => [
diff --git a/lang/es/integrations.php b/lang/es/integrations.php
index ecc816d5f..5a7d7f3c3 100644
--- a/lang/es/integrations.php
+++ b/lang/es/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Diseño recibido',
diff --git a/lang/es/labels.php b/lang/es/labels.php
index f5188256d..272add25d 100644
--- a/lang/es/labels.php
+++ b/lang/es/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Etiquetas',
'description' => 'Organiza y filtra tus posts con etiquetas.',
diff --git a/lang/es/offers.php b/lang/es/offers.php
new file mode 100644
index 000000000..f84cc8b87
--- /dev/null
+++ b/lang/es/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50% de descuento los primeros 3 meses',
+ 'price' => '$9.50',
+ 'unit' => '/mes',
+ 'period' => 'los primeros 3 meses',
+ 'checkout_button' => 'Activar mi cuenta',
+ ],
+ 'fm1' => [
+ 'name' => 'Primer mes',
+ 'headline' => 'Tu primer mes por $1',
+ 'price' => '$1',
+ 'period' => 'el primer mes',
+ 'checkout_button' => 'Activar mi cuenta',
+ ],
+ 'ft7d' => [
+ 'price' => 'Gratis',
+ 'period' => 'durante 7 días',
+ 'checkout_button' => 'Empezar prueba gratis',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Gratis',
+ 'period' => 'durante 7 días',
+ 'checkout_button' => 'Empezar prueba gratis',
+ 'terms' => 'No necesitas tarjeta de crédito',
+ ],
+];
diff --git a/lang/es/pagination.php b/lang/es/pagination.php
index 1bed3bd06..9cba696ab 100644
--- a/lang/es/pagination.php
+++ b/lang/es/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'previous' => '&laquo; Anterior',
'next' => 'Siguiente &raquo;',
diff --git a/lang/es/passwords.php b/lang/es/passwords.php
index 66292cb30..c0d56d1d1 100644
--- a/lang/es/passwords.php
+++ b/lang/es/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'reset' => 'Tu contraseña ha sido restablecida.',
'sent' => 'Te hemos enviado un enlace para restablecer tu contraseña.',
diff --git a/lang/es/posts.php b/lang/es/posts.php
index a2d229f47..c8e7c5cb9 100644
--- a/lang/es/posts.php
+++ b/lang/es/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Lista',
'view_switcher' => 'Vista de programación',
diff --git a/lang/es/settings.php b/lang/es/settings.php
index c527baa07..1ab8f0e08 100644
--- a/lang/es/settings.php
+++ b/lang/es/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Configuración',
'description' => 'Administra tu perfil y configuración de la cuenta',
diff --git a/lang/es/signatures.php b/lang/es/signatures.php
index 222fa5d9d..345c12c0a 100644
--- a/lang/es/signatures.php
+++ b/lang/es/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Firmas',
'description' => 'Textos reutilizables para tus posts.',
diff --git a/lang/es/template_library.php b/lang/es/template_library.php
index 843938bf8..19a80b92f 100644
--- a/lang/es/template_library.php
+++ b/lang/es/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'La solución de cinco minutos',
diff --git a/lang/es/validation.php b/lang/es/validation.php
index bb7a9e003..beb0dd4b6 100644
--- a/lang/es/validation.php
+++ b/lang/es/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'accepted' => 'El campo :attribute debe ser aceptado.',
'accepted_if' => 'El campo :attribute debe ser aceptado cuando :other es :value.',
diff --git a/lang/es/welcome.php b/lang/es/welcome.php
index 4193c2416..ad4b5ca6c 100644
--- a/lang/es/welcome.php
+++ b/lang/es/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Activa tu cuenta',
'plan_description' => 'Conecta tus redes y programa tu primer post hoy.',
- 'plan_first_month' => 'el primer mes',
- 'plan_terms' => 'Luego, :price/mes. Cancela cuando quieras.',
- 'plan_per_month' => 'al mes',
- 'plan_cancel_anytime' => 'Cancela cuando quieras.',
+ 'plan_terms' => 'Luego, :price/mes. Cancela cuando quieras',
+ 'plan_checkout_button' => 'Activar mi cuenta',
+ 'plan_cancel_anytime' => 'Cancela cuando quieras',
'mcp' => [
'title' => 'Gestiona tus redes desde el chat',
'description' => 'Crea, programa y analiza posts en TryPost con tu IA favorita.',
diff --git a/lang/fr/accounts.php b/lang/fr/accounts.php
index c30d8de6a..06c6c9267 100644
--- a/lang/fr/accounts.php
+++ b/lang/fr/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Connecter Bluesky',
diff --git a/lang/fr/analytics.php b/lang/fr/analytics.php
index 47a1f9126..888dcf261 100644
--- a/lang/fr/analytics.php
+++ b/lang/fr/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/fr/auth.php b/lang/fr/auth.php
index ce1984bb3..e646e0369 100644
--- a/lang/fr/auth.php
+++ b/lang/fr/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/fr/billing.php b/lang/fr/billing.php
index 413571ee6..8f6122c3f 100644
--- a/lang/fr/billing.php
+++ b/lang/fr/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Facturation',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Facturé mensuellement',
'prices' => [
- 'first_month' => '1 $',
'socials' => ['monthly' => '19 $', 'yearly_per_month' => '15,83 $', 'yearly' => '190 $'],
'workspaces' => ['monthly' => '99 $', 'yearly_per_month' => '82,50 $', 'yearly' => '990 $'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Annuel',
'save_two_months' => '2 mois offerts',
'per_month' => '/mois',
+ 'per_year' => '/an',
'workspaces_one' => 'Un espace de travail',
'workspaces_unlimited' => 'Espaces de travail illimités',
'workspaces_tooltip' => 'Un espace de travail correspond à une marque ou un client, séparé des autres : ses propres réseaux sociaux, signatures, libellés, statistiques, permissions des membres et connexion MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Choisir :plan',
'upgrade' => 'Passer à :plan',
'downgrade' => 'Revenir à :plan',
- 'start_first_month' => 'Activer pour :price',
'billed_yearly_total' => 'Facturé annuellement · :price (2 mois offerts)',
'socials_tagline' => 'Idéal pour les créateurs et petites marques.',
'workspaces_tagline' => 'Idéal pour les agences et grandes entreprises.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Active',
+ 'trial' => 'Essai gratuit',
+ 'cancelling' => 'Annulée',
+ 'past_due' => 'En retard',
+ ],
'change' => 'Changer d\'offre',
- 'price_monthly' => ':price/mois',
- 'price_yearly' => ':price/an',
+ 'subscribe' => 'S\'abonner',
'trial_until' => 'Essai jusqu\'au :date',
- 'renews' => 'Renouvellement automatique',
'cancelled' => 'Annulé, se termine le :date',
- 'workspaces_usage' => 'Workspaces : :count sur :limit',
+ 'discount_until' => ':discount de réduction jusqu\'au :date',
+ 'discount_forever' => ':discount de réduction sur chaque paiement',
+ 'discount_once' => ':discount de réduction sur votre prochain paiement',
],
'subscription' => [
- 'title' => 'Moyen de paiement',
+ 'title' => 'Moyens de paiement',
+ 'default' => 'Par défaut',
'description' => 'Mettez à jour votre carte ou vos informations de facturation sur Stripe.',
'no_payment_method' => 'Aucun moyen de paiement enregistré pour le moment.',
'expires_on' => 'Expire le :month/:year',
'manage_stripe' => 'Gérer sur Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Offre',
+ 'invoices' => 'Factures',
+ ],
+
'invoices' => [
- 'title' => 'Factures',
- 'description' => 'Téléchargez vos factures passées.',
+ 'columns' => [
+ 'date' => 'Date',
+ 'amount' => 'Montant',
+ 'status' => 'Statut',
+ ],
+ 'empty_title' => 'Aucune facture pour l\'instant',
+ 'empty_description' => 'Vos factures apparaîtront ici après votre premier paiement.',
'paid' => 'Payée',
'download' => 'Télécharger la facture',
],
diff --git a/lang/fr/calendar.php b/lang/fr/calendar.php
index 9eef708df..d08b8387f 100644
--- a/lang/fr/calendar.php
+++ b/lang/fr/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Calendrier',
'today' => 'Aujourd\'hui',
diff --git a/lang/fr/create.php b/lang/fr/create.php
index 431d7f084..bca77d48a 100644
--- a/lang/fr/create.php
+++ b/lang/fr/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Créer',
'tabs' => [
diff --git a/lang/fr/integrations.php b/lang/fr/integrations.php
index 9964d6b5e..57c75e0f0 100644
--- a/lang/fr/integrations.php
+++ b/lang/fr/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Design reçu',
diff --git a/lang/fr/labels.php b/lang/fr/labels.php
index 4ee4e61cd..253a79967 100644
--- a/lang/fr/labels.php
+++ b/lang/fr/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Étiquettes',
'description' => 'Organisez vos publications avec des étiquettes.',
diff --git a/lang/fr/notes.php b/lang/fr/notes.php
index aecb6f19a..4feac653a 100644
--- a/lang/fr/notes.php
+++ b/lang/fr/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Écrire une note...',
'title' => 'Notes',
diff --git a/lang/fr/offers.php b/lang/fr/offers.php
new file mode 100644
index 000000000..ebb3e0f3c
--- /dev/null
+++ b/lang/fr/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50 % de réduction les 3 premiers mois',
+ 'price' => '9,50 $',
+ 'unit' => '/mois',
+ 'period' => 'pour les 3 premiers mois',
+ 'checkout_button' => 'Activer mon compte',
+ ],
+ 'fm1' => [
+ 'name' => 'Premier mois',
+ 'headline' => 'Votre premier mois pour 1 $',
+ 'price' => '1 $',
+ 'period' => 'pour le premier mois',
+ 'checkout_button' => 'Activer mon compte',
+ ],
+ 'ft7d' => [
+ 'price' => 'Gratuit',
+ 'period' => 'pendant 7 jours',
+ 'checkout_button' => 'Commencer l\'essai',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Gratuit',
+ 'period' => 'pendant 7 jours',
+ 'checkout_button' => 'Commencer l\'essai',
+ 'terms' => 'Aucune carte bancaire requise',
+ ],
+];
diff --git a/lang/fr/pagination.php b/lang/fr/pagination.php
index 8eff37464..15c69f696 100644
--- a/lang/fr/pagination.php
+++ b/lang/fr/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/fr/passwords.php b/lang/fr/passwords.php
index 8f4f8abbd..a89e3f1d9 100644
--- a/lang/fr/passwords.php
+++ b/lang/fr/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/fr/posts.php b/lang/fr/posts.php
index 882a779ea..0d01926fb 100644
--- a/lang/fr/posts.php
+++ b/lang/fr/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Liste',
'view_switcher' => 'Vue du calendrier',
diff --git a/lang/fr/settings.php b/lang/fr/settings.php
index fa064352c..077ed80cd 100644
--- a/lang/fr/settings.php
+++ b/lang/fr/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Paramètres',
'description' => 'Gérez votre profil et les paramètres de votre compte',
diff --git a/lang/fr/signatures.php b/lang/fr/signatures.php
index ea0ff5f0c..65200e111 100644
--- a/lang/fr/signatures.php
+++ b/lang/fr/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Signatures',
'description' => 'Textes réutilisables pour vos publications.',
diff --git a/lang/fr/template_library.php b/lang/fr/template_library.php
index 7aaf6047b..df5a12c9a 100644
--- a/lang/fr/template_library.php
+++ b/lang/fr/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'Le correctif en cinq minutes',
diff --git a/lang/fr/validation.php b/lang/fr/validation.php
index e21385424..f27a2be5e 100644
--- a/lang/fr/validation.php
+++ b/lang/fr/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/fr/welcome.php b/lang/fr/welcome.php
index 9accff043..619b6db30 100644
--- a/lang/fr/welcome.php
+++ b/lang/fr/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Activez votre compte',
'plan_description' => 'Connectez vos réseaux et programmez votre premier post dès aujourd’hui.',
- 'plan_first_month' => 'pour le premier mois',
- 'plan_terms' => 'Puis :price/mois. Annulez à tout moment.',
- 'plan_per_month' => 'par mois',
- 'plan_cancel_anytime' => 'Annulez à tout moment.',
+ 'plan_terms' => 'Puis :price/mois. Annulez à tout moment',
+ 'plan_checkout_button' => 'Activer mon compte',
+ 'plan_cancel_anytime' => 'Annulez à tout moment',
'mcp' => [
'title' => 'Gérez vos réseaux par chat',
'description' => 'Créez, planifiez et analysez vos posts TryPost avec votre IA préférée.',
diff --git a/lang/it/accounts.php b/lang/it/accounts.php
index fe1d15dc5..0cad14588 100644
--- a/lang/it/accounts.php
+++ b/lang/it/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Collega Bluesky',
diff --git a/lang/it/analytics.php b/lang/it/analytics.php
index a46c06cfc..c5a0a5a40 100644
--- a/lang/it/analytics.php
+++ b/lang/it/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/it/auth.php b/lang/it/auth.php
index fc8822d87..2c45744fc 100644
--- a/lang/it/auth.php
+++ b/lang/it/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/it/billing.php b/lang/it/billing.php
index 61a74e56c..e8a0f2a23 100644
--- a/lang/it/billing.php
+++ b/lang/it/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Fatturazione',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Fatturazione mensile',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Annuale',
'save_two_months' => '2 mesi gratis',
'per_month' => '/mese',
+ 'per_year' => '/anno',
'workspaces_one' => 'Un workspace',
'workspaces_unlimited' => 'Workspace illimitati',
'workspaces_tooltip' => 'Un workspace è un brand o un cliente, separato dagli altri: con i propri account social, firme, etichette, analytics, permessi dei membri e connessione MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Scegli :plan',
'upgrade' => 'Fai upgrade a :plan',
'downgrade' => 'Fai downgrade a :plan',
- 'start_first_month' => 'Attiva a :price',
'billed_yearly_total' => 'Fatturato annualmente · :price (2 mesi gratis)',
'socials_tagline' => 'Ideale per creator e piccole marche.',
'workspaces_tagline' => 'Ideale per agenzie e grandi attività.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Attivo',
+ 'trial' => 'Prova gratuita',
+ 'cancelling' => 'Annullato',
+ 'past_due' => 'Scaduto',
+ ],
'change' => 'Cambia piano',
- 'price_monthly' => ':price/mese',
- 'price_yearly' => ':price/anno',
+ 'subscribe' => 'Abbonati ora',
'trial_until' => 'Prova fino al :date',
- 'renews' => 'Si rinnova automaticamente',
'cancelled' => 'Annullato, termina il :date',
- 'workspaces_usage' => 'Workspace: :count di :limit',
+ 'discount_until' => ':discount di sconto fino al :date',
+ 'discount_forever' => ':discount di sconto su ogni pagamento',
+ 'discount_once' => ':discount di sconto sul prossimo pagamento',
],
'subscription' => [
- 'title' => 'Metodo di pagamento',
+ 'title' => 'Metodi di pagamento',
+ 'default' => 'Predefinito',
'description' => 'Aggiorna la carta o i dati di fatturazione su Stripe.',
'no_payment_method' => 'Nessun metodo di pagamento ancora registrato.',
'expires_on' => 'Scade il :month/:year',
'manage_stripe' => 'Gestisci su Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Piano',
+ 'invoices' => 'Fatture',
+ ],
+
'invoices' => [
- 'title' => 'Fatture',
- 'description' => 'Scarica le tue fatture passate.',
+ 'columns' => [
+ 'date' => 'Data',
+ 'amount' => 'Importo',
+ 'status' => 'Stato',
+ ],
+ 'empty_title' => 'Ancora nessuna fattura',
+ 'empty_description' => 'Le tue fatture appariranno qui dopo il primo pagamento.',
'paid' => 'Pagata',
'download' => 'Scarica fattura',
],
diff --git a/lang/it/calendar.php b/lang/it/calendar.php
index ccd15ef6b..c6d86e054 100644
--- a/lang/it/calendar.php
+++ b/lang/it/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Calendario',
'today' => 'Oggi',
diff --git a/lang/it/create.php b/lang/it/create.php
index eaa961b68..5053144c4 100644
--- a/lang/it/create.php
+++ b/lang/it/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Crea',
'tabs' => [
diff --git a/lang/it/integrations.php b/lang/it/integrations.php
index df7907c44..675d9b81c 100644
--- a/lang/it/integrations.php
+++ b/lang/it/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Design ricevuto',
diff --git a/lang/it/labels.php b/lang/it/labels.php
index 8962d6061..b805724d5 100644
--- a/lang/it/labels.php
+++ b/lang/it/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Etichette',
'description' => 'Organizza i tuoi post con le etichette.',
diff --git a/lang/it/notes.php b/lang/it/notes.php
index 8b54e25ea..d83f595a0 100644
--- a/lang/it/notes.php
+++ b/lang/it/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Scrivi una nota...',
'title' => 'Note',
diff --git a/lang/it/offers.php b/lang/it/offers.php
new file mode 100644
index 000000000..cb2ed2144
--- /dev/null
+++ b/lang/it/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50% di sconto per i primi 3 mesi',
+ 'price' => '$9.50',
+ 'unit' => '/mese',
+ 'period' => 'per i primi 3 mesi',
+ 'checkout_button' => 'Attiva il mio account',
+ ],
+ 'fm1' => [
+ 'name' => 'Primo mese',
+ 'headline' => 'Il tuo primo mese a $1',
+ 'price' => '$1',
+ 'period' => 'per il primo mese',
+ 'checkout_button' => 'Attiva il mio account',
+ ],
+ 'ft7d' => [
+ 'price' => 'Gratis',
+ 'period' => 'per 7 giorni',
+ 'checkout_button' => 'Inizia la prova gratis',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Gratis',
+ 'period' => 'per 7 giorni',
+ 'checkout_button' => 'Inizia la prova gratis',
+ 'terms' => 'Nessuna carta di credito richiesta',
+ ],
+];
diff --git a/lang/it/pagination.php b/lang/it/pagination.php
index 9d6a2e2bc..17d5f149b 100644
--- a/lang/it/pagination.php
+++ b/lang/it/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/it/passwords.php b/lang/it/passwords.php
index 556d8e76e..002647953 100644
--- a/lang/it/passwords.php
+++ b/lang/it/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/it/posts.php b/lang/it/posts.php
index da1128772..2a7635429 100644
--- a/lang/it/posts.php
+++ b/lang/it/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Elenco',
'view_switcher' => 'Vista programmazione',
diff --git a/lang/it/settings.php b/lang/it/settings.php
index 34b9936da..5048b1605 100644
--- a/lang/it/settings.php
+++ b/lang/it/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Impostazioni',
'description' => 'Gestisci il tuo profilo e le impostazioni dell\'account',
diff --git a/lang/it/signatures.php b/lang/it/signatures.php
index f2e91b100..d94d58c46 100644
--- a/lang/it/signatures.php
+++ b/lang/it/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Firme',
'description' => 'Testi riutilizzabili per i tuoi post.',
diff --git a/lang/it/template_library.php b/lang/it/template_library.php
index 34728c5fa..423c37746 100644
--- a/lang/it/template_library.php
+++ b/lang/it/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'La soluzione in cinque minuti',
diff --git a/lang/it/validation.php b/lang/it/validation.php
index 9b82f6f01..0717c02d9 100644
--- a/lang/it/validation.php
+++ b/lang/it/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/it/welcome.php b/lang/it/welcome.php
index 47dd97ca8..d5463f220 100644
--- a/lang/it/welcome.php
+++ b/lang/it/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Attiva il tuo account',
'plan_description' => 'Collega i tuoi canali e programma il tuo primo post oggi.',
- 'plan_first_month' => 'per il primo mese',
- 'plan_terms' => 'Poi :price/mese. Disdici quando vuoi.',
- 'plan_per_month' => 'al mese',
- 'plan_cancel_anytime' => 'Disdici quando vuoi.',
+ 'plan_terms' => 'Poi :price/mese. Disdici quando vuoi',
+ 'plan_checkout_button' => 'Attiva il mio account',
+ 'plan_cancel_anytime' => 'Disdici quando vuoi',
'mcp' => [
'title' => 'Gestisci i social dalla chat',
'description' => 'Crea, programma e analizza i post su TryPost con la tua IA preferita.',
diff --git a/lang/ja/accounts.php b/lang/ja/accounts.php
index e3acbcfba..03f8c2e94 100644
--- a/lang/ja/accounts.php
+++ b/lang/ja/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Bluesky を接続',
diff --git a/lang/ja/analytics.php b/lang/ja/analytics.php
index dc00a296a..68a0beec8 100644
--- a/lang/ja/analytics.php
+++ b/lang/ja/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/ja/auth.php b/lang/ja/auth.php
index 6f317c5f6..4f504c85c 100644
--- a/lang/ja/auth.php
+++ b/lang/ja/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ja/billing.php b/lang/ja/billing.php
index 4dbf006be..69b8fe33e 100644
--- a/lang/ja/billing.php
+++ b/lang/ja/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'お支払い',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => '月払い',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => '年額',
'save_two_months' => '2か月分無料',
'per_month' => '/月',
+ 'per_year' => '/年',
'workspaces_one' => 'ワークスペース 1 つ',
'workspaces_unlimited' => '無制限のワークスペース',
'workspaces_tooltip' => 'ワークスペースは 1 つのブランドや顧客ごとの独立した領域です。SNS アカウント、署名、ラベル、アナリティクス、メンバー権限、MCP 接続をそれぞれ個別に持ちます。',
@@ -33,7 +35,6 @@ return [
'select' => ':plan を選ぶ',
'upgrade' => ':plan にアップグレード',
'downgrade' => ':plan にダウングレード',
- 'start_first_month' => ':priceで有効にする',
'billed_yearly_total' => '年払い · :price(2か月分無料)',
'socials_tagline' => 'クリエイターや小規模ブランド向け。',
'workspaces_tagline' => '代理店や大規模ビジネス向け。',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => '有効',
+ 'trial' => '無料トライアル',
+ 'cancelling' => '解約済み',
+ 'past_due' => '延滞',
+ ],
'change' => 'プランを変更',
- 'price_monthly' => ':price/月',
- 'price_yearly' => ':price/年',
+ 'subscribe' => '今すぐ申し込む',
'trial_until' => ':dateまでトライアル',
- 'renews' => '自動更新',
'cancelled' => '解約済み、:dateに終了',
- 'workspaces_usage' => 'ワークスペース: :count / :limit',
+ 'discount_until' => ':dateまで:discount割引',
+ 'discount_forever' => '毎回の支払いで:discount割引',
+ 'discount_once' => '次回の支払いで:discount割引',
],
'subscription' => [
'title' => 'お支払い方法',
+ 'default' => 'デフォルト',
'description' => 'カードや請求情報は Stripe で更新できます。',
'no_payment_method' => 'まだ登録されたお支払い方法がありません。',
'expires_on' => '有効期限 :month/:year',
'manage_stripe' => 'Stripe で管理',
],
+ 'tabs' => [
+ 'plan' => 'プラン',
+ 'invoices' => '請求書',
+ ],
+
'invoices' => [
- 'title' => '請求書',
- 'description' => '過去の請求書をダウンロードできます。',
+ 'columns' => [
+ 'date' => '日付',
+ 'amount' => '金額',
+ 'status' => 'ステータス',
+ ],
+ 'empty_title' => '請求書はまだありません',
+ 'empty_description' => '初回のお支払い後、請求書がここに表示されます。',
'paid' => '支払い済み',
'download' => '請求書をダウンロード',
],
diff --git a/lang/ja/calendar.php b/lang/ja/calendar.php
index ff38a98bf..551359e31 100644
--- a/lang/ja/calendar.php
+++ b/lang/ja/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'カレンダー',
'today' => '今日',
diff --git a/lang/ja/create.php b/lang/ja/create.php
index 877123045..2316f759f 100644
--- a/lang/ja/create.php
+++ b/lang/ja/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '作成',
'tabs' => [
diff --git a/lang/ja/integrations.php b/lang/ja/integrations.php
index 71d389206..544e6ed79 100644
--- a/lang/ja/integrations.php
+++ b/lang/ja/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'デザインを受け取りました',
diff --git a/lang/ja/labels.php b/lang/ja/labels.php
index ecd009123..4c9a9e218 100644
--- a/lang/ja/labels.php
+++ b/lang/ja/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'ラベル',
'description' => 'ラベルで投稿を整理しましょう。',
diff --git a/lang/ja/notes.php b/lang/ja/notes.php
index b0b6ec36b..be8cefd32 100644
--- a/lang/ja/notes.php
+++ b/lang/ja/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'メモを書く...',
'title' => 'メモ',
diff --git a/lang/ja/offers.php b/lang/ja/offers.php
new file mode 100644
index 000000000..16b202a7e
--- /dev/null
+++ b/lang/ja/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'ブラックフライデー',
+ 'headline' => '最初の3か月50%オフ',
+ 'price' => '$9.50',
+ 'unit' => '/月',
+ 'period' => '最初の3か月',
+ 'checkout_button' => 'アカウントを有効にする',
+ ],
+ 'fm1' => [
+ 'name' => '初月',
+ 'headline' => '初月は$1',
+ 'price' => '$1',
+ 'period' => '初月の料金',
+ 'checkout_button' => 'アカウントを有効にする',
+ ],
+ 'ft7d' => [
+ 'price' => '無料',
+ 'period' => '7日間',
+ 'checkout_button' => '無料で試す',
+ ],
+ 'ft7dnc' => [
+ 'price' => '無料',
+ 'period' => '7日間',
+ 'checkout_button' => '無料で試す',
+ 'terms' => 'クレジットカードは不要です',
+ ],
+];
diff --git a/lang/ja/pagination.php b/lang/ja/pagination.php
index 46e88f9d0..56ef30be4 100644
--- a/lang/ja/pagination.php
+++ b/lang/ja/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ja/passwords.php b/lang/ja/passwords.php
index a0ae6dbe0..1e64cb689 100644
--- a/lang/ja/passwords.php
+++ b/lang/ja/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ja/posts.php b/lang/ja/posts.php
index 5ee94ab71..b48daa800 100644
--- a/lang/ja/posts.php
+++ b/lang/ja/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'リスト',
'view_switcher' => 'スケジュール表示',
diff --git a/lang/ja/settings.php b/lang/ja/settings.php
index e10fa6958..c821eeb74 100644
--- a/lang/ja/settings.php
+++ b/lang/ja/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '設定',
'description' => 'プロフィールとアカウントの設定を管理します',
diff --git a/lang/ja/signatures.php b/lang/ja/signatures.php
index c26c05269..eb5692084 100644
--- a/lang/ja/signatures.php
+++ b/lang/ja/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '署名',
'description' => '投稿に追加できる定型文です。',
diff --git a/lang/ja/template_library.php b/lang/ja/template_library.php
index 688555dcf..40cb3c37b 100644
--- a/lang/ja/template_library.php
+++ b/lang/ja/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => '5分でできる改善',
diff --git a/lang/ja/validation.php b/lang/ja/validation.php
index 6b041e264..52b02508e 100644
--- a/lang/ja/validation.php
+++ b/lang/ja/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ja/welcome.php b/lang/ja/welcome.php
index c6973a89a..1e50dbaed 100644
--- a/lang/ja/welcome.php
+++ b/lang/ja/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'アカウントを有効にしましょう',
'plan_description' => 'チャンネルを連携して、今日最初の投稿を予約しましょう。',
- 'plan_first_month' => '初月の料金',
- 'plan_terms' => 'その後は:price/月。いつでも解約できます。',
- 'plan_per_month' => '毎月',
- 'plan_cancel_anytime' => 'いつでも解約できます。',
+ 'plan_terms' => 'その後は:price/月。いつでも解約できます',
+ 'plan_checkout_button' => 'アカウントを有効にする',
+ 'plan_cancel_anytime' => 'いつでも解約できます',
'mcp' => [
'title' => 'AIとの会話でSNSを運用',
'description' => 'お気に入りのAIで、TryPostの投稿を作成・予約・分析。',
diff --git a/lang/ko/accounts.php b/lang/ko/accounts.php
index dea35fa7b..eb961f1d5 100644
--- a/lang/ko/accounts.php
+++ b/lang/ko/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Bluesky 연결',
diff --git a/lang/ko/analytics.php b/lang/ko/analytics.php
index 0f3399b0c..db0109889 100644
--- a/lang/ko/analytics.php
+++ b/lang/ko/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/ko/auth.php b/lang/ko/auth.php
index bfdf70c18..c8c193298 100644
--- a/lang/ko/auth.php
+++ b/lang/ko/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ko/billing.php b/lang/ko/billing.php
index 13652ad25..c32777eca 100644
--- a/lang/ko/billing.php
+++ b/lang/ko/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '결제',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => '월간 결제',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => '연간',
'save_two_months' => '2개월 무료',
'per_month' => '/월',
+ 'per_year' => '/년',
'workspaces_one' => '워크스페이스 하나',
'workspaces_unlimited' => '무제한 워크스페이스',
'workspaces_tooltip' => '워크스페이스는 브랜드나 고객 하나를 나머지와 분리한 공간입니다. 소셜 계정, 서명, 라벨, 분석, 멤버 권한, MCP 연결을 각각 따로 가집니다.',
@@ -33,7 +35,6 @@ return [
'select' => ':plan 선택',
'upgrade' => ':plan(으)로 업그레이드',
'downgrade' => ':plan(으)로 다운그레이드',
- 'start_first_month' => ':price에 활성화',
'billed_yearly_total' => '연간 결제 · :price (2개월 무료)',
'socials_tagline' => '크리에이터와 소규모 브랜드에 적합.',
'workspaces_tagline' => '에이전시와 대규모 비즈니스에 적합.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => '활성',
+ 'trial' => '무료 체험',
+ 'cancelling' => '취소됨',
+ 'past_due' => '연체',
+ ],
'change' => '요금제 변경',
- 'price_monthly' => ':price/월',
- 'price_yearly' => ':price/년',
+ 'subscribe' => '지금 구독하기',
'trial_until' => ':date까지 체험',
- 'renews' => '자동 갱신',
'cancelled' => '취소됨, :date에 종료',
- 'workspaces_usage' => '워크스페이스: :count / :limit',
+ 'discount_until' => ':date까지 :discount 할인',
+ 'discount_forever' => '매 결제 시 :discount 할인',
+ 'discount_once' => '다음 결제 시 :discount 할인',
],
'subscription' => [
'title' => '결제 수단',
+ 'default' => '기본',
'description' => '카드나 청구 정보는 Stripe에서 업데이트하세요.',
'no_payment_method' => '아직 등록된 결제 수단이 없습니다.',
'expires_on' => ':month/:year 만료',
'manage_stripe' => 'Stripe에서 관리',
],
+ 'tabs' => [
+ 'plan' => '요금제',
+ 'invoices' => '청구서',
+ ],
+
'invoices' => [
- 'title' => '청구서',
- 'description' => '지난 청구서를 다운로드하세요.',
+ 'columns' => [
+ 'date' => '날짜',
+ 'amount' => '금액',
+ 'status' => '상태',
+ ],
+ 'empty_title' => '아직 청구서가 없습니다',
+ 'empty_description' => '첫 결제 후 청구서가 여기에 표시됩니다.',
'paid' => '결제 완료',
'download' => '인보이스 다운로드',
],
diff --git a/lang/ko/calendar.php b/lang/ko/calendar.php
index 561770778..1437ddaa9 100644
--- a/lang/ko/calendar.php
+++ b/lang/ko/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '캘린더',
'today' => '오늘',
diff --git a/lang/ko/create.php b/lang/ko/create.php
index 3322678ed..2d8829bfa 100644
--- a/lang/ko/create.php
+++ b/lang/ko/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '만들기',
'tabs' => [
diff --git a/lang/ko/integrations.php b/lang/ko/integrations.php
index 9550a5408..edf1ec61c 100644
--- a/lang/ko/integrations.php
+++ b/lang/ko/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => '디자인을 받았습니다',
diff --git a/lang/ko/labels.php b/lang/ko/labels.php
index c6c492cde..b91af04a2 100644
--- a/lang/ko/labels.php
+++ b/lang/ko/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '라벨',
'description' => '라벨로 게시물을 정리하세요.',
diff --git a/lang/ko/notes.php b/lang/ko/notes.php
index 4895af59f..8d2031a10 100644
--- a/lang/ko/notes.php
+++ b/lang/ko/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => '메모를 작성하세요...',
'title' => '메모',
diff --git a/lang/ko/offers.php b/lang/ko/offers.php
new file mode 100644
index 000000000..14733e98c
--- /dev/null
+++ b/lang/ko/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => '블랙 프라이데이',
+ 'headline' => '첫 3개월 50% 할인',
+ 'price' => '$9.50',
+ 'unit' => '/월',
+ 'period' => '첫 3개월',
+ 'checkout_button' => '내 계정 활성화',
+ ],
+ 'fm1' => [
+ 'name' => '첫 달',
+ 'headline' => '첫 달 $1',
+ 'price' => '$1',
+ 'period' => '첫 달 요금',
+ 'checkout_button' => '내 계정 활성화',
+ ],
+ 'ft7d' => [
+ 'price' => '무료',
+ 'period' => '7일 동안',
+ 'checkout_button' => '무료 체험 시작',
+ ],
+ 'ft7dnc' => [
+ 'price' => '무료',
+ 'period' => '7일 동안',
+ 'checkout_button' => '무료 체험 시작',
+ 'terms' => '신용카드가 필요 없습니다',
+ ],
+];
diff --git a/lang/ko/pagination.php b/lang/ko/pagination.php
index 6c0707734..5a6835856 100644
--- a/lang/ko/pagination.php
+++ b/lang/ko/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ko/passwords.php b/lang/ko/passwords.php
index 2f927e3f1..b044e80b3 100644
--- a/lang/ko/passwords.php
+++ b/lang/ko/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ko/posts.php b/lang/ko/posts.php
index 3c70e1d2c..f08370fd8 100644
--- a/lang/ko/posts.php
+++ b/lang/ko/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => '목록',
'view_switcher' => '일정 보기',
diff --git a/lang/ko/settings.php b/lang/ko/settings.php
index 50e627e74..c77fb7179 100644
--- a/lang/ko/settings.php
+++ b/lang/ko/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '설정',
'description' => '프로필 및 계정 설정 관리',
diff --git a/lang/ko/signatures.php b/lang/ko/signatures.php
index 56ef401d0..532ee4417 100644
--- a/lang/ko/signatures.php
+++ b/lang/ko/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '서명',
'description' => '게시물에 추가할 재사용 텍스트입니다.',
diff --git a/lang/ko/template_library.php b/lang/ko/template_library.php
index 069e470c2..319c80458 100644
--- a/lang/ko/template_library.php
+++ b/lang/ko/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => '5분이면 끝나는 해결법',
diff --git a/lang/ko/validation.php b/lang/ko/validation.php
index 7e8102203..1036fa221 100644
--- a/lang/ko/validation.php
+++ b/lang/ko/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ko/welcome.php b/lang/ko/welcome.php
index 2901f0ae5..e0498e838 100644
--- a/lang/ko/welcome.php
+++ b/lang/ko/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => '계정을 활성화하세요',
'plan_description' => '채널을 연결하고 오늘 첫 게시물을 예약하세요.',
- 'plan_first_month' => '첫 달 요금',
- 'plan_terms' => '이후 :price/월. 언제든지 해지 가능.',
- 'plan_per_month' => '매월',
- 'plan_cancel_anytime' => '언제든지 해지 가능.',
+ 'plan_terms' => '이후 :price/월. 언제든지 해지 가능',
+ 'plan_checkout_button' => '내 계정 활성화',
+ 'plan_cancel_anytime' => '언제든지 해지 가능',
'mcp' => [
'title' => 'AI와 대화하며 SNS를 관리하세요',
'description' => '좋아하는 AI로 TryPost 게시물을 만들고, 예약하고, 분석하세요.',
diff --git a/lang/nl/accounts.php b/lang/nl/accounts.php
index 1cfc09f1c..2168ea629 100644
--- a/lang/nl/accounts.php
+++ b/lang/nl/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Bluesky koppelen',
diff --git a/lang/nl/analytics.php b/lang/nl/analytics.php
index 7b604d4db..acdada9d0 100644
--- a/lang/nl/analytics.php
+++ b/lang/nl/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/nl/auth.php b/lang/nl/auth.php
index 130c4c882..877b8c742 100644
--- a/lang/nl/auth.php
+++ b/lang/nl/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/nl/billing.php b/lang/nl/billing.php
index 313c3ece6..aa3c3a210 100644
--- a/lang/nl/billing.php
+++ b/lang/nl/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Facturatie',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Maandelijks gefactureerd',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Jaarlijks',
'save_two_months' => '2 maanden gratis',
'per_month' => '/maand',
+ 'per_year' => '/jaar',
'workspaces_one' => 'Eén workspace',
'workspaces_unlimited' => 'Onbeperkte workspaces',
'workspaces_tooltip' => 'Een workspace is één merk of klant, gescheiden van de rest: met eigen social-media-accounts, handtekeningen, labels, analytics, ledenrechten en MCP-verbinding.',
@@ -33,7 +35,6 @@ return [
'select' => 'Kies :plan',
'upgrade' => 'Upgrade naar :plan',
'downgrade' => 'Downgrade naar :plan',
- 'start_first_month' => 'Activeer voor :price',
'billed_yearly_total' => 'Jaarlijks gefactureerd · :price (2 maanden gratis)',
'socials_tagline' => 'Ideaal voor creators en kleine merken.',
'workspaces_tagline' => 'Ideaal voor bureaus en grotere bedrijven.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Actief',
+ 'trial' => 'Gratis proefperiode',
+ 'cancelling' => 'Opgezegd',
+ 'past_due' => 'Achterstallig',
+ ],
'change' => 'Plan wijzigen',
- 'price_monthly' => ':price/maand',
- 'price_yearly' => ':price/jaar',
+ 'subscribe' => 'Nu abonneren',
'trial_until' => 'Proefperiode tot :date',
- 'renews' => 'Wordt automatisch verlengd',
'cancelled' => 'Opgezegd, eindigt op :date',
- 'workspaces_usage' => 'Workspaces: :count van :limit',
+ 'discount_until' => ':discount korting tot :date',
+ 'discount_forever' => ':discount korting op elke betaling',
+ 'discount_once' => ':discount korting op je volgende betaling',
],
'subscription' => [
- 'title' => 'Betaalmethode',
+ 'title' => 'Betaalmethoden',
+ 'default' => 'Standaard',
'description' => 'Werk je kaart of factuurgegevens bij in Stripe.',
'no_payment_method' => 'Nog geen betaalmethode geregistreerd.',
'expires_on' => 'Verloopt :month/:year',
'manage_stripe' => 'Beheren op Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Plan',
+ 'invoices' => 'Facturen',
+ ],
+
'invoices' => [
- 'title' => 'Facturen',
- 'description' => 'Download je eerdere facturen.',
+ 'columns' => [
+ 'date' => 'Datum',
+ 'amount' => 'Bedrag',
+ 'status' => 'Status',
+ ],
+ 'empty_title' => 'Nog geen facturen',
+ 'empty_description' => 'Je facturen verschijnen hier na je eerste betaling.',
'paid' => 'Betaald',
'download' => 'Factuur downloaden',
],
diff --git a/lang/nl/calendar.php b/lang/nl/calendar.php
index d30298224..24872bc09 100644
--- a/lang/nl/calendar.php
+++ b/lang/nl/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Kalender',
'today' => 'Vandaag',
diff --git a/lang/nl/create.php b/lang/nl/create.php
index 18f2928e5..67fa406de 100644
--- a/lang/nl/create.php
+++ b/lang/nl/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Maken',
'tabs' => [
diff --git a/lang/nl/integrations.php b/lang/nl/integrations.php
index 6dc0a398f..db17029d0 100644
--- a/lang/nl/integrations.php
+++ b/lang/nl/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Ontwerp ontvangen',
diff --git a/lang/nl/labels.php b/lang/nl/labels.php
index b65d7062c..8771cbefd 100644
--- a/lang/nl/labels.php
+++ b/lang/nl/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Labels',
'description' => 'Organiseer je posts met labels.',
diff --git a/lang/nl/notes.php b/lang/nl/notes.php
index 3a514083d..5ff503b32 100644
--- a/lang/nl/notes.php
+++ b/lang/nl/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Schrijf een notitie...',
'title' => 'Notities',
diff --git a/lang/nl/offers.php b/lang/nl/offers.php
new file mode 100644
index 000000000..a2f21f9df
--- /dev/null
+++ b/lang/nl/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50% korting de eerste 3 maanden',
+ 'price' => '$9.50',
+ 'unit' => '/maand',
+ 'period' => 'voor de eerste 3 maanden',
+ 'checkout_button' => 'Mijn account activeren',
+ ],
+ 'fm1' => [
+ 'name' => 'Eerste maand',
+ 'headline' => 'Je eerste maand voor $1',
+ 'price' => '$1',
+ 'period' => 'voor de eerste maand',
+ 'checkout_button' => 'Mijn account activeren',
+ ],
+ 'ft7d' => [
+ 'price' => 'Gratis',
+ 'period' => 'voor 7 dagen',
+ 'checkout_button' => 'Gratis proberen',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Gratis',
+ 'period' => 'voor 7 dagen',
+ 'checkout_button' => 'Gratis proberen',
+ 'terms' => 'Geen creditcard nodig',
+ ],
+];
diff --git a/lang/nl/pagination.php b/lang/nl/pagination.php
index 7382e2e8e..945fc9958 100644
--- a/lang/nl/pagination.php
+++ b/lang/nl/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/nl/passwords.php b/lang/nl/passwords.php
index 2d62deaad..9250238eb 100644
--- a/lang/nl/passwords.php
+++ b/lang/nl/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/nl/posts.php b/lang/nl/posts.php
index 835a33815..f8d434fab 100644
--- a/lang/nl/posts.php
+++ b/lang/nl/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Lijst',
'view_switcher' => 'Planningweergave',
diff --git a/lang/nl/settings.php b/lang/nl/settings.php
index 0117832d5..9e41ad354 100644
--- a/lang/nl/settings.php
+++ b/lang/nl/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Instellingen',
'description' => 'Beheer je profiel- en accountinstellingen',
diff --git a/lang/nl/signatures.php b/lang/nl/signatures.php
index 550f1ea73..11c95b0d3 100644
--- a/lang/nl/signatures.php
+++ b/lang/nl/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Handtekeningen',
'description' => 'Herbruikbare teksten voor je posts.',
diff --git a/lang/nl/template_library.php b/lang/nl/template_library.php
index bfb830554..f22b798a2 100644
--- a/lang/nl/template_library.php
+++ b/lang/nl/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'De oplossing van vijf minuten',
diff --git a/lang/nl/validation.php b/lang/nl/validation.php
index c36f3adc7..2a8e0f3bb 100644
--- a/lang/nl/validation.php
+++ b/lang/nl/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/nl/welcome.php b/lang/nl/welcome.php
index 3e26c19ee..fe7be179b 100644
--- a/lang/nl/welcome.php
+++ b/lang/nl/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Activeer je account',
'plan_description' => 'Koppel je kanalen en plan vandaag je eerste post.',
- 'plan_first_month' => 'voor de eerste maand',
- 'plan_terms' => 'Daarna :price/maand. Altijd opzegbaar.',
- 'plan_per_month' => 'per maand',
- 'plan_cancel_anytime' => 'Altijd opzegbaar.',
+ 'plan_terms' => 'Daarna :price/maand. Altijd opzegbaar',
+ 'plan_checkout_button' => 'Mijn account activeren',
+ 'plan_cancel_anytime' => 'Altijd opzegbaar',
'mcp' => [
'title' => 'Beheer je socials via chat',
'description' => 'Maak, plan en analyseer posts in TryPost met je favoriete AI.',
diff --git a/lang/pl/accounts.php b/lang/pl/accounts.php
index 76bd079f3..d9e05ec8c 100644
--- a/lang/pl/accounts.php
+++ b/lang/pl/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Połącz Bluesky',
diff --git a/lang/pl/analytics.php b/lang/pl/analytics.php
index fdefcc247..02549ecd4 100644
--- a/lang/pl/analytics.php
+++ b/lang/pl/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/pl/auth.php b/lang/pl/auth.php
index 247af01ec..398018429 100644
--- a/lang/pl/auth.php
+++ b/lang/pl/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pl/billing.php b/lang/pl/billing.php
index d9dc0a9d0..7813110ab 100644
--- a/lang/pl/billing.php
+++ b/lang/pl/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Rozliczenia',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Rozliczane miesięcznie',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Rocznie',
'save_two_months' => '2 miesiące gratis',
'per_month' => '/miesiąc',
+ 'per_year' => '/rok',
'workspaces_one' => 'Jeden workspace',
'workspaces_unlimited' => 'Nielimitowane workspace’y',
'workspaces_tooltip' => 'Workspace to jedna marka lub klient, oddzielony od pozostałych: własne konta społecznościowe, podpisy, etykiety, analityka, uprawnienia członków i połączenie MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Wybierz :plan',
'upgrade' => 'Przejdź na :plan',
'downgrade' => 'Zmień na :plan',
- 'start_first_month' => 'Aktywuj za :price',
'billed_yearly_total' => 'Rozliczane rocznie · :price (2 miesiące gratis)',
'socials_tagline' => 'Dla twórców i małych marek.',
'workspaces_tagline' => 'Dla agencji i większych firm.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Aktywny',
+ 'trial' => 'Okres próbny',
+ 'cancelling' => 'Anulowany',
+ 'past_due' => 'Zaległy',
+ ],
'change' => 'Zmień plan',
- 'price_monthly' => ':price/miesiąc',
- 'price_yearly' => ':price/rok',
+ 'subscribe' => 'Subskrybuj teraz',
'trial_until' => 'Okres próbny do :date',
- 'renews' => 'Odnawia się automatycznie',
'cancelled' => 'Anulowano, kończy się :date',
- 'workspaces_usage' => 'Workspace’y: :count z :limit',
+ 'discount_until' => 'Rabat :discount do :date',
+ 'discount_forever' => 'Rabat :discount na każdą płatność',
+ 'discount_once' => 'Rabat :discount na następną płatność',
],
'subscription' => [
- 'title' => 'Metoda płatności',
+ 'title' => 'Metody płatności',
+ 'default' => 'Domyślna',
'description' => 'Zaktualizuj kartę lub dane rozliczeniowe w Stripe.',
'no_payment_method' => 'Brak zapisanej metody płatności.',
'expires_on' => 'Wygasa :month/:year',
'manage_stripe' => 'Zarządzaj w Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Plan',
+ 'invoices' => 'Faktury',
+ ],
+
'invoices' => [
- 'title' => 'Faktury',
- 'description' => 'Pobierz swoje wcześniejsze faktury.',
+ 'columns' => [
+ 'date' => 'Data',
+ 'amount' => 'Kwota',
+ 'status' => 'Status',
+ ],
+ 'empty_title' => 'Brak faktur',
+ 'empty_description' => 'Faktury pojawią się tutaj po pierwszej płatności.',
'paid' => 'Opłacona',
'download' => 'Pobierz fakturę',
],
diff --git a/lang/pl/calendar.php b/lang/pl/calendar.php
index 555bb8f5f..0d7ed5b34 100644
--- a/lang/pl/calendar.php
+++ b/lang/pl/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Kalendarz',
'today' => 'Dziś',
diff --git a/lang/pl/create.php b/lang/pl/create.php
index f36fb4ab3..03a60db37 100644
--- a/lang/pl/create.php
+++ b/lang/pl/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Twórz',
'tabs' => [
diff --git a/lang/pl/integrations.php b/lang/pl/integrations.php
index 6c6afd1fe..85bc032a3 100644
--- a/lang/pl/integrations.php
+++ b/lang/pl/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Projekt odebrany',
diff --git a/lang/pl/labels.php b/lang/pl/labels.php
index 8c16db264..7bf57b909 100644
--- a/lang/pl/labels.php
+++ b/lang/pl/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Etykiety',
'description' => 'Porządkuj posty za pomocą etykiet.',
diff --git a/lang/pl/notes.php b/lang/pl/notes.php
index 24b1ed241..75b36d35e 100644
--- a/lang/pl/notes.php
+++ b/lang/pl/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Napisz notatkę...',
'title' => 'Notatki',
diff --git a/lang/pl/offers.php b/lang/pl/offers.php
new file mode 100644
index 000000000..d602252a2
--- /dev/null
+++ b/lang/pl/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50% zniżki przez pierwsze 3 miesiące',
+ 'price' => '$9.50',
+ 'unit' => '/miesiąc',
+ 'period' => 'przez pierwsze 3 miesiące',
+ 'checkout_button' => 'Aktywuj moje konto',
+ ],
+ 'fm1' => [
+ 'name' => 'Pierwszy miesiąc',
+ 'headline' => 'Pierwszy miesiąc za $1',
+ 'price' => '$1',
+ 'period' => 'za pierwszy miesiąc',
+ 'checkout_button' => 'Aktywuj moje konto',
+ ],
+ 'ft7d' => [
+ 'price' => 'Za darmo',
+ 'period' => 'przez 7 dni',
+ 'checkout_button' => 'Wypróbuj za darmo',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Za darmo',
+ 'period' => 'przez 7 dni',
+ 'checkout_button' => 'Wypróbuj za darmo',
+ 'terms' => 'Karta kredytowa nie jest wymagana',
+ ],
+];
diff --git a/lang/pl/pagination.php b/lang/pl/pagination.php
index 23f719602..b7088608d 100644
--- a/lang/pl/pagination.php
+++ b/lang/pl/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pl/passwords.php b/lang/pl/passwords.php
index ca55aa584..4576404e1 100644
--- a/lang/pl/passwords.php
+++ b/lang/pl/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pl/posts.php b/lang/pl/posts.php
index eb01b782a..f6d465d75 100644
--- a/lang/pl/posts.php
+++ b/lang/pl/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Lista',
'view_switcher' => 'Widok harmonogramu',
diff --git a/lang/pl/settings.php b/lang/pl/settings.php
index e1de1219b..1264ca063 100644
--- a/lang/pl/settings.php
+++ b/lang/pl/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Ustawienia',
'description' => 'Zarządzaj swoim profilem i ustawieniami konta',
diff --git a/lang/pl/signatures.php b/lang/pl/signatures.php
index fbaba9068..9adc86b21 100644
--- a/lang/pl/signatures.php
+++ b/lang/pl/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Sygnatury',
'description' => 'Teksty wielokrotnego użytku do postów.',
diff --git a/lang/pl/template_library.php b/lang/pl/template_library.php
index 405346b4a..0562b58ed 100644
--- a/lang/pl/template_library.php
+++ b/lang/pl/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'Poprawka na pięć minut',
diff --git a/lang/pl/validation.php b/lang/pl/validation.php
index 8a4a9e7c9..72bba9dc4 100644
--- a/lang/pl/validation.php
+++ b/lang/pl/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pl/welcome.php b/lang/pl/welcome.php
index a8d8f07f8..a52da0c29 100644
--- a/lang/pl/welcome.php
+++ b/lang/pl/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Aktywuj swoje konto',
'plan_description' => 'Połącz kanały i zaplanuj pierwszy post już dziś.',
- 'plan_first_month' => 'za pierwszy miesiąc',
- 'plan_terms' => 'Potem :price/mies. Anuluj w dowolnym momencie.',
- 'plan_per_month' => 'miesięcznie',
- 'plan_cancel_anytime' => 'Anuluj w dowolnym momencie.',
+ 'plan_terms' => 'Potem :price/mies. Anuluj w dowolnym momencie',
+ 'plan_checkout_button' => 'Aktywuj moje konto',
+ 'plan_cancel_anytime' => 'Anuluj w dowolnym momencie',
'mcp' => [
'title' => 'Zarządzaj social mediami w czacie',
'description' => 'Twórz, planuj i analizuj posty w TryPost z ulubioną AI.',
diff --git a/lang/pt-BR/accounts.php b/lang/pt-BR/accounts.php
index 048169011..ad477a084 100644
--- a/lang/pt-BR/accounts.php
+++ b/lang/pt-BR/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Conectar Bluesky',
diff --git a/lang/pt-BR/analytics.php b/lang/pt-BR/analytics.php
index 833322bba..1966d6bd8 100644
--- a/lang/pt-BR/analytics.php
+++ b/lang/pt-BR/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/pt-BR/auth.php b/lang/pt-BR/auth.php
index 29706785c..ead42e95d 100644
--- a/lang/pt-BR/auth.php
+++ b/lang/pt-BR/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pt-BR/billing.php b/lang/pt-BR/billing.php
index d40a2ec82..af2498cb8 100644
--- a/lang/pt-BR/billing.php
+++ b/lang/pt-BR/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Faturamento',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Cobrança mensal',
'prices' => [
- 'first_month' => 'R$ 1',
'socials' => ['monthly' => 'R$ 99', 'yearly_per_month' => 'R$ 82,50', 'yearly' => 'R$ 990'],
'workspaces' => ['monthly' => 'R$ 499', 'yearly_per_month' => 'R$ 415,83', 'yearly' => 'R$ 4.990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Anual',
'save_two_months' => '2 meses grátis',
'per_month' => '/mês',
+ 'per_year' => '/ano',
'workspaces_one' => 'Um workspace',
'workspaces_unlimited' => 'Workspaces ilimitados',
'workspaces_tooltip' => 'Um workspace é uma marca ou cliente, separado dos demais: com suas próprias redes sociais, assinaturas, labels, analytics, permissões de membros e conexão MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Escolher :plan',
'upgrade' => 'Fazer upgrade para :plan',
'downgrade' => 'Fazer downgrade para :plan',
- 'start_first_month' => 'Ativar por :price',
'billed_yearly_total' => 'Cobrança anual · :price (2 meses grátis)',
'socials_tagline' => 'Indicado para criadores e pequenas marcas.',
'workspaces_tagline' => 'Indicado para agências e grandes negócios.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Ativo',
+ 'trial' => 'Teste grátis',
+ 'cancelling' => 'Cancelado',
+ 'past_due' => 'Em atraso',
+ ],
'change' => 'Mudar plano',
- 'price_monthly' => ':price/mês',
- 'price_yearly' => ':price/ano',
- 'trial_until' => 'Trial até :date',
- 'renews' => 'Renova automaticamente',
+ 'subscribe' => 'Assinar agora',
+ 'trial_until' => 'Seu período de teste vai até :date',
'cancelled' => 'Cancelado, termina em :date',
- 'workspaces_usage' => 'Workspaces: :count de :limit',
+ 'discount_until' => ':discount de desconto até :date',
+ 'discount_forever' => ':discount de desconto em todos os pagamentos',
+ 'discount_once' => ':discount de desconto no próximo pagamento',
],
'subscription' => [
- 'title' => 'Método de pagamento',
+ 'title' => 'Métodos de pagamento',
+ 'default' => 'Padrão',
'description' => 'Atualize seu cartão ou dados de cobrança no Stripe.',
'no_payment_method' => 'Nenhum método de pagamento cadastrado.',
'expires_on' => 'Expira em :month/:year',
'manage_stripe' => 'Gerenciar no Stripe',
],
+ 'tabs' => [
+ 'plan' => 'Plano',
+ 'invoices' => 'Faturas',
+ ],
+
'invoices' => [
- 'title' => 'Faturas',
- 'description' => 'Baixe suas faturas anteriores.',
+ 'columns' => [
+ 'date' => 'Data',
+ 'amount' => 'Valor',
+ 'status' => 'Status',
+ ],
+ 'empty_title' => 'Nenhuma fatura ainda',
+ 'empty_description' => 'Suas faturas aparecem aqui depois do primeiro pagamento.',
'paid' => 'Pago',
'download' => 'Baixar fatura',
],
diff --git a/lang/pt-BR/calendar.php b/lang/pt-BR/calendar.php
index f9a551584..ae396dfb8 100644
--- a/lang/pt-BR/calendar.php
+++ b/lang/pt-BR/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Calendário',
'today' => 'Hoje',
diff --git a/lang/pt-BR/create.php b/lang/pt-BR/create.php
index c3f72f8eb..c87f19413 100644
--- a/lang/pt-BR/create.php
+++ b/lang/pt-BR/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Criar',
'tabs' => [
diff --git a/lang/pt-BR/integrations.php b/lang/pt-BR/integrations.php
index 1bc972181..ce9a8f65f 100644
--- a/lang/pt-BR/integrations.php
+++ b/lang/pt-BR/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Design recebido',
diff --git a/lang/pt-BR/labels.php b/lang/pt-BR/labels.php
index 4eb08f515..2ea306beb 100644
--- a/lang/pt-BR/labels.php
+++ b/lang/pt-BR/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Etiquetas',
'description' => 'Organize e filtre seus posts com etiquetas.',
diff --git a/lang/pt-BR/offers.php b/lang/pt-BR/offers.php
new file mode 100644
index 000000000..77a2c0eb6
--- /dev/null
+++ b/lang/pt-BR/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => '50% de desconto nos 3 primeiros meses',
+ 'price' => 'R$ 49,50',
+ 'unit' => '/mês',
+ 'period' => 'nos 3 primeiros meses',
+ 'checkout_button' => 'Ativar minha conta',
+ ],
+ 'fm1' => [
+ 'name' => 'Primeiro mês',
+ 'headline' => 'Seu primeiro mês por R$ 1',
+ 'price' => 'R$ 1',
+ 'period' => 'no primeiro mês',
+ 'checkout_button' => 'Ativar minha conta',
+ ],
+ 'ft7d' => [
+ 'price' => 'Grátis',
+ 'period' => 'por 7 dias',
+ 'checkout_button' => 'Começar teste grátis',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Grátis',
+ 'period' => 'por 7 dias',
+ 'checkout_button' => 'Começar teste grátis',
+ 'terms' => 'Sem cartão de crédito',
+ ],
+];
diff --git a/lang/pt-BR/pagination.php b/lang/pt-BR/pagination.php
index 4deabd6fb..4b1cc5f31 100644
--- a/lang/pt-BR/pagination.php
+++ b/lang/pt-BR/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pt-BR/passwords.php b/lang/pt-BR/passwords.php
index 600b63b89..e1b2cacc7 100644
--- a/lang/pt-BR/passwords.php
+++ b/lang/pt-BR/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pt-BR/posts.php b/lang/pt-BR/posts.php
index 65df7297d..9c309765a 100644
--- a/lang/pt-BR/posts.php
+++ b/lang/pt-BR/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Lista',
'view_switcher' => 'Visualização do agendamento',
diff --git a/lang/pt-BR/settings.php b/lang/pt-BR/settings.php
index 94937cbcc..b088035d8 100644
--- a/lang/pt-BR/settings.php
+++ b/lang/pt-BR/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Configurações',
'description' => 'Gerencie seu perfil e configurações da conta',
diff --git a/lang/pt-BR/signatures.php b/lang/pt-BR/signatures.php
index 2a88eba65..9fb34c560 100644
--- a/lang/pt-BR/signatures.php
+++ b/lang/pt-BR/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Assinaturas',
'description' => 'Textos reutilizáveis para seus posts.',
diff --git a/lang/pt-BR/template_library.php b/lang/pt-BR/template_library.php
index c6fa5e419..cffad25ad 100644
--- a/lang/pt-BR/template_library.php
+++ b/lang/pt-BR/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'A correção de cinco minutos',
diff --git a/lang/pt-BR/validation.php b/lang/pt-BR/validation.php
index 05d4442ed..f235868be 100644
--- a/lang/pt-BR/validation.php
+++ b/lang/pt-BR/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/pt-BR/welcome.php b/lang/pt-BR/welcome.php
index b74768449..4e21e5b49 100644
--- a/lang/pt-BR/welcome.php
+++ b/lang/pt-BR/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Ative sua conta',
'plan_description' => 'Conecte suas redes e agende seu primeiro post hoje.',
- 'plan_first_month' => 'no primeiro mês',
- 'plan_terms' => 'Depois, :price/mês. Cancele quando quiser.',
- 'plan_per_month' => 'por mês',
- 'plan_cancel_anytime' => 'Cancele quando quiser.',
+ 'plan_terms' => 'Depois, :price/mês. Cancele quando quiser',
+ 'plan_checkout_button' => 'Ativar minha conta',
+ 'plan_cancel_anytime' => 'Cancele quando quiser',
'mcp' => [
'title' => 'Gerencie suas redes pelo chat',
'description' => 'Crie, agende e analise posts no TryPost usando a sua IA favorita.',
diff --git a/lang/ru/accounts.php b/lang/ru/accounts.php
index a5d7a24d5..a1a40ccae 100644
--- a/lang/ru/accounts.php
+++ b/lang/ru/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Подключить Bluesky',
diff --git a/lang/ru/analytics.php b/lang/ru/analytics.php
index 46725fbb7..3f74660b8 100644
--- a/lang/ru/analytics.php
+++ b/lang/ru/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/ru/auth.php b/lang/ru/auth.php
index cb16bd430..253e16de4 100644
--- a/lang/ru/auth.php
+++ b/lang/ru/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ru/billing.php b/lang/ru/billing.php
index e71de5e79..504a65efe 100644
--- a/lang/ru/billing.php
+++ b/lang/ru/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Оплата',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Ежемесячная оплата',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Ежегодно',
'save_two_months' => '2 месяца бесплатно',
'per_month' => '/месяц',
+ 'per_year' => '/год',
'workspaces_one' => 'Один workspace',
'workspaces_unlimited' => 'Неограниченное число workspace',
'workspaces_tooltip' => 'Workspace — это один бренд или клиент, отделённый от остальных: свои соцсети, подписи, метки, аналитика, права участников и подключение MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Выбрать :plan',
'upgrade' => 'Перейти на :plan',
'downgrade' => 'Понизить до :plan',
- 'start_first_month' => 'Активировать за :price',
'billed_yearly_total' => 'Оплата раз в год · :price (2 месяца бесплатно)',
'socials_tagline' => 'Для авторов и небольших брендов.',
'workspaces_tagline' => 'Для агентств и крупного бизнеса.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Активен',
+ 'trial' => 'Пробный период',
+ 'cancelling' => 'Отменён',
+ 'past_due' => 'Просрочен',
+ ],
'change' => 'Сменить план',
- 'price_monthly' => ':price/месяц',
- 'price_yearly' => ':price/год',
+ 'subscribe' => 'Оформить подписку',
'trial_until' => 'Пробный период до :date',
- 'renews' => 'Продлевается автоматически',
'cancelled' => 'Отменён, действует до :date',
- 'workspaces_usage' => 'Рабочие пространства: :count из :limit',
+ 'discount_until' => 'Скидка :discount до :date',
+ 'discount_forever' => 'Скидка :discount на каждый платёж',
+ 'discount_once' => 'Скидка :discount на следующий платёж',
],
'subscription' => [
- 'title' => 'Способ оплаты',
+ 'title' => 'Способы оплаты',
+ 'default' => 'Основная',
'description' => 'Обновите карту или платёжные данные в Stripe.',
'no_payment_method' => 'Способ оплаты пока не добавлен.',
'expires_on' => 'Истекает :month/:year',
'manage_stripe' => 'Управлять в Stripe',
],
+ 'tabs' => [
+ 'plan' => 'План',
+ 'invoices' => 'Счета',
+ ],
+
'invoices' => [
- 'title' => 'Счета',
- 'description' => 'Скачивайте прошлые счета.',
+ 'columns' => [
+ 'date' => 'Дата',
+ 'amount' => 'Сумма',
+ 'status' => 'Статус',
+ ],
+ 'empty_title' => 'Счетов пока нет',
+ 'empty_description' => 'Счета появятся здесь после первой оплаты.',
'paid' => 'Оплачено',
'download' => 'Скачать счёт',
],
diff --git a/lang/ru/calendar.php b/lang/ru/calendar.php
index 1fa803d50..b239fdf6d 100644
--- a/lang/ru/calendar.php
+++ b/lang/ru/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Календарь',
'today' => 'Сегодня',
diff --git a/lang/ru/create.php b/lang/ru/create.php
index dbb8a35e4..0323cc348 100644
--- a/lang/ru/create.php
+++ b/lang/ru/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Создание',
'tabs' => [
diff --git a/lang/ru/integrations.php b/lang/ru/integrations.php
index 67ca93c5f..666088500 100644
--- a/lang/ru/integrations.php
+++ b/lang/ru/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Дизайн получен',
diff --git a/lang/ru/labels.php b/lang/ru/labels.php
index de737e91b..3f4bfc7e7 100644
--- a/lang/ru/labels.php
+++ b/lang/ru/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Метки',
'description' => 'Упорядочивайте посты с помощью меток.',
diff --git a/lang/ru/notes.php b/lang/ru/notes.php
index 7e3313e9b..99a23500b 100644
--- a/lang/ru/notes.php
+++ b/lang/ru/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Напишите заметку...',
'title' => 'Заметки',
diff --git a/lang/ru/offers.php b/lang/ru/offers.php
new file mode 100644
index 000000000..9990f9854
--- /dev/null
+++ b/lang/ru/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Чёрная пятница',
+ 'headline' => 'Скидка 50% на первые 3 месяца',
+ 'price' => '$9.50',
+ 'unit' => '/месяц',
+ 'period' => 'за первые 3 месяца',
+ 'checkout_button' => 'Активировать мой аккаунт',
+ ],
+ 'fm1' => [
+ 'name' => 'Первый месяц',
+ 'headline' => 'Первый месяц за $1',
+ 'price' => '$1',
+ 'period' => 'за первый месяц',
+ 'checkout_button' => 'Активировать мой аккаунт',
+ ],
+ 'ft7d' => [
+ 'price' => 'Бесплатно',
+ 'period' => 'на 7 дней',
+ 'checkout_button' => 'Начать бесплатно',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Бесплатно',
+ 'period' => 'на 7 дней',
+ 'checkout_button' => 'Начать бесплатно',
+ 'terms' => 'Кредитная карта не нужна',
+ ],
+];
diff --git a/lang/ru/pagination.php b/lang/ru/pagination.php
index 9621a8ac8..5ead3b07a 100644
--- a/lang/ru/pagination.php
+++ b/lang/ru/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ru/passwords.php b/lang/ru/passwords.php
index b1cc044cf..0760ca7d7 100644
--- a/lang/ru/passwords.php
+++ b/lang/ru/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ru/posts.php b/lang/ru/posts.php
index 8f6df080e..881163038 100644
--- a/lang/ru/posts.php
+++ b/lang/ru/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Список',
'view_switcher' => 'Вид расписания',
diff --git a/lang/ru/settings.php b/lang/ru/settings.php
index decc71503..cb1b8f61a 100644
--- a/lang/ru/settings.php
+++ b/lang/ru/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Настройки',
'description' => 'Управляйте профилем и настройками аккаунта',
diff --git a/lang/ru/signatures.php b/lang/ru/signatures.php
index 206d08a9b..05356dcca 100644
--- a/lang/ru/signatures.php
+++ b/lang/ru/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Подписи',
'description' => 'Готовые тексты для ваших постов.',
diff --git a/lang/ru/template_library.php b/lang/ru/template_library.php
index b212a3c82..ca5c039c5 100644
--- a/lang/ru/template_library.php
+++ b/lang/ru/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'Решение за пять минут',
diff --git a/lang/ru/validation.php b/lang/ru/validation.php
index b879a1073..ecb285fcf 100644
--- a/lang/ru/validation.php
+++ b/lang/ru/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/ru/welcome.php b/lang/ru/welcome.php
index b7d40d03b..2f21a674e 100644
--- a/lang/ru/welcome.php
+++ b/lang/ru/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Активируйте аккаунт',
'plan_description' => 'Подключите каналы и запланируйте первый пост уже сегодня.',
- 'plan_first_month' => 'за первый месяц',
- 'plan_terms' => 'Затем :price/мес. Отмена в любой момент.',
- 'plan_per_month' => 'в месяц',
- 'plan_cancel_anytime' => 'Отмена в любой момент.',
+ 'plan_terms' => 'Затем :price/мес. Отмена в любой момент',
+ 'plan_checkout_button' => 'Активировать мой аккаунт',
+ 'plan_cancel_anytime' => 'Отмена в любой момент',
'mcp' => [
'title' => 'Ведите соцсети прямо в чате',
'description' => 'Создавайте, планируйте и анализируйте посты в TryPost с любимым ИИ.',
diff --git a/lang/tr/billing.php b/lang/tr/billing.php
index 74b3c4e94..e867dc2f2 100644
--- a/lang/tr/billing.php
+++ b/lang/tr/billing.php
@@ -14,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Aylık faturalandırılır',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -26,6 +25,7 @@ return [
'yearly' => 'Yıllık',
'save_two_months' => '2 ay ücretsiz',
'per_month' => '/ay',
+ 'per_year' => '/yıl',
'workspaces_one' => 'Bir workspace',
'workspaces_unlimited' => 'Sınırsız workspace',
'workspaces_tooltip' => 'Workspace, diğerlerinden ayrı tutulan tek bir marka veya müşteridir: kendi sosyal medya hesapları, imzaları, etiketleri, analizleri, üye izinleri ve MCP bağlantısı vardır.',
@@ -35,7 +35,6 @@ return [
'select' => ':plan seç',
'upgrade' => ':plan’e yükselt',
'downgrade' => ':plan’e düşür',
- 'start_first_month' => ':price ile etkinleştir',
'billed_yearly_total' => 'Yıllık faturalandırılır · :price (2 ay bedava)',
'socials_tagline' => 'İçerik üreticileri ve küçük markalar için.',
'workspaces_tagline' => 'Ajanslar ve büyük işletmeler için.',
@@ -63,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Aktif',
+ 'trial' => 'Ücretsiz deneme',
+ 'cancelling' => 'İptal edildi',
+ 'past_due' => 'Gecikmiş',
+ ],
'change' => 'Planı değiştir',
- 'price_monthly' => ':price/ay',
- 'price_yearly' => ':price/yıl',
+ 'subscribe' => 'Şimdi abone ol',
'trial_until' => ':date tarihine kadar deneme',
- 'renews' => 'Otomatik olarak yenilenir',
'cancelled' => 'İptal edildi, :date tarihinde sona erer',
- 'workspaces_usage' => 'Çalışma alanları: :count / :limit',
+ 'discount_until' => ':date tarihine kadar :discount indirim',
+ 'discount_forever' => 'Her ödemede :discount indirim',
+ 'discount_once' => 'Sonraki ödemenizde :discount indirim',
],
'subscription' => [
- 'title' => 'Ödeme yöntemi',
+ 'title' => 'Ödeme yöntemleri',
+ 'default' => 'Varsayılan',
'description' => 'Kartınızı veya fatura bilgilerinizi Stripe’da güncelleyin.',
'no_payment_method' => 'Henüz kayıtlı ödeme yöntemi yok.',
'expires_on' => 'Son kullanma: :month/:year',
'manage_stripe' => 'Stripe\'ta yönet',
],
+ 'tabs' => [
+ 'plan' => 'Plan',
+ 'invoices' => 'Faturalar',
+ ],
+
'invoices' => [
- 'title' => 'Faturalar',
- 'description' => 'Geçmiş faturalarınızı indirin.',
+ 'columns' => [
+ 'date' => 'Tarih',
+ 'amount' => 'Tutar',
+ 'status' => 'Durum',
+ ],
+ 'empty_title' => 'Henüz fatura yok',
+ 'empty_description' => 'Faturalarınız ilk ödemenizden sonra burada görünür.',
'paid' => 'Ödendi',
'download' => 'Faturayı indir',
],
diff --git a/lang/tr/create.php b/lang/tr/create.php
index 16850cc7c..a44d28966 100644
--- a/lang/tr/create.php
+++ b/lang/tr/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Oluştur',
'tabs' => [
diff --git a/lang/tr/integrations.php b/lang/tr/integrations.php
index d1ca11bed..4cd408fa3 100644
--- a/lang/tr/integrations.php
+++ b/lang/tr/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Tasarım alındı',
diff --git a/lang/tr/offers.php b/lang/tr/offers.php
new file mode 100644
index 000000000..45569eeb0
--- /dev/null
+++ b/lang/tr/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Black Friday',
+ 'headline' => 'İlk 3 ayda %50 indirim',
+ 'price' => '$9.50',
+ 'unit' => '/ay',
+ 'period' => 'ilk 3 ay için',
+ 'checkout_button' => 'Hesabımı etkinleştir',
+ ],
+ 'fm1' => [
+ 'name' => 'İlk ay',
+ 'headline' => 'İlk ayın $1',
+ 'price' => '$1',
+ 'period' => 'ilk ay için',
+ 'checkout_button' => 'Hesabımı etkinleştir',
+ ],
+ 'ft7d' => [
+ 'price' => 'Ücretsiz',
+ 'period' => '7 gün boyunca',
+ 'checkout_button' => 'Ücretsiz dene',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Ücretsiz',
+ 'period' => '7 gün boyunca',
+ 'checkout_button' => 'Ücretsiz dene',
+ 'terms' => 'Kredi kartı gerekmez',
+ ],
+];
diff --git a/lang/tr/template_library.php b/lang/tr/template_library.php
index cdb496d0f..94ef6356a 100644
--- a/lang/tr/template_library.php
+++ b/lang/tr/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'Beş dakikalık çözüm',
diff --git a/lang/tr/welcome.php b/lang/tr/welcome.php
index 1690b068c..b240fd6aa 100644
--- a/lang/tr/welcome.php
+++ b/lang/tr/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Hesabını etkinleştir',
'plan_description' => 'Kanallarını bağla ve ilk gönderini bugün planla.',
- 'plan_first_month' => 'ilk ay için',
- 'plan_terms' => 'Sonra :price/ay. İstediğin zaman iptal et.',
- 'plan_per_month' => 'aylık',
- 'plan_cancel_anytime' => 'İstediğin zaman iptal et.',
+ 'plan_terms' => 'Sonra :price/ay. İstediğin zaman iptal et',
+ 'plan_checkout_button' => 'Hesabımı etkinleştir',
+ 'plan_cancel_anytime' => 'İstediğin zaman iptal et',
'mcp' => [
'title' => 'Sosyal medyanı sohbetle yönet',
'description' => 'TryPost’ta gönderilerini favori yapay zekânla oluştur, planla ve analiz et.',
diff --git a/lang/uk/accounts.php b/lang/uk/accounts.php
index 1f33f437c..c07b6151a 100644
--- a/lang/uk/accounts.php
+++ b/lang/uk/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => 'Підключити Bluesky',
diff --git a/lang/uk/analytics.php b/lang/uk/analytics.php
index fd38f3266..f04032541 100644
--- a/lang/uk/analytics.php
+++ b/lang/uk/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/uk/auth.php b/lang/uk/auth.php
index ff30a80ee..eef47c757 100644
--- a/lang/uk/auth.php
+++ b/lang/uk/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/uk/billing.php b/lang/uk/billing.php
index c08f1b033..292f250f1 100644
--- a/lang/uk/billing.php
+++ b/lang/uk/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Оплата',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => 'Щомісячна оплата',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => 'Щороку',
'save_two_months' => '2 місяці безкоштовно',
'per_month' => '/місяць',
+ 'per_year' => '/рік',
'workspaces_one' => 'Один workspace',
'workspaces_unlimited' => 'Необмежена кількість workspace',
'workspaces_tooltip' => 'Workspace — це один бренд або клієнт, відокремлений від інших: власні соцмережі, підписи, мітки, аналітика, права учасників і підключення MCP.',
@@ -33,7 +35,6 @@ return [
'select' => 'Обрати :plan',
'upgrade' => 'Перейти на :plan',
'downgrade' => 'Понизити до :plan',
- 'start_first_month' => 'Активувати за :price',
'billed_yearly_total' => 'Оплата раз на рік · :price (2 місяці безкоштовно)',
'socials_tagline' => 'Для авторів і невеликих брендів.',
'workspaces_tagline' => 'Для агентств і великого бізнесу.',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => 'Активний',
+ 'trial' => 'Пробний період',
+ 'cancelling' => 'Скасовано',
+ 'past_due' => 'Прострочено',
+ ],
'change' => 'Змінити план',
- 'price_monthly' => ':price/місяць',
- 'price_yearly' => ':price/рік',
+ 'subscribe' => 'Оформити підписку',
'trial_until' => 'Пробний період до :date',
- 'renews' => 'Поновлюється автоматично',
'cancelled' => 'Скасовано, діє до :date',
- 'workspaces_usage' => 'Робочі простори: :count з :limit',
+ 'discount_until' => 'Знижка :discount до :date',
+ 'discount_forever' => 'Знижка :discount на кожен платіж',
+ 'discount_once' => 'Знижка :discount на наступний платіж',
],
'subscription' => [
- 'title' => 'Спосіб оплати',
+ 'title' => 'Способи оплати',
+ 'default' => 'Основна',
'description' => 'Оновіть картку або платіжні дані в Stripe.',
'no_payment_method' => 'Спосіб оплати ще не додано.',
'expires_on' => 'Діє до :month/:year',
'manage_stripe' => 'Керувати в Stripe',
],
+ 'tabs' => [
+ 'plan' => 'План',
+ 'invoices' => 'Рахунки',
+ ],
+
'invoices' => [
- 'title' => 'Рахунки',
- 'description' => 'Завантажуйте минулі рахунки.',
+ 'columns' => [
+ 'date' => 'Дата',
+ 'amount' => 'Сума',
+ 'status' => 'Статус',
+ ],
+ 'empty_title' => 'Рахунків поки немає',
+ 'empty_description' => 'Рахунки з’являться тут після першої оплати.',
'paid' => 'Оплачено',
'download' => 'Завантажити рахунок',
],
diff --git a/lang/uk/calendar.php b/lang/uk/calendar.php
index 08beceebd..3c63cf5c9 100644
--- a/lang/uk/calendar.php
+++ b/lang/uk/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Календар',
'today' => 'Сьогодні',
diff --git a/lang/uk/create.php b/lang/uk/create.php
index 459045566..5bc645326 100644
--- a/lang/uk/create.php
+++ b/lang/uk/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Створення',
'tabs' => [
diff --git a/lang/uk/integrations.php b/lang/uk/integrations.php
index a3146cef7..864b8aacf 100644
--- a/lang/uk/integrations.php
+++ b/lang/uk/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => 'Дизайн отримано',
diff --git a/lang/uk/labels.php b/lang/uk/labels.php
index 88ae40f18..16fd63130 100644
--- a/lang/uk/labels.php
+++ b/lang/uk/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Мітки',
'description' => 'Упорядковуйте дописи за допомогою міток.',
diff --git a/lang/uk/notes.php b/lang/uk/notes.php
index 959964ecf..fedb280ed 100644
--- a/lang/uk/notes.php
+++ b/lang/uk/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => 'Напишіть нотатку...',
'title' => 'Нотатки',
diff --git a/lang/uk/offers.php b/lang/uk/offers.php
new file mode 100644
index 000000000..aad271cc4
--- /dev/null
+++ b/lang/uk/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => 'Чорна пʼятниця',
+ 'headline' => 'Знижка 50% на перші 3 місяці',
+ 'price' => '$9.50',
+ 'unit' => '/місяць',
+ 'period' => 'за перші 3 місяці',
+ 'checkout_button' => 'Активувати мій акаунт',
+ ],
+ 'fm1' => [
+ 'name' => 'Перший місяць',
+ 'headline' => 'Перший місяць за $1',
+ 'price' => '$1',
+ 'period' => 'за перший місяць',
+ 'checkout_button' => 'Активувати мій акаунт',
+ ],
+ 'ft7d' => [
+ 'price' => 'Безкоштовно',
+ 'period' => 'на 7 днів',
+ 'checkout_button' => 'Почати безкоштовно',
+ ],
+ 'ft7dnc' => [
+ 'price' => 'Безкоштовно',
+ 'period' => 'на 7 днів',
+ 'checkout_button' => 'Почати безкоштовно',
+ 'terms' => 'Кредитна картка не потрібна',
+ ],
+];
diff --git a/lang/uk/pagination.php b/lang/uk/pagination.php
index 54e5a82b5..16d75f160 100644
--- a/lang/uk/pagination.php
+++ b/lang/uk/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/uk/passwords.php b/lang/uk/passwords.php
index ed9b73940..04b2478d4 100644
--- a/lang/uk/passwords.php
+++ b/lang/uk/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/uk/posts.php b/lang/uk/posts.php
index 431d5574e..fc7d746c8 100644
--- a/lang/uk/posts.php
+++ b/lang/uk/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => 'Список',
'view_switcher' => 'Перегляд розкладу',
diff --git a/lang/uk/settings.php b/lang/uk/settings.php
index 986e8b588..38969a319 100644
--- a/lang/uk/settings.php
+++ b/lang/uk/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Налаштування',
'description' => 'Керуйте профілем та налаштуваннями облікового запису',
diff --git a/lang/uk/signatures.php b/lang/uk/signatures.php
index adb3eae20..c8aaeea74 100644
--- a/lang/uk/signatures.php
+++ b/lang/uk/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Підписи',
'description' => 'Готові тексти для ваших дописів.',
diff --git a/lang/uk/template_library.php b/lang/uk/template_library.php
index 040e1c712..8819ac64e 100644
--- a/lang/uk/template_library.php
+++ b/lang/uk/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => 'Рішення за п\'ять хвилин',
diff --git a/lang/uk/validation.php b/lang/uk/validation.php
index 310c8aae0..32788b507 100644
--- a/lang/uk/validation.php
+++ b/lang/uk/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/uk/welcome.php b/lang/uk/welcome.php
index 135b45ee2..571bf0f57 100644
--- a/lang/uk/welcome.php
+++ b/lang/uk/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => 'Активуйте акаунт',
'plan_description' => 'Підключіть канали та заплануйте перший пост уже сьогодні.',
- 'plan_first_month' => 'за перший місяць',
- 'plan_terms' => 'Потім :price/міс. Скасування будь-коли.',
- 'plan_per_month' => 'на місяць',
- 'plan_cancel_anytime' => 'Скасування будь-коли.',
+ 'plan_terms' => 'Потім :price/міс. Скасування будь-коли',
+ 'plan_checkout_button' => 'Активувати мій акаунт',
+ 'plan_cancel_anytime' => 'Скасування будь-коли',
'mcp' => [
'title' => 'Ведіть соцмережі просто в чаті',
'description' => 'Створюйте, плануйте й аналізуйте дописи в TryPost з улюбленим ШІ.',
diff --git a/lang/zh/accounts.php b/lang/zh/accounts.php
index 10230f0e2..3321f49b3 100644
--- a/lang/zh/accounts.php
+++ b/lang/zh/accounts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'bluesky' => [
'title' => '连接 Bluesky',
diff --git a/lang/zh/analytics.php b/lang/zh/analytics.php
index 6563af765..c07181955 100644
--- a/lang/zh/analytics.php
+++ b/lang/zh/analytics.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => 'Insights',
'detail' => [
diff --git a/lang/zh/auth.php b/lang/zh/auth.php
index d0c736614..402243bcc 100644
--- a/lang/zh/auth.php
+++ b/lang/zh/auth.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/zh/billing.php b/lang/zh/billing.php
index 0c9e8620f..c9f7fe2e8 100644
--- a/lang/zh/billing.php
+++ b/lang/zh/billing.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '账单',
@@ -12,7 +14,6 @@ return [
'subscribe' => [
'billed_monthly' => '按月计费',
'prices' => [
- 'first_month' => '$1',
'socials' => ['monthly' => '$19', 'yearly_per_month' => '$15.83', 'yearly' => '$190'],
'workspaces' => ['monthly' => '$99', 'yearly_per_month' => '$82.50', 'yearly' => '$990'],
],
@@ -24,6 +25,7 @@ return [
'yearly' => '按年',
'save_two_months' => '免两个月',
'per_month' => '/月',
+ 'per_year' => '/年',
'workspaces_one' => '一个工作区',
'workspaces_unlimited' => '无限工作区',
'workspaces_tooltip' => '一个工作区对应一个品牌或客户,与其他工作区相互隔离:拥有自己的社交账号、签名、标签、数据分析、成员权限和 MCP 连接。',
@@ -33,7 +35,6 @@ return [
'select' => '选择 :plan',
'upgrade' => '升级到 :plan',
'downgrade' => '降级到 :plan',
- 'start_first_month' => '以 :price 激活',
'billed_yearly_total' => '按年计费 · :price(免两个月)',
'socials_tagline' => '适合创作者和小品牌。',
'workspaces_tagline' => '适合代理商和大型业务。',
@@ -61,26 +62,43 @@ return [
],
'current_plan' => [
+ 'statuses' => [
+ 'active' => '生效中',
+ 'trial' => '免费试用',
+ 'cancelling' => '已取消',
+ 'past_due' => '已逾期',
+ ],
'change' => '更改套餐',
- 'price_monthly' => ':price/月',
- 'price_yearly' => ':price/年',
+ 'subscribe' => '立即订阅',
'trial_until' => '试用至 :date',
- 'renews' => '自动续订',
'cancelled' => '已取消,将于 :date 结束',
- 'workspaces_usage' => '工作区::count / :limit',
+ 'discount_until' => '优惠 :discount,截至 :date',
+ 'discount_forever' => '每次付款优惠 :discount',
+ 'discount_once' => '下次付款优惠 :discount',
],
'subscription' => [
'title' => '付款方式',
+ 'default' => '默认',
'description' => '在 Stripe 更新你的卡片或账单信息。',
'no_payment_method' => '尚未添加付款方式。',
'expires_on' => '有效期至 :month/:year',
'manage_stripe' => '在 Stripe 上管理',
],
+ 'tabs' => [
+ 'plan' => '套餐',
+ 'invoices' => '发票',
+ ],
+
'invoices' => [
- 'title' => '发票',
- 'description' => '下载你过往的发票。',
+ 'columns' => [
+ 'date' => '日期',
+ 'amount' => '金额',
+ 'status' => '状态',
+ ],
+ 'empty_title' => '暂无发票',
+ 'empty_description' => '首次付款后,你的发票会显示在这里。',
'paid' => '已支付',
'download' => '下载发票',
],
diff --git a/lang/zh/calendar.php b/lang/zh/calendar.php
index 2989816b3..b6030e023 100644
--- a/lang/zh/calendar.php
+++ b/lang/zh/calendar.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '日历',
'today' => '今天',
diff --git a/lang/zh/create.php b/lang/zh/create.php
index 31b306120..6a39c773d 100644
--- a/lang/zh/create.php
+++ b/lang/zh/create.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '创建',
'tabs' => [
diff --git a/lang/zh/integrations.php b/lang/zh/integrations.php
index a5c1ae1c5..64a7207bb 100644
--- a/lang/zh/integrations.php
+++ b/lang/zh/integrations.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'media_source_popup' => [
'title_success' => '已收到设计',
diff --git a/lang/zh/labels.php b/lang/zh/labels.php
index 22c7c1f0a..6ce49f026 100644
--- a/lang/zh/labels.php
+++ b/lang/zh/labels.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '标签',
'description' => '用标签整理你的帖子。',
diff --git a/lang/zh/notes.php b/lang/zh/notes.php
index 5f019db3b..1746ee29c 100644
--- a/lang/zh/notes.php
+++ b/lang/zh/notes.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'placeholder' => '写下备注…',
'title' => '备注',
diff --git a/lang/zh/offers.php b/lang/zh/offers.php
new file mode 100644
index 000000000..7976001b8
--- /dev/null
+++ b/lang/zh/offers.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+return [
+ 'bf26' => [
+ 'name' => '黑色星期五',
+ 'headline' => '前 3 个月 5 折',
+ 'price' => '$9.50',
+ 'unit' => '/月',
+ 'period' => '前 3 个月',
+ 'checkout_button' => '激活我的账户',
+ ],
+ 'fm1' => [
+ 'name' => '首月',
+ 'headline' => '首月仅需 $1',
+ 'price' => '$1',
+ 'period' => '首月价格',
+ 'checkout_button' => '激活我的账户',
+ ],
+ 'ft7d' => [
+ 'price' => '免费',
+ 'period' => '7 天内',
+ 'checkout_button' => '开始免费试用',
+ ],
+ 'ft7dnc' => [
+ 'price' => '免费',
+ 'period' => '7 天内',
+ 'checkout_button' => '开始免费试用',
+ 'terms' => '无需信用卡',
+ ],
+];
diff --git a/lang/zh/pagination.php b/lang/zh/pagination.php
index 4e8dea7c7..fdb1a2a35 100644
--- a/lang/zh/pagination.php
+++ b/lang/zh/pagination.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/zh/passwords.php b/lang/zh/passwords.php
index 5a8effa65..06668d3cc 100644
--- a/lang/zh/passwords.php
+++ b/lang/zh/passwords.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/zh/posts.php b/lang/zh/posts.php
index f5e33de90..8540b5e1a 100644
--- a/lang/zh/posts.php
+++ b/lang/zh/posts.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'list_view' => '列表',
'view_switcher' => '日程视图',
diff --git a/lang/zh/settings.php b/lang/zh/settings.php
index 528369312..2ad7a5506 100644
--- a/lang/zh/settings.php
+++ b/lang/zh/settings.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '设置',
'description' => '管理你的个人资料和账户设置',
diff --git a/lang/zh/signatures.php b/lang/zh/signatures.php
index 6f6f6d09d..650335c7b 100644
--- a/lang/zh/signatures.php
+++ b/lang/zh/signatures.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'title' => '签名',
'description' => '可重复添加到帖子的文本。',
diff --git a/lang/zh/template_library.php b/lang/zh/template_library.php
index 768c60c93..1d2e5c4de 100644
--- a/lang/zh/template_library.php
+++ b/lang/zh/template_library.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
'quick_win' => [
'title' => '五分钟搞定的小改进',
diff --git a/lang/zh/validation.php b/lang/zh/validation.php
index ea2e2e700..3eafbd5c0 100644
--- a/lang/zh/validation.php
+++ b/lang/zh/validation.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
return [
/*
diff --git a/lang/zh/welcome.php b/lang/zh/welcome.php
index dfb4d08ab..781e36058 100644
--- a/lang/zh/welcome.php
+++ b/lang/zh/welcome.php
@@ -47,10 +47,9 @@ return [
],
'plan_title' => '激活你的账户',
'plan_description' => '连接你的账号,今天就排期第一条帖子。',
- 'plan_first_month' => '首月价格',
- 'plan_terms' => '之后 :price/月,随时取消。',
- 'plan_per_month' => '每月',
- 'plan_cancel_anytime' => '随时取消。',
+ 'plan_terms' => '之后 :price/月,随时取消',
+ 'plan_checkout_button' => '激活我的账户',
+ 'plan_cancel_anytime' => '随时取消',
'mcp' => [
'title' => '和 AI 聊天,轻松管理社交媒体',
'description' => '用你最喜欢的 AI,在 TryPost 中创建、排期和分析帖子。',
diff --git a/pint.json b/pint.json
index 93061b6bd..4b4f9409a 100644
--- a/pint.json
+++ b/pint.json
@@ -1,3 +1,6 @@
{
- "preset": "laravel"
+ "preset": "laravel",
+ "rules": {
+ "declare_strict_types": true
+ }
}
diff --git a/public/images/card-brands/amex.svg b/public/images/card-brands/amex.svg
new file mode 100755
index 000000000..9007e03fc
--- /dev/null
+++ b/public/images/card-brands/amex.svg
@@ -0,0 +1 @@
+<svg width="780" height="500" enable-background="new 0 0 780 500" version="1.1" viewBox="0 0 780 500" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m40 1e-3h700c22.092 0 40 17.909 40 40v420c0 22.092-17.908 40-40 40h-700c-22.091 0-40-17.908-40-40v-420c0-22.091 17.909-40 40-40z" fill="#2557D6"/><path d="m0.253 235.69h37.441l8.442-19.51h18.9l8.42 19.51h73.668v-14.915l6.576 14.98h38.243l6.576-15.202v15.138h183.08l-0.085-32.026h3.542c2.479 0.083 3.204 0.302 3.204 4.226v27.8h94.689v-7.455c7.639 3.92 19.518 7.455 35.148 7.455h39.836l8.525-19.51h18.9l8.337 19.51h76.765v-18.532l11.626 18.532h61.515v-122.51h-60.88v14.468l-8.522-14.468h-62.471v14.468l-7.828-14.468h-84.38c-14.123 0-26.539 1.889-36.569 7.153v-7.153h-58.229v7.153c-6.383-5.426-15.079-7.153-24.75-7.153h-212.74l-14.274 31.641-14.659-31.641h-67.005v14.468l-7.362-14.468h-57.145l-26.539 58.246v64.261h3e-3zm236.34-17.67h-22.464l-0.083-68.794-31.775 68.793h-19.24l-31.858-68.854v68.854h-44.57l-8.42-19.592h-45.627l-8.505 19.592h-23.801l39.241-87.837h32.559l37.269 83.164v-83.164h35.766l28.678 59.587 26.344-59.587h36.485l1e-3 87.838zm-165.9-37.823l-14.998-35.017-14.915 35.017h29.913zm255.3 37.821h-73.203v-87.837h73.203v18.291h-51.289v15.833h50.06v18.005h-50.061v17.542h51.289l1e-3 18.166zm103.16-64.18c0 14.004-9.755 21.24-15.439 23.412 4.794 1.748 8.891 4.838 10.84 7.397 3.094 4.369 3.628 8.271 3.628 16.116v17.255h-22.104l-0.083-11.077c0-5.285 0.528-12.886-3.458-17.112-3.202-3.09-8.083-3.76-15.973-3.76h-23.523v31.95h-21.914v-87.838h50.401c11.199 0 19.451 0.283 26.535 4.207 6.933 3.924 11.09 9.652 11.09 19.45zm-27.699 13.042c-3.013 1.752-6.573 1.81-10.841 1.81h-26.62v-19.51h26.982c3.818 0 7.804 0.164 10.393 1.584 2.842 1.28 4.601 4.003 4.601 7.765 0 3.84-1.674 6.929-4.515 8.351zm62.844 51.138h-22.358v-87.837h22.358v87.837zm259.56 0h-31.053l-41.535-65.927v65.927h-44.628l-8.527-19.592h-45.521l-8.271 19.592h-25.648c-10.649 0-24.138-2.257-31.773-9.715-7.701-7.458-11.708-17.56-11.708-33.533 0-13.027 2.395-24.936 11.812-34.347 7.085-7.01 18.18-10.242 33.28-10.242h21.215v18.821h-20.771c-7.997 0-12.514 1.14-16.862 5.203-3.735 3.699-6.298 10.69-6.298 19.897 0 9.41 1.951 16.196 6.023 20.628 3.373 3.476 9.506 4.53 15.272 4.53h9.842l30.884-69.076h32.835l37.102 83.081v-83.08h33.366l38.519 61.174v-61.174h22.445v87.833zm-133.2-37.82l-15.165-35.017-15.081 35.017h30.246zm189.04 178.08c-5.322 7.457-15.694 11.238-29.736 11.238h-42.319v-18.84h42.147c4.181 0 7.106-0.527 8.868-2.175 1.665-1.474 2.605-3.554 2.591-5.729 0-2.561-1.064-4.593-2.677-5.811-1.59-1.342-3.904-1.95-7.722-1.95-20.574-0.67-46.244 0.608-46.244-27.194 0-12.742 8.443-26.156 31.439-26.156h43.649v-17.479h-40.557c-12.237 0-21.129 2.81-27.425 7.174v-7.175h-59.985c-9.595 0-20.854 2.279-26.179 7.175v-7.175h-107.12v7.175c-8.524-5.892-22.908-7.175-29.549-7.175h-70.656v7.175c-6.745-6.258-21.742-7.175-30.886-7.175h-79.077l-18.094 18.764-16.949-18.764h-118.13v122.59h115.9l18.646-19.062 17.565 19.062 71.442 0.061v-28.838h7.021c9.479 0.14 20.66-0.228 30.523-4.312v33.085h58.928v-31.952h2.842c3.628 0 3.985 0.144 3.985 3.615v28.333h179.01c11.364 0 23.244-2.786 29.824-7.845v7.845h56.78c11.815 0 23.354-1.587 32.134-5.649l2e-3 -22.84zm-354.94-47.155c0 24.406-19.005 29.445-38.159 29.445h-27.343v29.469h-42.591l-26.984-29.086-28.042 29.086h-86.802v-87.859h88.135l26.961 28.799 27.875-28.799h70.021c17.389 0 36.929 4.613 36.929 28.945zm-174.22 40.434h-53.878v-17.48h48.11v-17.926h-48.11v-15.974h54.939l23.969 25.604-25.03 25.776zm86.81 10.06l-33.644-35.789 33.644-34.65v70.439zm49.757-39.066h-28.318v-22.374h28.572c7.912 0 13.404 3.09 13.404 10.772 0 7.599-5.238 11.602-13.658 11.602zm148.36-40.373h73.138v18.17h-51.315v15.973h50.062v17.926h-50.062v17.48l51.314 0.08v18.23h-73.139l2e-3 -87.859zm-28.119 47.029c4.878 1.725 8.865 4.816 10.734 7.375 3.095 4.291 3.542 8.294 3.631 16.037v17.418h-22.002v-10.992c0-5.286 0.531-13.112-3.542-17.198-3.201-3.147-8.083-3.899-16.076-3.899h-23.42v32.09h-22.02v-87.859h50.594c11.093 0 19.173 0.47 26.366 4.146 6.915 4.004 11.266 9.487 11.266 19.511-1e-3 14.022-9.764 21.178-15.531 23.371zm-12.385-11.107c-2.932 1.667-6.556 1.811-10.818 1.811h-26.622v-19.732h26.982c3.902 0 7.807 0.08 10.458 1.587 2.84 1.423 4.538 4.146 4.538 7.903 0 3.758-1.699 6.786-4.538 8.431zm197.82 5.597c4.27 4.229 6.554 9.571 6.554 18.613 0 18.9-12.322 27.723-34.425 27.723h-42.68v-18.84h42.51c4.157 0 7.104-0.525 8.95-2.175 1.508-1.358 2.589-3.333 2.589-5.729 0-2.561-1.17-4.592-2.675-5.811-1.675-1.34-3.986-1.949-7.803-1.949-20.493-0.67-46.157 0.609-46.157-27.192 0-12.744 8.355-26.158 31.33-26.158h43.932v18.7h-40.198c-3.984 0-6.575 0.145-8.779 1.587-2.4 1.422-3.29 3.534-3.29 6.319 0 3.314 2.037 5.57 4.795 6.546 2.311 0.77 4.795 0.995 8.526 0.995l11.797 0.306c11.895 0.276 20.061 2.248 25.024 7.065zm86.955-23.52h-39.938c-3.986 0-6.638 0.144-8.867 1.587-2.312 1.423-3.202 3.534-3.202 6.322 0 3.314 1.951 5.568 4.791 6.544 2.312 0.771 4.795 0.996 8.444 0.996l11.878 0.304c11.983 0.284 19.982 2.258 24.86 7.072 0.891 0.67 1.422 1.422 2.033 2.175v-25h1e-3z" fill="#fff"/></svg>
diff --git a/public/images/card-brands/diners.svg b/public/images/card-brands/diners.svg
new file mode 100755
index 000000000..3f1827bf4
--- /dev/null
+++ b/public/images/card-brands/diners.svg
@@ -0,0 +1 @@
+<svg width="780" height="500" enable-background="new 0 0 780 500" version="1.1" viewBox="0 0 780 500" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="M40,0h700c22.092,0,40,17.909,40,40v420c0,22.092-17.908,40-40,40H40c-22.091,0-40-17.908-40-40V40 C0,17.909,17.909,0,40,0z" fill="#0079BE"/><path d="m599.93 251.45c0-99.415-82.98-168.13-173.9-168.1h-78.242c-92.003-0.033-167.73 68.705-167.73 168.1 0 90.93 75.727 165.64 167.73 165.2h78.242c90.914 0.436 173.9-74.294 173.9-165.2z" fill="#fff"/><path d="m348.28 97.43c-84.07 0.027-152.19 68.308-152.21 152.58 0.02 84.258 68.144 152.53 152.21 152.56 84.09-0.027 152.23-68.303 152.24-152.56-0.011-84.272-68.149-152.55-152.24-152.58z" fill="#0079BE"/><path d="m252.07 249.6c0.08-41.181 25.746-76.297 61.94-90.25v180.48c-36.194-13.948-61.861-49.045-61.94-90.23zm131 90.274v-180.53c36.207 13.92 61.914 49.057 61.979 90.257-0.065 41.212-25.772 76.322-61.979 90.269z" fill="#fff"/></svg>
diff --git a/public/images/card-brands/discover.svg b/public/images/card-brands/discover.svg
new file mode 100755
index 000000000..e6ee96565
--- /dev/null
+++ b/public/images/card-brands/discover.svg
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg width="780" height="500" viewBox="0 0 780 500" xmlns="http://www.w3.org/2000/svg"><g fill-rule="evenodd"><path d="M54.992 0C24.627 0 0 24.63 0 55.004v390.992C0 476.376 24.619 501 54.992 501h670.016C755.373 501 780 476.37 780 445.996V55.004C780 24.624 755.381 0 725.008 0H54.992z" fill="#4D4D4D"/><path d="M327.152 161.893c8.837 0 16.248 1.784 25.268 6.09v22.751c-8.544-7.863-15.955-11.154-25.756-11.154-19.264 0-34.414 15.015-34.414 34.05 0 20.075 14.681 34.196 35.37 34.196 9.312 0 16.586-3.12 24.8-10.857v22.763c-9.341 4.14-16.911 5.776-25.756 5.776-31.278 0-55.582-22.596-55.582-51.737 0-28.826 24.951-51.878 56.07-51.878zm-97.113.627c11.546 0 22.11 3.72 30.943 10.994l-10.748 13.248c-5.35-5.646-10.41-8.028-16.564-8.028-8.853 0-15.3 4.745-15.3 10.989 0 5.354 3.619 8.188 15.944 12.482 23.365 8.044 30.29 15.176 30.29 30.926 0 19.193-14.976 32.553-36.32 32.553-15.63 0-26.994-5.795-36.458-18.872l13.268-12.03c4.73 8.61 12.622 13.222 22.42 13.222 9.163 0 15.947-5.952 15.947-13.984 0-4.164-2.055-7.734-6.158-10.258-2.066-1.195-6.158-2.977-14.2-5.647-19.291-6.538-25.91-13.527-25.91-27.185 0-16.225 14.214-28.41 32.846-28.41zm234.723 1.728h22.437l28.084 66.592 28.446-66.592h22.267l-45.494 101.686h-11.053l-44.687-101.686zm-397.348.152h30.15c33.312 0 56.534 20.382 56.534 49.641 0 14.59-7.104 28.696-19.118 38.057-10.108 7.901-21.626 11.445-37.574 11.445H67.414V164.4zm96.135 0h20.54v99.143h-20.54V164.4zm411.734 0h58.252v16.8H595.81v22.005h36.336v16.791h-36.336v26.762h37.726v16.785h-58.252V164.4zm71.858 0h30.455c23.69 0 37.265 10.71 37.265 29.272 0 15.18-8.514 25.14-23.986 28.105l33.148 41.766h-25.26l-28.429-39.828h-2.678v39.828h-20.515V164.4zm20.515 15.616v30.025h6.002c13.117 0 20.069-5.362 20.069-15.328 0-9.648-6.954-14.697-19.745-14.697h-6.326zM87.94 181.199v65.559h5.512c13.273 0 21.656-2.394 28.11-7.88 7.103-5.955 11.376-15.465 11.376-24.98 0-9.499-4.273-18.725-11.376-24.681-6.785-5.78-14.837-8.018-28.11-8.018H87.94z" fill="#FFF"/><path d="m415.13 161.21c30.941 0 56.022 23.58 56.022 52.709v0.033c0 29.13-25.081 52.742-56.021 52.742s-56.022-23.613-56.022-52.742v-0.033c0-29.13 25.082-52.71 56.022-52.71zm364.85 127.15c-26.05 18.33-221.08 149.34-558.75 212.62h503.76c30.365 0 54.992-24.63 54.992-55.004v-157.62z" fill="#F47216"/></g></svg>
diff --git a/public/images/card-brands/generic.svg b/public/images/card-brands/generic.svg
new file mode 100755
index 000000000..e0dd349da
--- /dev/null
+++ b/public/images/card-brands/generic.svg
@@ -0,0 +1 @@
+<svg width="780" height="500" enable-background="new 0 0 780 500" version="1.1" viewBox="0 0 780 500" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="M40,0h700c22.092,0,40,17.909,40,40v420c0,22.092-17.908,40-40,40H40c-22.091,0-40-17.908-40-40V40 C0,17.909,17.909,0,40,0z" fill="#000C9D"/><rect x="66.908" y="106.91" width="110.32" height="99.679" fill="#9D9400"/><path d="m94.714 284.15v-3.795h-5.117v-11.27h-4.198l-0.402 11.27h-11.443l10.58-25.07-3.967-1.725-11.673 27.141v3.449h16.445v9.66h4.658v-9.66h5.117zm19.586-30.589c-4.025 0-7.878 1.381-11.213 4.6l2.588 2.934c2.645-2.473 5.002-3.68 8.395-3.68 4.197 0 7.532 2.357 7.532 6.727 0 4.773-3.737 6.959-7.532 6.959h-2.358l-0.575 3.795h3.335c4.658 0 8.223 1.84 8.223 7.531 0 4.945-3.278 8.107-8.855 8.107-3.22 0-6.555-1.322-8.798-3.967l-3.22 2.645c2.99 3.68 7.705 5.232 12.133 5.232 8.165 0 13.742-5.174 13.742-12.018 0-6.152-4.37-9.371-9.027-9.717 4.197-0.807 7.762-4.43 7.762-9.199 0-5.406-4.715-9.949-12.132-9.949zm34.477 0c-5.347 0-8.912 1.896-12.075 5.693l3.335 2.529c2.53-2.934 4.658-4.197 8.568-4.197 4.427 0 7.072 2.76 7.072 7.188 0 6.496-3.22 10.809-18.17 25.127v3.908h23.518l0.575-4.08h-18.63c13.052-11.904 17.71-17.826 17.71-25.07 0-6.325-4.428-11.098-11.903-11.098zm48.738 36.339h-8.28v-35.648h-4.198l-11.73 7.244 2.07 3.393 9.085-5.463v30.476h-9.775v3.908h22.828v-3.91zm69.587-5.75v-3.795h-5.117v-11.27h-4.198l-0.402 11.27h-11.443l10.58-25.07-3.967-1.725-11.673 27.141v3.449h16.445v9.66h4.658v-9.66h5.117zm19.585-30.589c-4.025 0-7.877 1.381-11.212 4.6l2.587 2.934c2.645-2.473 5.003-3.68 8.395-3.68 4.198 0 7.533 2.357 7.533 6.727 0 4.773-3.738 6.959-7.533 6.959h-2.357l-0.575 3.795h3.335c4.657 0 8.222 1.84 8.222 7.531 0 4.945-3.277 8.107-8.855 8.107-3.22 0-6.555-1.322-8.797-3.967l-3.22 2.645c2.99 3.68 7.705 5.232 12.132 5.232 8.165 0 13.743-5.174 13.743-12.018 0-6.152-4.37-9.371-9.028-9.717 4.198-0.807 7.763-4.43 7.763-9.199 0-5.406-4.715-9.949-12.133-9.949zm34.478 0c-5.348 0-8.913 1.896-12.075 5.693l3.335 2.529c2.53-2.934 4.657-4.197 8.567-4.197 4.428 0 7.073 2.76 7.073 7.188 0 6.496-3.221 10.809-18.171 25.127v3.908h23.518l0.575-4.08h-18.63c13.053-11.904 17.71-17.826 17.71-25.07 0-6.325-4.427-11.098-11.902-11.098zm48.737 36.339h-8.28v-35.648h-4.196l-11.729 7.244 2.069 3.393 9.085-5.463v30.476h-9.774v3.908h22.827l-2e-3 -3.91zm69.588-5.75v-3.795h-5.119v-11.27h-4.197l-0.401 11.27h-11.443l10.58-25.07-3.969-1.725-11.672 27.141v3.449h16.445v9.66h4.656v-9.66h5.12zm19.584-30.589c-4.023 0-7.877 1.381-11.213 4.6l2.588 2.934c2.646-2.473 5.002-3.68 8.396-3.68 4.195 0 7.531 2.357 7.531 6.727 0 4.773-3.736 6.959-7.531 6.959h-2.358l-0.574 3.795h3.334c4.658 0 8.225 1.84 8.225 7.531 0 4.945-3.278 8.107-8.854 8.107-3.222 0-6.556-1.322-8.799-3.967l-3.22 2.645c2.988 3.68 7.703 5.232 12.134 5.232 8.163 0 13.741-5.174 13.741-12.018 0-6.152-4.371-9.371-9.026-9.717 4.196-0.807 7.762-4.43 7.762-9.199-3e-3 -5.406-4.718-9.949-12.136-9.949zm34.479 0c-5.348 0-8.912 1.896-12.076 5.693l3.337 2.529c2.528-2.934 4.657-4.197 8.565-4.197 4.428 0 7.072 2.76 7.072 7.188 0 6.496-3.219 10.809-18.17 25.127v3.908h23.518l0.576-4.08h-18.631c13.053-11.904 17.711-17.826 17.711-25.07 0-6.326-4.428-11.098-11.904-11.098h2e-3zm48.736 36.339h-8.279v-35.648h-4.197l-11.729 7.244 2.07 3.393 9.084-5.463v30.476h-9.775v3.908h22.828l-2e-3 -3.91zm69.588-5.75v-3.795h-5.117v-11.27h-4.197l-0.401 11.27h-11.443l10.58-25.07-3.967-1.725-11.672 27.141v3.449h16.445v9.66h4.655v-9.66h5.117zm19.584-30.589c-4.023 0-7.877 1.381-11.211 4.6l2.588 2.934c2.646-2.473 5.002-3.68 8.396-3.68 4.196 0 7.532 2.357 7.532 6.727 0 4.773-3.737 6.959-7.532 6.959h-2.357l-0.574 3.795h3.334c4.658 0 8.224 1.84 8.224 7.531 0 4.945-3.277 8.107-8.855 8.107-3.219 0-6.555-1.322-8.797-3.967l-3.221 2.645c2.99 3.68 7.705 5.232 12.133 5.232 8.166 0 13.742-5.174 13.742-12.018 0-6.152-4.369-9.371-9.027-9.717 4.197-0.807 7.764-4.43 7.764-9.199 0-5.406-4.715-9.949-12.133-9.949h-6e-3zm34.478 0c-5.347 0-8.912 1.896-12.074 5.693l3.334 2.529c2.531-2.934 4.658-4.197 8.567-4.197 4.429 0 7.072 2.76 7.072 7.188 0 6.496-3.221 10.809-18.17 25.127v3.908h23.519l0.575-4.08h-18.631c13.054-11.904 17.711-17.826 17.711-25.07 2e-3 -6.325-4.428-11.098-11.903-11.098zm48.739 36.339h-8.278v-35.648h-4.2l-11.729 7.244 2.068 3.393 9.086-5.463v30.476h-9.775v3.908h22.828v-3.91z" fill="#fff"/><path d="m72.219 389.2h6.445v-22.246l-7.012 1.406v-3.594l6.973-1.406h3.945v25.84h6.446v3.32h-16.797v-3.32zm25.468 0h6.446v-22.246l-7.012 1.406v-3.594l6.973-1.406h3.945v25.84h6.445v3.32h-16.797v-3.32zm40.918 0h13.77v3.32h-18.516v-3.32c1.497-1.549 3.535-3.625 6.114-6.229 2.591-2.617 4.218-4.305 4.882-5.061 1.263-1.42 2.142-2.617 2.637-3.594 0.508-0.988 0.762-1.959 0.762-2.91 0-1.549-0.547-2.811-1.64-3.789-1.081-0.977-2.495-1.465-4.24-1.465-1.237 0-2.545 0.215-3.925 0.646-1.367 0.43-2.831 1.08-4.394 1.953v-3.986c1.588-0.637 3.072-1.119 4.453-1.443 1.38-0.326 2.643-0.486 3.789-0.486 3.021 0 5.429 0.754 7.226 2.264 1.797 1.512 2.696 3.529 2.696 6.055 0 1.199-0.228 2.338-0.684 3.418-0.442 1.068-1.256 2.332-2.441 3.789-0.326 0.377-1.361 1.471-3.106 3.281-1.745 1.796-4.206 4.315-7.383 7.557zm34.024-12.402c1.888 0.404 3.359 1.244 4.414 2.521 1.067 1.275 1.601 2.852 1.601 4.727 0 2.877-0.99 5.104-2.968 6.682-1.979 1.574-4.792 2.361-8.438 2.361-1.224 0-2.487-0.125-3.789-0.371-1.289-0.234-2.623-0.594-4.004-1.074v-3.809c1.093 0.639 2.292 1.119 3.594 1.445 1.302 0.324 2.663 0.488 4.082 0.488 2.474 0 4.356-0.488 5.645-1.465 1.302-0.979 1.953-2.396 1.953-4.26 0-1.719-0.605-3.061-1.817-4.021-1.198-0.979-2.872-1.465-5.02-1.465h-3.398v-3.242h3.555c1.94 0 3.425-0.385 4.453-1.152 1.029-0.781 1.543-1.9 1.543-3.359 0-1.496-0.534-2.645-1.601-3.438-1.055-0.809-2.572-1.211-4.551-1.211-1.081 0-2.24 0.117-3.477 0.354-1.237 0.232-2.597 0.598-4.082 1.092v-3.514c1.498-0.418 2.897-0.73 4.2-0.939 1.314-0.207 2.551-0.311 3.71-0.311 2.995 0 5.365 0.682 7.11 2.049 1.745 1.354 2.617 3.189 2.617 5.508 0 1.615-0.462 2.98-1.387 4.102-0.925 1.105-2.24 1.872-3.945 2.302zm26.289-13.438h15.488v3.32h-11.874v7.148c0.573-0.195 1.146-0.34 1.719-0.43 0.573-0.105 1.146-0.156 1.719-0.156 3.255 0 5.833 0.893 7.734 2.676s2.852 4.199 2.852 7.246c0 3.139-0.977 5.578-2.93 7.324-1.954 1.732-4.708 2.598-8.262 2.598-1.224 0-2.474-0.104-3.75-0.312-1.263-0.207-2.571-0.521-3.926-0.938v-3.965c1.172 0.639 2.383 1.113 3.633 1.426s2.572 0.469 3.965 0.469c2.253 0 4.037-0.594 5.352-1.777s1.972-2.793 1.972-4.824-0.657-3.639-1.972-4.824-3.099-1.775-5.352-1.775c-1.055 0-2.109 0.117-3.164 0.352-1.041 0.234-2.109 0.6-3.203 1.092l-1e-3 -14.65zm33.867 15.313c-1.875 0-3.353 0.502-4.434 1.506-1.067 1.002-1.601 2.383-1.601 4.141s0.534 3.137 1.601 4.139c1.082 1.004 2.56 1.506 4.434 1.506 1.875 0 3.354-0.502 4.434-1.504 1.08-1.016 1.62-2.396 1.62-4.141 0-1.758-0.54-3.139-1.62-4.141-1.068-1.004-2.546-1.506-4.434-1.506zm-3.945-1.68c-1.693-0.416-3.015-1.203-3.965-2.363-0.938-1.158-1.406-2.57-1.406-4.236 0-2.332 0.827-4.174 2.48-5.527 1.667-1.354 3.945-2.029 6.836-2.029 2.904 0 5.183 0.676 6.836 2.027 1.653 1.355 2.48 3.197 2.48 5.529 0 1.666-0.475 3.078-1.425 4.236-0.938 1.16-2.247 1.947-3.926 2.363 1.9 0.443 3.378 1.311 4.434 2.598 1.067 1.289 1.601 2.865 1.601 4.729 0 2.824-0.866 4.992-2.598 6.504-1.719 1.51-4.186 2.266-7.402 2.266s-5.69-0.756-7.422-2.266c-1.719-1.512-2.578-3.68-2.578-6.504 0-1.863 0.534-3.439 1.602-4.729 1.067-1.289 2.551-2.154 4.453-2.598zm-1.446-6.228c0 1.51 0.469 2.688 1.407 3.533 0.95 0.848 2.278 1.271 3.984 1.271 1.693 0 3.015-0.424 3.965-1.271 0.963-0.848 1.445-2.023 1.445-3.535 0-1.51-0.481-2.688-1.445-3.535-0.951-0.846-2.272-1.271-3.965-1.271-1.706 0-3.034 0.426-3.984 1.271-0.938 0.847-1.407 2.025-1.407 3.537z" fill="#fff" fill-opacity=".784"/><path d="m325.45 388.23h6.444v-22.246l-7.012 1.406v-3.594l6.973-1.406h3.946v25.84h6.444v3.32h-16.797l2e-3 -3.32zm36.738-12.404c1.889 0.404 3.359 1.244 4.415 2.521 1.067 1.275 1.602 2.852 1.602 4.727 0 2.877-0.989 5.105-2.969 6.68-1.979 1.576-4.791 2.363-8.438 2.363-1.224 0-2.487-0.123-3.79-0.371-1.288-0.232-2.622-0.592-4.003-1.074v-3.809c1.094 0.639 2.292 1.121 3.595 1.445 1.303 0.326 2.662 0.488 4.082 0.488 2.474 0 4.354-0.488 5.645-1.465 1.302-0.977 1.953-2.396 1.953-4.258 0-1.719-0.605-3.061-1.816-4.023-1.197-0.977-2.871-1.465-5.02-1.465h-3.398v-3.242h3.556c1.939 0 3.425-0.385 4.453-1.152 1.028-0.781 1.543-1.9 1.543-3.359 0-1.496-0.533-2.643-1.603-3.438-1.055-0.807-2.571-1.209-4.55-1.209-1.081 0-2.24 0.115-3.479 0.35-1.236 0.234-2.598 0.6-4.081 1.096v-3.518c1.497-0.416 2.896-0.729 4.198-0.938 1.315-0.209 2.553-0.312 3.71-0.312 2.996 0 5.365 0.686 7.11 2.053 1.744 1.354 2.616 3.189 2.616 5.508 0 1.613-0.462 2.98-1.386 4.102-0.923 1.103-2.239 1.872-3.945 2.3zm16.915 12.404h13.771v3.32h-18.518v-3.32c1.498-1.551 3.536-3.627 6.114-6.23 2.59-2.617 4.218-4.305 4.883-5.059 1.264-1.42 2.143-2.617 2.637-3.594 0.508-0.99 0.762-1.961 0.762-2.91 0-1.549-0.547-2.812-1.64-3.789-1.081-0.977-2.494-1.465-4.239-1.465-1.236 0-2.545 0.215-3.926 0.645-1.367 0.43-2.831 1.08-4.396 1.953v-3.984c1.589-0.639 3.073-1.119 4.453-1.445s2.645-0.488 3.789-0.488c3.021 0 5.43 0.756 7.227 2.268 1.797 1.51 2.695 3.527 2.695 6.055 0 1.195-0.227 2.336-0.684 3.418-0.441 1.066-1.256 2.33-2.441 3.789-0.325 0.377-1.36 1.471-3.104 3.279-1.746 1.796-4.206 4.315-7.383 7.557zm22.753 0h6.447v-22.246l-7.014 1.406v-3.594l6.975-1.406h3.943v25.84h6.445v3.32h-16.798l2e-3 -3.32zm49.472-12.404c1.889 0.404 3.358 1.244 4.414 2.521 1.067 1.275 1.604 2.852 1.604 4.727 0 2.877-0.99 5.105-2.971 6.68-1.979 1.576-4.791 2.363-8.438 2.363-1.223 0-2.485-0.123-3.788-0.371-1.289-0.232-2.623-0.592-4.005-1.074v-3.809c1.095 0.639 2.293 1.121 3.595 1.445 1.303 0.326 2.664 0.488 4.082 0.488 2.475 0 4.354-0.488 5.645-1.465 1.303-0.977 1.953-2.396 1.953-4.258 0-1.719-0.605-3.061-1.814-4.023-1.198-0.977-2.873-1.465-5.021-1.465h-3.396v-3.242h3.554c1.94 0 3.424-0.385 4.453-1.152 1.028-0.781 1.543-1.9 1.543-3.359 0-1.496-0.533-2.643-1.603-3.438-1.055-0.807-2.569-1.209-4.551-1.209-1.08 0-2.238 0.115-3.477 0.35-1.236 0.234-2.599 0.6-4.082 1.096v-3.518c1.497-0.416 2.897-0.729 4.2-0.938 1.314-0.209 2.552-0.312 3.709-0.312 2.996 0 5.365 0.686 7.109 2.053 1.746 1.354 2.617 3.189 2.617 5.508 0 1.613-0.461 2.98-1.387 4.102-0.923 1.103-2.238 1.872-3.945 2.3zm24.356-10l-9.959 15.568h9.959v-15.568zm-1.036-3.435h4.961v19.004h4.159v3.281h-4.159v6.875h-3.925v-6.875h-13.166v-3.811l12.132-18.477h-2e-3v3e-3zm15.706 0h15.486v3.32h-11.875v7.146c0.574-0.195 1.146-0.338 1.721-0.43 0.572-0.104 1.146-0.156 1.718-0.156 3.256 0 5.834 0.893 7.735 2.676 1.9 1.785 2.851 4.199 2.851 7.246 0 3.139-0.978 5.58-2.931 7.324-1.953 1.73-4.707 2.598-8.262 2.598-1.223 0-2.473-0.104-3.75-0.311-1.262-0.209-2.57-0.521-3.926-0.939v-3.965c1.172 0.639 2.383 1.113 3.633 1.426 1.25 0.314 2.572 0.469 3.967 0.469 2.252 0 4.035-0.592 5.351-1.775 1.315-1.186 1.973-2.793 1.973-4.824s-0.656-3.641-1.973-4.824c-1.314-1.186-3.099-1.777-5.351-1.777-1.055 0-2.108 0.117-3.164 0.352-1.043 0.234-2.11 0.6-3.203 1.094v-14.65zm25.466 0h15.489v3.32h-11.877v7.146c0.572-0.195 1.146-0.338 1.72-0.43 0.571-0.104 1.146-0.156 1.719-0.156 3.256 0 5.832 0.893 7.733 2.676 1.9 1.785 2.853 4.199 2.853 7.246 0 3.139-0.978 5.58-2.93 7.324-1.953 1.73-4.707 2.598-8.263 2.598-1.225 0-2.475-0.104-3.75-0.311-1.264-0.209-2.571-0.521-3.926-0.939v-3.965c1.172 0.639 2.383 1.113 3.633 1.426 1.25 0.314 2.572 0.469 3.965 0.469 2.252 0 4.037-0.592 5.353-1.775 1.313-1.186 1.973-2.793 1.973-4.824s-0.658-3.641-1.973-4.824c-1.316-1.186-3.101-1.777-5.353-1.777-1.055 0-2.108 0.117-3.164 0.352-1.043 0.234-2.108 0.6-3.202 1.094v-14.65z" fill="#fff" fill-opacity=".784"/></svg>
diff --git a/public/images/card-brands/jcb.svg b/public/images/card-brands/jcb.svg
new file mode 100755
index 000000000..b1143c01b
--- /dev/null
+++ b/public/images/card-brands/jcb.svg
@@ -0,0 +1 @@
+<svg width="780" height="500" enable-background="new 0 0 780 500" version="1.1" viewBox="0 0 780 500" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="M40,0h700c22.092,0,40,17.909,40,40v420c0,22.092-17.908,40-40,40H40c-22.091,0-40-17.908-40-40V40 C0,17.909,17.909,0,40,0z" fill="#0E4C96"/><path d="m632.24 361.27c0 41.615-33.729 75.36-75.36 75.36h-409.13v-297.88c0-41.626 33.733-75.37 75.365-75.37l409.12-1e-3 1e-3 297.89z" fill="#fff"/><linearGradient id="c" x1="83.977" x2="84.977" y1="645.5" y2="645.5" gradientTransform="matrix(132.87 0 0 -323.02 -10686 2.0876e5)" gradientUnits="userSpaceOnUse"><stop stop-color="#007B40" offset="0"/><stop stop-color="#55B330" offset="1"/></linearGradient><path d="m498.86 256.54c11.684 0.253 23.437-0.516 35.076 0.4 11.787 2.199 14.629 20.043 4.156 25.888-7.141 3.851-15.633 1.433-23.379 2.113h-15.852l-1e-3 -28.401zm41.833-32.145c2.596 9.164-6.238 17.392-15.066 16.13h-26.767c0.185-8.642-0.368-18.021 0.271-26.208 10.725 0.301 21.549-0.616 32.21 0.479 4.581 1.151 8.414 4.917 9.352 9.599zm64.428-135.9c0.498 17.501 0.071 35.927 0.214 53.783-0.035 72.596 0.072 145.19-0.055 217.79-0.47 27.207-24.582 50.844-51.601 51.387-27.046 0.111-54.095 0.016-81.142 0.047v-109.75c29.47-0.154 58.959 0.307 88.417-0.232 13.667-0.859 28.632-9.875 29.27-24.914 1.61-15.103-12.632-25.551-26.152-27.201-5.198-0.135-5.044-1.516 0-2.117 12.892-2.787 23.02-16.133 19.226-29.499-3.236-14.058-18.772-19.499-31.697-19.472-26.351-0.18-52.709-0.026-79.062-0.077 0.172-20.489-0.354-41 0.286-61.474 2.087-26.716 26.806-48.747 53.447-48.27h78.849v-1e-3z" fill="url(#c)"/><linearGradient id="b" x1="83.984" x2="84.979" y1="645.5" y2="645.5" gradientTransform="matrix(133.43 0 0 -323.02 -11031 2.0876e5)" gradientUnits="userSpaceOnUse"><stop stop-color="#1D2970" offset="0"/><stop stop-color="#006DBA" offset="1"/></linearGradient><path d="m174.74 139.54c0.674-27.163 24.889-50.611 51.875-51.007 26.944-0.083 53.891-0.012 80.837-0.036-0.074 90.885 0.148 181.78-0.112 272.66-1.038 26.835-24.99 49.835-51.679 50.308-26.996 0.099-53.995 0.014-80.992 0.042v-113.45c26.223 6.194 53.722 8.832 80.473 4.721 15.993-2.574 33.488-10.424 38.902-27.014 3.986-14.191 1.742-29.126 2.334-43.691v-33.824h-46.297c-0.208 22.369 0.426 44.779-0.335 67.125-1.248 13.734-14.846 22.46-27.8 21.994-16.066 0.17-47.898-11.639-47.898-11.639-0.08-41.918 0.466-94.409 0.692-136.18z" fill="url(#b)"/><linearGradient id="a" x1="83.978" x2="84.977" y1="645.5" y2="645.5" gradientTransform="matrix(132.96 0 0 -323.03 -10842 2.0877e5)" gradientUnits="userSpaceOnUse"><stop stop-color="#6E2B2F" offset="0"/><stop stop-color="#E30138" offset="1"/></linearGradient><path d="m324.72 211.89c-2.434 0.517-0.489-8.301-1.113-11.646 0.165-21.15-0.347-42.323 0.283-63.458 2.083-26.829 26.991-48.916 53.739-48.288h78.766c-0.073 90.884 0.147 181.78-0.111 272.66-1.039 26.834-24.992 49.833-51.681 50.308-26.997 0.1-53.997 0.015-80.997 0.043v-124.3c18.44 15.128 43.5 17.483 66.473 17.524 17.316-6e-3 34.534-2.674 51.35-6.67v-22.772c-18.953 9.446-41.232 15.446-62.243 10.019-14.655-3.65-25.294-17.812-25.056-32.937-1.699-15.728 7.524-32.335 22.981-37.011 19.189-6.008 40.107-1.413 58.096 6.397 3.854 2.019 7.765 4.521 6.222-1.921v-17.9c-30.084-7.156-62.101-9.792-92.329-2.004-8.749 2.469-17.271 6.212-24.38 11.958z" fill="url(#a)"/></svg>
diff --git a/public/images/card-brands/mastercard.svg b/public/images/card-brands/mastercard.svg
new file mode 100755
index 000000000..73b6a4d6b
--- /dev/null
+++ b/public/images/card-brands/mastercard.svg
@@ -0,0 +1,14 @@
+<svg width="780" height="500" viewBox="0 0 780 500" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_6278_125843)">
+<path d="M40 0H740C762.092 0 780 17.909 780 40V460C780 482.092 762.092 500 740 500H40C17.909 500 0 482.092 0 460V40C0 17.909 17.909 0 40 0Z" fill="#253747"/>
+<path d="M211.053 467.045V438.109C211.053 427.041 204.311 419.793 192.736 419.793C186.949 419.793 180.657 421.703 176.33 427.996C172.959 422.715 168.127 419.793 160.879 419.793C156.047 419.793 151.215 421.254 147.395 426.535V420.748H137.281V467.045H147.395V441.481C147.395 433.278 151.721 429.401 158.463 429.401C165.205 429.401 168.577 433.727 168.577 441.481V467.045H178.69V441.481C178.69 433.278 183.522 429.401 189.759 429.401C196.501 429.401 199.872 433.727 199.872 441.481V467.045H211.053ZM361.068 420.748H344.662V406.758H334.549V420.748H325.391V429.906H334.549V451.145C334.549 461.764 338.875 468 350.449 468C354.776 468 359.608 466.539 362.979 464.629L360.057 455.92C357.135 457.831 353.764 458.336 351.348 458.336C346.516 458.336 344.606 455.415 344.606 450.639V429.906H361.012V420.748H361.068ZM446.92 419.737C441.133 419.737 437.256 422.658 434.84 426.479V420.692H424.727V466.989H434.84V440.919C434.84 433.221 438.211 428.839 444.504 428.839C446.414 428.839 448.83 429.345 450.797 429.794L453.718 420.13C451.696 419.737 448.83 419.737 446.92 419.737ZM317.187 424.569C312.356 421.198 305.613 419.737 298.365 419.737C286.791 419.737 279.094 425.524 279.094 434.682C279.094 442.38 284.881 446.762 294.994 448.167L299.826 448.672C305.108 449.628 308.029 451.088 308.029 453.504C308.029 456.875 304.152 459.291 297.41 459.291C290.668 459.291 285.33 456.875 281.959 454.459L277.127 462.157C282.409 466.034 289.657 467.944 296.904 467.944C310.389 467.944 318.143 461.651 318.143 452.999C318.143 444.796 311.85 440.469 302.242 439.008L297.41 438.503C293.084 437.997 289.713 437.042 289.713 434.176C289.713 430.805 293.084 428.895 298.421 428.895C304.209 428.895 309.996 431.311 312.917 432.772L317.187 424.569ZM586.26 419.737C580.473 419.737 576.596 422.658 574.18 426.479V420.692H564.067V466.989H574.18V440.919C574.18 433.221 577.551 428.839 583.844 428.839C585.754 428.839 588.17 429.345 590.137 429.794L593.059 420.242C591.092 419.737 588.227 419.737 586.26 419.737ZM457.033 443.897C457.033 457.887 466.697 468 481.643 468C488.385 468 493.217 466.539 498.049 462.719L493.217 454.516C489.34 457.437 485.519 458.842 481.137 458.842C472.934 458.842 467.147 453.055 467.147 443.897C467.147 435.188 472.934 429.401 481.137 428.951C485.463 428.951 489.34 430.412 493.217 433.278L498.049 425.074C493.217 421.198 488.385 419.793 481.643 419.793C466.697 419.737 457.033 429.906 457.033 443.897ZM550.582 443.897V420.748H540.469V426.535C537.098 422.209 532.266 419.793 525.973 419.793C512.938 419.793 502.825 429.906 502.825 443.897C502.825 457.887 512.938 468 525.973 468C532.715 468 537.547 465.584 540.469 461.258V467.045H550.582V443.897ZM513.444 443.897C513.444 435.693 518.725 428.951 527.434 428.951C535.637 428.951 541.424 435.244 541.424 443.897C541.424 452.1 535.637 458.842 527.434 458.842C518.781 458.336 513.444 452.043 513.444 443.897ZM392.42 419.737C378.935 419.737 369.271 429.401 369.271 443.84C369.271 458.336 378.935 467.944 392.926 467.944C399.668 467.944 406.41 466.034 411.748 461.651L406.916 454.403C403.039 457.325 398.207 459.235 393.431 459.235C387.139 459.235 380.902 456.314 379.441 448.167H413.658C413.658 446.706 413.658 445.751 413.658 444.29C414.108 429.401 405.399 419.737 392.42 419.737ZM392.42 428.446C398.713 428.446 403.039 432.322 403.994 439.514H379.891C380.846 433.278 385.172 428.446 392.42 428.446ZM643.682 443.897V402.432H633.568V426.535C630.197 422.209 625.365 419.793 619.073 419.793C606.037 419.793 595.924 429.906 595.924 443.897C595.924 457.887 606.037 468 619.073 468C625.815 468 630.647 465.584 633.568 461.258V467.045H643.682V443.897ZM606.543 443.897C606.543 435.693 611.825 428.951 620.533 428.951C628.736 428.951 634.524 435.244 634.524 443.897C634.524 452.1 628.736 458.842 620.533 458.842C611.825 458.336 606.543 452.043 606.543 443.897ZM267.969 443.897V420.748H257.855V426.535C254.484 422.209 249.652 419.793 243.36 419.793C230.325 419.793 220.211 429.906 220.211 443.897C220.211 457.887 230.325 468 243.36 468C250.102 468 254.934 465.584 257.855 461.258V467.045H267.969V443.897ZM230.381 443.897C230.381 435.693 235.662 428.951 244.371 428.951C252.574 428.951 258.361 435.244 258.361 443.897C258.361 452.1 252.574 458.842 244.371 458.842C235.662 458.336 230.381 452.043 230.381 443.897Z" fill="white"/>
+<path d="M465.738 69.1387H313.812V342.088H465.738V69.1387Z" fill="#FF5A00"/>
+<path d="M323.926 205.613C323.926 150.158 349.996 100.94 390 69.1387C360.559 45.9902 323.42 32 282.91 32C186.945 32 109.297 109.648 109.297 205.613C109.297 301.578 186.945 379.227 282.91 379.227C323.42 379.227 360.559 365.237 390 342.088C349.94 310.737 323.926 261.069 323.926 205.613Z" fill="#EB001B"/>
+<path d="M670.711 205.613C670.711 301.578 593.062 379.227 497.098 379.227C456.588 379.227 419.449 365.237 390.008 342.088C430.518 310.231 456.082 261.069 456.082 205.613C456.082 150.158 430.012 100.94 390.008 69.1387C419.393 45.9902 456.532 32 497.041 32C593.062 32 670.711 110.154 670.711 205.613Z" fill="#F79E1B"/>
+</g>
+<defs>
+<clipPath id="clip0_6278_125843">
+<rect width="780" height="500" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/public/images/card-brands/unionpay.svg b/public/images/card-brands/unionpay.svg
new file mode 100755
index 000000000..145428d71
--- /dev/null
+++ b/public/images/card-brands/unionpay.svg
@@ -0,0 +1 @@
+<svg width="780" height="500" enable-background="new 0 0 780 500" version="1.1" viewBox="0 0 780 500" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="M40,0h700c22.092,0,40,17.909,40,40v420c0,22.092-17.908,40-40,40H40c-22.091,0-40-17.908-40-40V40 C0,17.909,17.909,0,40,0z" fill="#fff"/><path d="m216.4 69.791h142.39c19.87 0 32.287 16.406 27.63 36.47l-66.333 287.48c-4.656 20.063-24.629 36.47-44.498 36.47h-142.39c-19.87 0-32.287-16.406-27.63-36.47l66.331-287.48c4.657-20.168 24.526-36.47 44.395-36.47h0.104z" fill="#D10429"/><path d="m346.34 69.791h163.82c19.868 0 10.865 16.406 6.209 36.47l-66.334 287.48c-4.657 20.063-3.208 36.47-23.077 36.47h-163.81c-19.972 0-32.287-16.406-27.527-36.47l66.334-287.48c4.656-20.168 24.524-36.47 44.498-36.47h-0.104z" fill="#022E64"/><path d="m504.41 69.791h142.4c19.869 0 32.287 16.406 27.629 36.47l-66.332 287.48c-4.658 20.063-24.631 36.47-44.499 36.47h-142.39c-19.973 0-32.287-16.406-27.63-36.47l66.333-287.48c4.656-20.168 24.525-36.47 44.394-36.47h0.104z" fill="#076F74"/><path d="m480.5 340.81h13.453l3.829-13.063h-13.351l-3.931 13.063zm10.762-35.95l-4.657 15.467s5.071-2.613 7.865-3.449c2.794-0.627 6.933-1.15 6.933-1.15l3.208-10.763h-13.451l0.102-0.105zm6.726-22.153l-4.449 14.839s4.967-2.3 7.761-3.029c2.794-0.732 6.933-0.941 6.933-0.941l3.208-10.764h-13.349l-0.104-0.105zm29.701 0l-17.386 57.997h4.657l-3.622 12.018h-4.657l-1.138 3.657h-16.559l1.14-3.657h-33.529l3.311-11.076h3.415l17.594-58.938 3.518-11.913h16.868l-1.76 5.956s4.449-3.239 8.797-4.39c4.243-1.148 28.665-1.566 28.665-1.566l-3.622 11.809h-5.795l0.103 0.103z" fill="#FEFEFE"/><path d="m534.59 270.79h18.006l0.207 6.792c-0.103 1.149 0.828 1.672 3.001 1.672h3.622l-3.311 11.183h-9.729c-8.382 0.627-11.59-3.03-11.383-7.106l-0.311-12.437-0.102-0.104zm2.216 53.2h-17.178l2.896-9.927h19.662l2.794-9.092h-19.351l3.311-11.182h53.812l-3.312 11.182h-18.109l-2.794 9.092h18.109l-3.002 9.927h-19.558l-3.518 4.18h7.968l1.966 12.54c0.207 1.254 0.207 2.09 0.62 2.613 0.415 0.418 2.795 0.627 4.14 0.627h2.38l-3.725 12.227h-6.106c-0.93 0-2.38-0.104-4.346-0.104-1.863-0.21-3.104-1.255-4.346-1.882-1.139-0.522-2.794-1.881-3.208-4.284l-1.863-12.54-8.899 12.331c-2.795 3.866-6.622 6.897-13.143 6.897h-12.418l3.311-10.869h4.761c1.346 0 2.588-0.521 3.52-1.045 0.931-0.418 1.758-0.836 2.586-2.193l13.04-18.498zm-187.9-27.2h45.429l-3.312 10.973h-18.109l-2.793 9.299h18.627l-3.415 11.287h-18.524l-4.553 15.152c-0.517 1.672 4.45 1.881 6.209 1.881l9.313-1.254-3.726 12.54h-20.904c-1.654 0-2.896-0.209-4.76-0.627-1.76-0.418-2.587-1.254-3.311-2.403-0.726-1.254-1.968-2.195-1.14-4.912l6.002-20.063h-10.348l3.415-11.495h10.348l2.794-9.3h-10.347l3.312-10.974-0.207-0.104zm31.387-19.835h18.627l-3.415 11.39h-25.457l-2.794 2.404c-1.242 1.15-1.552 0.732-3.105 1.568-1.447 0.73-4.449 2.193-8.382 2.193h-8.175l3.311-10.972h2.484c2.07 0 3.52-0.21 4.243-0.627 0.828-0.522 1.76-1.672 2.69-3.554l4.656-8.568h18.525l-3.208 6.27v-0.104zm35.107 18.81s5.07-4.701 13.764-6.164c1.966-0.418 14.384-0.211 14.384-0.211l1.863-6.27h-26.182l-3.83 12.75 1e-3 -0.105zm24.629 4.807h-25.975l-1.552 5.329h22.56c2.69-0.313 3.208 0.104 3.415-0.104l1.655-5.225h-0.103zm-33.735-29.678h15.833l-2.276 8.047s4.967-4.075 8.485-5.539c3.519-1.254 11.383-2.508 11.383-2.508l25.664-0.104-8.796 29.469c-1.449 5.016-3.208 8.256-4.243 9.823-0.93 1.463-2.07 2.821-4.346 4.075-2.173 1.15-4.141 1.881-6.002 1.986-1.656 0.104-4.347 0.209-7.865 0.209h-24.732l-6.934 23.303c-0.62 2.299-0.931 3.447-0.517 4.074 0.31 0.523 1.241 1.15 2.38 1.15l10.865-1.045-3.726 12.749h-12.21c-3.933 0-6.727-0.104-8.693-0.21-1.862-0.208-3.83 0-5.175-1.044-1.138-1.045-2.896-2.403-2.794-3.763 0.104-1.254 0.621-3.344 1.45-6.27l22.249-74.402z" fill="#FEFEFE"/><path d="m452.43 317.79l-1.449 7.105c-0.619 2.194-1.138 3.867-2.794 5.33-1.759 1.463-3.725 3.03-8.484 3.03l-8.796 0.418-0.104 7.942c-0.103 2.193 0.519 1.984 0.828 2.402 0.414 0.418 0.724 0.523 1.138 0.732l2.794-0.21 8.384-0.417-3.52 11.704h-9.624c-6.726 0-11.797-0.21-13.35-1.463-1.655-1.046-1.862-2.3-1.862-4.599l0.62-31.141h15.42l-0.207 6.374h3.725c1.242 0 2.175-0.104 2.691-0.418s0.828-0.836 1.035-1.567l1.552-5.016h12.108l-0.105-0.206zm-219.37-156c-0.517 2.508-10.451 48.592-10.451 48.592-2.174 9.3-3.726 15.989-8.9 20.273-3.001 2.508-6.52 3.657-10.555 3.657-6.52 0-10.245-3.239-10.866-9.404l-0.104-2.09s1.966-12.436 1.966-12.54c0 0 10.349-42.009 12.212-47.548 0.103-0.313 0.103-0.522 0.103-0.627-20.18 0.21-23.801 0-24.008-0.313-0.104 0.418-0.621 3.03-0.621 3.03l-10.556 47.34-0.932 3.97-1.758 13.168c0 3.866 0.724 7.105 2.277 9.718 4.863 8.569 18.627 9.823 26.388 9.823 10.038 0 19.455-2.195 25.767-6.061 11.073-6.584 13.97-16.929 16.454-26.02l1.242-4.703s10.659-43.576 12.522-49.219c0.103-0.314 0.103-0.523 0.207-0.627-14.695 0.104-18.938 0-20.387-0.314v-0.105zm59.03 86.623c-7.141-0.105-9.728-0.105-18.11 0.313l-0.311-0.627c0.724-3.24 1.552-6.374 2.173-9.614l1.035-4.389c1.552-6.792 3.001-14.839 3.208-17.242 0.207-1.463 0.62-5.12-3.519-5.12-1.759 0-3.518 0.835-5.38 1.671-1.036 3.658-3.002 13.899-4.037 18.497-2.07 9.823-2.173 10.972-3.104 15.78l-0.621 0.626c-7.347-0.104-9.934-0.104-18.42 0.314l-0.414-0.732c1.449-5.852 2.794-11.704 4.14-17.556 3.518-15.78 4.45-21.84 5.38-29.887l0.725-0.418c8.279-1.149 10.245-1.463 19.248-3.239l0.724 0.836-1.345 5.016c1.552-0.94 3.001-1.881 4.553-2.613 4.243-2.09 8.9-2.717 11.487-2.717 3.932 0 8.279 1.15 10.038 5.748 1.656 4.075 0.62 9.091-1.656 19.019l-1.138 5.016c-2.277 11.077-2.69 13.062-3.933 20.586l-0.827 0.627 0.104 0.105zm29.057 0.027c-4.346 0-7.14-0.104-9.83 0-2.691 0-5.278 0.21-9.314 0.314l-0.207-0.314-0.207-0.418c1.138-4.18 1.656-5.643 2.277-7.106 0.517-1.463 1.034-2.926 2.07-7.21 1.241-5.539 2.069-9.405 2.586-12.854 0.621-3.24 0.932-6.06 1.346-9.3l0.31-0.209 0.31-0.313c4.347-0.627 7.038-1.045 9.832-1.463s5.691-0.94 10.141-1.776l0.207 0.418 0.103 0.418-2.482 10.345c-0.828 3.449-1.656 6.897-2.38 10.346-1.554 7.315-2.277 10.032-2.587 12.017-0.414 1.881-0.519 2.822-1.14 6.584l-0.414 0.313-0.414 0.314-0.207-0.106zm45.942-25.675c-0.31 1.881-1.966 8.883-4.139 11.809-1.553 2.194-3.312 3.553-5.382 3.553-0.62 0-4.14 0-4.242-5.33 0-2.612 0.517-5.33 1.138-8.255 1.863-8.465 4.14-15.466 9.831-15.466 4.45 0 4.76 5.225 2.794 13.689zm18.73 0.836c2.483-11.077 0.518-16.302-1.862-19.437-3.726-4.807-10.348-6.374-17.178-6.374-4.141 0-13.867 0.418-21.525 7.524-5.484 5.12-8.071 12.122-9.52 18.81-1.554 6.792-3.312 19.019 7.864 23.617 3.414 1.463 8.382 1.88 11.59 1.88 8.176 0 16.558-2.298 22.87-8.986 4.863-5.434 7.036-13.585 7.864-17.034h-0.103zm174.43 26.08c-8.693-0.104-11.176-0.104-19.146 0.314l-0.517-0.627c2.173-8.256 4.346-16.616 6.312-24.976 2.483-10.868 3.104-15.466 3.933-21.84l0.62-0.522c8.59-1.254 10.97-1.567 19.973-3.239l0.207 0.731c-1.656 6.897-3.208 13.69-4.864 20.482-3.311 14.317-4.45 21.632-5.69 29.156l-0.828 0.627v-0.106z" fill="#FEFEFE"/><path d="m547.75 224.16c-0.414 1.776-2.07 8.882-4.243 11.808-1.449 2.09-4.967 3.449-6.933 3.449-0.621 0-4.036 0-4.243-5.225 0-2.613 0.517-5.33 1.138-8.256 1.863-8.255 4.141-15.257 9.831-15.257 4.45 0 6.416 5.12 4.45 13.585v-0.104zm17.075 0.836c2.482-11.077-7.658-0.94-9.21-4.598-2.484-5.748-0.933-17.243-10.866-21.109-3.829-1.568-12.832 0.418-20.49 7.524-5.381 5.016-8.072 12.017-9.52 18.705-1.554 6.688-3.312 19.02 7.76 23.304 3.52 1.567 6.727 1.985 9.935 1.776 11.178-0.627 19.662-17.661 25.976-24.349 4.861-5.329 5.69 1.986 6.415-1.253zm-129.94 23.413c-7.14-0.105-9.624-0.105-18.006 0.313l-0.311-0.627c0.725-3.24 1.553-6.374 2.276-9.614l0.931-4.389c1.554-6.792 3.105-14.839 3.208-17.242 0.207-1.463 0.621-5.12-3.415-5.12-1.759 0-3.62 0.835-5.38 1.671-0.932 3.658-3.002 13.899-4.037 18.497-1.966 9.823-2.173 10.972-3.104 15.78l-0.621 0.626c-7.347-0.104-9.934-0.104-18.42 0.314l-0.414-0.732c1.449-5.852 2.794-11.704 4.14-17.556 3.519-15.78 4.347-21.84 5.38-29.887l0.621-0.418c8.28-1.149 10.35-1.463 19.248-3.239l0.726 0.836-1.242 5.016c1.449-0.94 3.001-1.881 4.45-2.613 4.243-2.09 8.899-2.717 11.485-2.717 3.934 0 8.177 1.15 10.038 5.748 1.656 4.075 0.519 9.091-1.759 19.019l-1.138 5.016c-2.38 11.077-2.69 13.062-3.934 20.586l-0.826 0.627 0.104 0.105zm62.001-86.519l-6.002 0.105c-15.523 0.209-21.732 0.104-24.215-0.209-0.207 1.15-0.621 3.135-0.621 3.135s-5.588 25.916-5.588 26.02c0 0-13.246 55.176-13.867 57.788 13.556-0.209 19.041-0.209 21.421 0.105 0.519-2.613 3.622-17.974 3.726-17.974 0 0 2.69-11.286 2.795-11.704 0 0 0.826-1.15 1.654-1.672h1.242c11.694 0 24.836 0 35.186-7.628 7.036-5.225 11.797-13.063 13.97-22.468 0.517-2.299 0.931-5.016 0.931-7.837 0-3.658-0.724-7.21-2.794-10.032-5.279-7.42-15.731-7.524-27.838-7.629zm7.761 27.066c-1.241 5.747-4.967 10.659-9.727 12.958-3.933 1.985-8.693 2.194-13.66 2.194h-3.208l0.207-1.254s5.899-25.916 5.899-25.811l0.206-1.359 0.104-1.045 2.38 0.21s12.211 1.044 12.418 1.044c4.759 1.881 6.83 6.688 5.381 13.063zm127.21 8.666l-0.723-0.836c-8.797 1.776-10.453 2.09-18.525 3.24l-0.619 0.626c0 0.105-0.104 0.21-0.104 0.418v-0.104c-6.002 14.107-5.9 11.077-10.762 22.154 0-0.523 0-0.836-0.105-1.359l-1.242-24.035-0.723-0.836c-9.314 1.777-9.521 2.09-18.007 3.24l-0.621 0.627c-0.104 0.313-0.104 0.627-0.104 0.94l0.104 0.105c1.035 5.538 0.828 4.284 1.863 12.958 0.517 4.284 1.138 8.569 1.655 12.749 0.828 7.106 1.346 10.554 2.381 21.318-5.797 9.613-7.142 13.271-12.729 21.734l0.31 0.836c8.384-0.312 10.246-0.312 16.455-0.312l1.346-1.568c4.656-10.135 40.256-71.79 40.256-71.79l-0.106-0.105zm-302.72 6.922c4.76-3.344 5.38-7.942 1.345-10.345-4.036-2.404-11.176-1.672-15.937 1.672-4.76 3.24-5.277 7.837-1.241 10.345 3.932 2.3 11.072 1.672 15.833-1.672z" fill="#FEFEFE"/><path d="m590.33 270.9l-6.935 12.019c-2.173 4.075-6.312 7.21-12.728 7.21l-11.073-0.209 3.208-10.868h2.173c1.138 0 1.966-0.104 2.587-0.418 0.621-0.209 0.933-0.627 1.449-1.254l4.14-6.583h17.282l-0.103 0.103z" fill="#FEFEFE"/></svg>
diff --git a/public/images/card-brands/visa.svg b/public/images/card-brands/visa.svg
new file mode 100755
index 000000000..c2e790a0d
--- /dev/null
+++ b/public/images/card-brands/visa.svg
@@ -0,0 +1,11 @@
+<svg width="780" height="500" viewBox="0 0 780 500" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_6278_125851)">
+<path d="M40 0H740C762.092 0 780 17.909 780 40V460C780 482.092 762.092 500 740 500H40C17.909 500 0 482.092 0 460V40C0 17.909 17.909 0 40 0Z" fill="#1434CB"/>
+<path d="M489.823 143.111C442.988 143.111 401.134 167.393 401.134 212.256C401.134 263.706 475.364 267.259 475.364 293.106C475.364 303.989 462.895 313.731 441.6 313.731C411.377 313.731 388.789 300.119 388.789 300.119L379.123 345.391C379.123 345.391 405.145 356.889 439.692 356.889C490.898 356.889 531.19 331.415 531.19 285.784C531.19 231.419 456.652 227.971 456.652 203.981C456.652 195.455 466.887 186.114 488.122 186.114C512.081 186.114 531.628 196.014 531.628 196.014L541.087 152.289C541.087 152.289 519.818 143.111 489.823 143.111ZM61.3294 146.411L60.1953 153.011C60.1953 153.011 79.8988 156.618 97.645 163.814C120.495 172.064 122.122 176.868 125.971 191.786L167.905 353.486H224.118L310.719 146.411H254.635L198.989 287.202L176.282 167.861C174.199 154.203 163.651 146.411 150.74 146.411H61.3294ZM333.271 146.411L289.275 353.486H342.756L386.598 146.411H333.271ZM631.554 146.411C618.658 146.411 611.825 153.318 606.811 165.386L528.458 353.486H584.542L595.393 322.136H663.72L670.318 353.486H719.805L676.633 146.411H631.554ZM638.848 202.356L655.473 280.061H610.935L638.848 202.356Z" fill="white"/>
+</g>
+<defs>
+<clipPath id="clip0_6278_125851">
+<rect width="780" height="500" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/public/index.php b/public/index.php
index ee8f07e99..6aa752c80 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
diff --git a/resources/js/components/billing/PlanPicker.vue b/resources/js/components/billing/PlanPicker.vue
index 6899c1ea0..b23ed485c 100644
--- a/resources/js/components/billing/PlanPicker.vue
+++ b/resources/js/components/billing/PlanPicker.vue
@@ -167,7 +167,7 @@ const workspaceLabel = (plan: PlanOption): string =>
<div class="flex flex-col gap-1">
<p class="flex items-baseline gap-2">
<span
- class="text-2xl leading-9 font-strong tabular-nums"
+ class="text-2xl leading-9 font-strong tracking-tight tabular-nums [word-spacing:-0.15em]"
:data-testid="`plan-price-${plan.slug}`"
>{{ price(plan) }}</span
>
diff --git a/resources/js/components/welcome/WelcomeOfferBanner.vue b/resources/js/components/welcome/WelcomeOfferBanner.vue
new file mode 100644
index 000000000..591b4c022
--- /dev/null
+++ b/resources/js/components/welcome/WelcomeOfferBanner.vue
@@ -0,0 +1,22 @@
+<script setup lang="ts">
+defineProps<{
+ offerKey: string;
+}>();
+</script>
+
+<template>
+ <div class="mb-6 flex justify-center" data-testid="welcome-plan-offer">
+ <p
+ class="inline-flex items-center gap-3 rounded-full bg-foreground py-1.5 ps-1.5 pe-5 text-start text-sm text-background sm:text-base"
+ >
+ <span
+ class="shrink-0 rounded-full bg-background px-3 py-1 text-xs font-strong tracking-wider text-foreground uppercase sm:text-sm"
+ data-testid="welcome-plan-offer-name"
+ >{{ $t(`offers.${offerKey}.name`) }}</span
+ >
+ <span data-testid="welcome-plan-offer-headline">{{
+ $t(`offers.${offerKey}.headline`)
+ }}</span>
+ </p>
+ </div>
+</template>
diff --git a/resources/js/lib/cardBrands.ts b/resources/js/lib/cardBrands.ts
new file mode 100644
index 000000000..cc6990cc5
--- /dev/null
+++ b/resources/js/lib/cardBrands.ts
@@ -0,0 +1,28 @@
+interface CardBrand {
+ name: string;
+ logo: string;
+}
+
+/**
+ * Card brands as Stripe names them (`card.brand`), with the name people know
+ * and its card-shaped logo. A brand without its own logo gets the generic card.
+ */
+const CARD_BRANDS: Record<string, CardBrand> = {
+ amex: { name: 'American Express', logo: '/images/card-brands/amex.svg' },
+ cartes_bancaires: { name: 'Cartes Bancaires', logo: '/images/card-brands/generic.svg' },
+ diners: { name: 'Diners Club', logo: '/images/card-brands/diners.svg' },
+ discover: { name: 'Discover', logo: '/images/card-brands/discover.svg' },
+ eftpos_au: { name: 'eftpos', logo: '/images/card-brands/generic.svg' },
+ interac: { name: 'Interac', logo: '/images/card-brands/generic.svg' },
+ jcb: { name: 'JCB', logo: '/images/card-brands/jcb.svg' },
+ link: { name: 'Link', logo: '/images/card-brands/generic.svg' },
+ mastercard: { name: 'Mastercard', logo: '/images/card-brands/mastercard.svg' },
+ unionpay: { name: 'UnionPay', logo: '/images/card-brands/unionpay.svg' },
+ visa: { name: 'Visa', logo: '/images/card-brands/visa.svg' },
+};
+
+export const cardBrand = (brand: string): CardBrand =>
+ CARD_BRANDS[brand] ?? {
+ name: brand.charAt(0).toUpperCase() + brand.slice(1),
+ logo: '/images/card-brands/generic.svg',
+ };
diff --git a/resources/js/pages/auth/Login.vue b/resources/js/pages/auth/Login.vue
index 6ca5b4e5b..8545b9be4 100644
--- a/resources/js/pages/auth/Login.vue
+++ b/resources/js/pages/auth/Login.vue
@@ -76,6 +76,7 @@ const pageErrors = usePageErrors();
id="email"
type="email"
name="email"
+ data-testid="login-email"
autofocus
:tabindex="1"
autocomplete="email"
@@ -103,6 +104,7 @@ const pageErrors = usePageErrors();
id="password"
:type="showPassword ? 'text' : 'password'"
name="password"
+ data-testid="login-password"
:tabindex="2"
autocomplete="current-password"
:placeholder="$t('auth.login.password')"
diff --git a/resources/js/pages/billing/Processing.vue b/resources/js/pages/billing/Processing.vue
index 7dae680f7..7d879c2b1 100644
--- a/resources/js/pages/billing/Processing.vue
+++ b/resources/js/pages/billing/Processing.vue
@@ -5,32 +5,42 @@ import { computed, onMounted, ref, watch } from 'vue';
import { useBelowBreakpoint } from '@/composables/useBreakpoint';
import AuthSplitLayout from '@/layouts/auth/AuthSplitLayout.vue';
+import { index as billingIndex } from '@/routes/app/billing';
import { index as postsIndex } from '@/routes/app/posts';
import { mcp } from '@/routes/app/welcome';
import type { SharedData } from '@/types';
const props = defineProps<{
- subscriptionActive: boolean;
+ ready: boolean;
+ returnsToBilling: boolean;
}>();
const page = usePage<SharedData>();
// Poll `auth` so `auth.plan` is set after the webhook writes plan_id.
const { stop } = usePoll(2000, {
- only: ['subscriptionActive', 'auth'],
+ only: ['ready', 'auth'],
});
const finishing = ref(false);
const purchaseReady = computed(
- (): boolean => props.subscriptionActive && page.props.auth.plan !== null,
+ (): boolean => props.ready && page.props.auth.plan !== null,
);
const isPhone = useBelowBreakpoint('sm');
/** Connecting an AI is a desktop task, so phones go straight to the schedule. */
const goNext = (): void => {
- router.visit(isPhone.value ? postsIndex.url() : mcp.url());
+ if (props.returnsToBilling) {
+ router.visit(billingIndex.url(), { replace: true });
+
+ return;
+ }
+
+ router.visit(isPhone.value ? postsIndex.url() : mcp.url(), {
+ replace: true,
+ });
};
// Card-required trials are already `subscribed()` (`trialing`) on first paint.
diff --git a/resources/js/pages/settings/account/Billing.vue b/resources/js/pages/settings/account/Billing.vue
index 79dd7552a..75d753eea 100644
--- a/resources/js/pages/settings/account/Billing.vue
+++ b/resources/js/pages/settings/account/Billing.vue
@@ -1,12 +1,18 @@
<script setup lang="ts">
-import { Head, useForm, usePage } from '@inertiajs/vue3';
-import { IconCreditCard, IconDownload, IconFileText } from '@tabler/icons-vue';
+import { Head, InfiniteScroll, router, useForm, usePage } from '@inertiajs/vue3';
+import {
+ IconCreditCard,
+ IconDiscount,
+ IconDownload,
+ IconFileText,
+ IconSparkles,
+} from '@tabler/icons-vue';
import { computed, ref } from 'vue';
import PlanPicker from '@/components/billing/PlanPicker.vue';
-import SettingsListRow from '@/components/settings/SettingsListRow.vue';
+import EmptyState from '@/components/EmptyState.vue';
import SettingsSection from '@/components/settings/SettingsSection.vue';
-import { Badge } from '@/components/ui/badge';
+import { Badge, type BadgeVariants } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
Dialog,
@@ -15,14 +21,32 @@ import {
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
-import { Separator } from '@/components/ui/separator';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableLoadMore,
+ TableRow,
+} from '@/components/ui/table';
+import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import date from '@/date';
import SettingsLayout from '@/layouts/SettingsLayout.vue';
+import { cardBrand } from '@/lib/cardBrands';
import {
changePlan as changePlanRoute,
+ checkout as checkoutRoute,
+ index,
portal,
} from '@/routes/app/billing';
import type { AuthPlan, SharedData } from '@/types';
+import type {
+ Invoice,
+ PaymentMethod,
+ Subscription,
+ SubscriptionDiscount,
+} from '@/types/billing';
import {
DEFAULT_BILLING_INTERVAL,
deniedPlanIdsFor,
@@ -31,25 +55,22 @@ import {
type PlanOption,
} from '@/types/plan';
-interface Subscription {
- stripe_status: string;
- ends_at: string | null;
+interface ScrollInvoices {
+ data: Invoice[];
}
-interface PaymentMethod {
- brand: string;
- last4: string;
- exp_month: number;
- exp_year: number;
-}
+type BillingTab = 'plan' | 'invoices';
-interface Invoice {
- id: string;
- date: string;
- total: string;
- status: string;
- invoice_pdf: string;
-}
+const BILLING_TABS: BillingTab[] = ['plan', 'invoices'];
+
+type SubscriptionStatus = 'trial' | 'past_due' | 'cancelling' | 'active';
+
+const STATUS_BADGES: Record<SubscriptionStatus, BadgeVariants['variant']> = {
+ active: 'success',
+ trial: 'info',
+ cancelling: 'warning',
+ past_due: 'destructive-subtle',
+};
const props = defineProps<{
hasSubscription: boolean;
@@ -58,11 +79,21 @@ const props = defineProps<{
subscription: Subscription | null;
plan: PlanOption | null;
workspaceCount: number;
- workspaceLimit: number | null;
- invoices: Invoice[];
- defaultPaymentMethod: PaymentMethod | null;
+ invoices: ScrollInvoices;
+ paymentMethods: PaymentMethod[];
+ discount: SubscriptionDiscount | null;
}>();
+const discountKey = computed((): string => {
+ if (props.discount?.duration === 'once') {
+ return 'billing.current_plan.discount_once';
+ }
+
+ return props.discount?.ends_at
+ ? 'billing.current_plan.discount_until'
+ : 'billing.current_plan.discount_forever';
+});
+
const page = usePage<SharedData>();
const plans = computed((): PlanOption[] => page.props.plans ?? []);
const authPlan = computed((): AuthPlan | null => page.props.auth.plan);
@@ -70,21 +101,21 @@ const currentInterval = computed(
(): BillingInterval => authPlan.value?.interval ?? DEFAULT_BILLING_INTERVAL,
);
-const subscriptionStatus = computed(() => {
- if (props.onTrial) {
- return 'trial' as const;
- }
-
+const subscriptionStatus = computed((): SubscriptionStatus | null => {
if (props.subscription?.stripe_status === 'past_due') {
- return 'past_due' as const;
+ return 'past_due';
}
if (props.subscription?.ends_at) {
- return 'cancelling' as const;
+ return 'cancelling';
+ }
+
+ if (props.onTrial) {
+ return 'trial';
}
if (props.subscription?.stripe_status === 'active') {
- return 'active' as const;
+ return 'active';
}
return null;
@@ -105,10 +136,33 @@ const priceKey = computed((): string | null => {
return `billing.subscribe.prices.${props.plan.slug}.${currentInterval.value === 'yearly' ? 'yearly' : 'monthly'}`;
});
-const priceLabelKey = computed(
- (): string => `billing.current_plan.price_${currentInterval.value}`,
+const priceSuffixKey = computed((): string =>
+ currentInterval.value === 'yearly'
+ ? 'billing.plans.per_year'
+ : 'billing.plans.per_month',
+);
+
+const billingTab = (value: unknown): BillingTab =>
+ BILLING_TABS.find((tab) => tab === value) ?? 'plan';
+
+const tab = ref<BillingTab>(
+ billingTab(
+ new URL(page.url, window.location.origin).searchParams.get('tab'),
+ ),
);
+const selectTab = (value: string | number): void => {
+ tab.value = billingTab(value);
+
+ router.replace({
+ url: index({
+ query: tab.value === 'plan' ? {} : { tab: tab.value },
+ }).url,
+ preserveScroll: true,
+ preserveState: true,
+ });
+};
+
const planForm = useForm<{
plan_id: string | null;
interval: BillingInterval;
@@ -126,6 +180,12 @@ const closePlanDialog = (): void => {
isPlanDialogOpen.value = false;
};
+const checkoutForm = useForm({});
+
+const subscribe = (): void => {
+ checkoutForm.post(checkoutRoute.url());
+};
+
const selectPlan = (planId: string): void => {
if (planForm.processing) {
return;
@@ -144,217 +204,333 @@ const selectPlan = (planId: string): void => {
<Head :title="$t('billing.title')" />
<SettingsLayout :title="$t('billing.title')">
- <div class="flex flex-col gap-10">
- <SettingsSection
- v-if="hasSubscription"
- :title="$t('billing.plans.current')"
- >
- <div
- class="flex flex-wrap items-center gap-4 rounded-xl border border-border bg-card px-4 py-6"
- data-testid="billing-current-plan"
+ <Tabs
+ :model-value="tab"
+ class="flex flex-col gap-8"
+ @update:model-value="selectTab"
+ >
+ <TabsList variant="line">
+ <TabsTrigger
+ v-for="value in BILLING_TABS"
+ :key="value"
+ :value="value"
+ :data-testid="`billing-tab-${value}`"
>
- <div class="flex min-w-0 flex-1 flex-col gap-1">
- <div class="flex flex-wrap items-baseline gap-x-2">
- <p
- class="text-base leading-tight font-emphasis text-foreground"
- data-testid="billing-current-plan-name"
- >
- {{ plan?.name }}
- </p>
- <p
- v-if="priceKey"
- class="text-sm text-muted-foreground tabular-nums"
- data-testid="billing-current-plan-price"
- >
- {{
- $t(priceLabelKey, {
- price: $t(priceKey),
- })
- }}
- </p>
+ {{ $t(`billing.tabs.${value}`) }}
+ </TabsTrigger>
+ </TabsList>
+
+ <TabsContent value="plan" class="flex flex-col gap-10">
+ <SettingsSection
+ v-if="hasSubscription || onTrial"
+ :title="$t('billing.plans.current')"
+ >
+ <div
+ class="overflow-hidden rounded-xl border border-border bg-card"
+ data-testid="billing-current-plan"
+ >
+ <div class="flex flex-col gap-5 p-5 sm:p-6">
+ <div class="flex flex-wrap items-start justify-between gap-4">
+ <div class="flex min-w-0 flex-col gap-3">
+ <div class="flex flex-wrap items-center gap-2">
+ <p
+ class="text-lg leading-tight font-emphasis text-foreground"
+ data-testid="billing-current-plan-name"
+ >
+ {{ plan?.name }}
+ </p>
+ <Badge
+ v-if="subscriptionStatus"
+ :variant="STATUS_BADGES[subscriptionStatus]"
+ data-testid="billing-current-plan-badge"
+ >
+ {{
+ $t(
+ `billing.current_plan.statuses.${subscriptionStatus}`,
+ )
+ }}
+ </Badge>
+ </div>
+ <p
+ v-if="priceKey"
+ class="flex items-baseline gap-1 tabular-nums"
+ data-testid="billing-current-plan-price"
+ >
+ <span
+ class="text-3xl leading-none font-emphasis tracking-tight text-foreground [word-spacing:-0.15em]"
+ >
+ {{ $t(priceKey) }}
+ </span>
+ <span class="text-sm text-muted-foreground">
+ {{ $t(priceSuffixKey) }}
+ </span>
+ </p>
+ <p
+ v-if="discount"
+ class="flex items-center gap-1.5 text-sm text-muted-foreground"
+ data-testid="billing-current-plan-discount"
+ >
+ <IconDiscount
+ class="size-4 shrink-0 text-success-text"
+ />
+ {{
+ $t(discountKey, {
+ discount: discount.value,
+ date: date.formatDate(discount.ends_at),
+ })
+ }}
+ </p>
+ </div>
+ <Button
+ v-if="hasSubscription"
+ variant="outline"
+ class="shrink-0"
+ data-testid="billing-change-plan"
+ @click="openPlanDialog"
+ >
+ {{ $t('billing.current_plan.change') }}
+ </Button>
+ <Button
+ v-else
+ class="shrink-0"
+ :loading="checkoutForm.processing"
+ data-testid="billing-subscribe"
+ @click="subscribe"
+ >
+ {{ $t('billing.current_plan.subscribe') }}
+ </Button>
+ </div>
</div>
<p
- class="text-sm text-muted-foreground"
+ v-if="subscriptionStatus === 'trial' && trialEndsAt"
+ class="flex items-center gap-1.5 border-t border-border bg-muted/40 px-5 py-3 text-sm text-muted-foreground sm:px-6"
data-testid="billing-current-plan-status"
>
- <template
- v-if="subscriptionStatus === 'trial' && trialEndsAt"
- >
- {{
- $t('billing.current_plan.trial_until', {
- date: date.formatDate(trialEndsAt),
- })
- }}
- </template>
- <template
- v-else-if="
- subscriptionStatus === 'cancelling' &&
- subscription?.ends_at
- "
- >
- {{
- $t('billing.current_plan.cancelled', {
- date: date.formatDate(
- subscription.ends_at,
- ),
- })
- }}
- </template>
- <template v-else-if="subscriptionStatus === 'past_due'">
- {{ $t('billing.past_due_notice.title') }}
- </template>
- <template v-else>
- {{ $t('billing.current_plan.renews') }}
- </template>
+ <IconSparkles
+ class="size-4 shrink-0 text-primary-text"
+ data-testid="billing-current-plan-trial-icon"
+ />
+ {{
+ $t('billing.current_plan.trial_until', {
+ date: date.formatDateTime(trialEndsAt),
+ })
+ }}
</p>
<p
- class="text-sm text-muted-foreground tabular-nums"
- data-testid="billing-current-plan-usage"
+ v-else-if="
+ subscriptionStatus === 'cancelling' &&
+ subscription?.ends_at
+ "
+ class="border-t border-border bg-muted/40 px-5 py-3 text-sm text-muted-foreground sm:px-6"
+ data-testid="billing-current-plan-status"
>
{{
- workspaceLimit === null
- ? $t('billing.plans.workspaces_unlimited')
- : $t('billing.current_plan.workspaces_usage', {
- count: workspaceCount.toString(),
- limit: workspaceLimit.toString(),
- })
+ $t('billing.current_plan.cancelled', {
+ date: date.formatDate(subscription.ends_at),
+ })
}}
</p>
+ <p
+ v-else-if="subscriptionStatus === 'past_due'"
+ class="border-t border-border bg-muted/40 px-5 py-3 text-sm text-muted-foreground sm:px-6"
+ data-testid="billing-current-plan-status"
+ >
+ {{ $t('billing.past_due_notice.description') }}
+ </p>
</div>
- <Button
- variant="outline"
- class="shrink-0"
- data-testid="billing-change-plan"
- @click="openPlanDialog"
- >
- {{ $t('billing.current_plan.change') }}
- </Button>
- </div>
- <Dialog v-model:open="isPlanDialogOpen">
- <DialogContent
- class="sm:max-w-3xl"
- data-testid="billing-plan-dialog"
- >
- <DialogHeader>
- <DialogTitle>
- {{ $t('billing.current_plan.change') }}
- </DialogTitle>
- <DialogDescription>
- {{ $t('billing.plans.description') }}
- </DialogDescription>
- </DialogHeader>
- <PlanPicker
- :plans="plans"
- v-model:interval="selectedInterval"
- :current-plan-id="plan?.id ?? null"
- :current-interval="currentInterval"
- :disabled-plan-ids="deniedPlanIds"
- :processing="planForm.processing"
- @select="selectPlan"
- />
- </DialogContent>
- </Dialog>
- </SettingsSection>
-
- <Separator v-if="hasSubscription" />
-
- <SettingsSection
- v-if="hasSubscription"
- :title="$t('billing.subscription.title')"
- :description="$t('billing.subscription.description')"
- >
- <div
- class="flex flex-wrap items-center gap-4 rounded-xl border border-border bg-card px-4 py-6"
+ <Dialog v-model:open="isPlanDialogOpen">
+ <DialogContent
+ class="sm:max-w-3xl"
+ data-testid="billing-plan-dialog"
+ >
+ <DialogHeader>
+ <DialogTitle>
+ {{ $t('billing.current_plan.change') }}
+ </DialogTitle>
+ <DialogDescription>
+ {{ $t('billing.plans.description') }}
+ </DialogDescription>
+ </DialogHeader>
+ <PlanPicker
+ :plans="plans"
+ v-model:interval="selectedInterval"
+ :current-plan-id="plan?.id ?? null"
+ :current-interval="currentInterval"
+ :disabled-plan-ids="deniedPlanIds"
+ :processing="planForm.processing"
+ @select="selectPlan"
+ />
+ </DialogContent>
+ </Dialog>
+ </SettingsSection>
+
+ <SettingsSection
+ v-if="hasSubscription"
+ :title="$t('billing.subscription.title')"
+ :description="$t('billing.subscription.description')"
>
- <span
- class="inline-flex size-12 shrink-0 items-center justify-center rounded-xl bg-primary-subtle text-primary-text"
+ <template #actions>
+ <Button
+ as="a"
+ variant="outline"
+ :href="portal.url()"
+ data-testid="billing-manage-stripe"
+ >
+ {{ $t('billing.subscription.manage_stripe') }}
+ </Button>
+ </template>
+
+ <ul
+ v-if="paymentMethods.length > 0"
+ class="divide-y divide-border overflow-hidden rounded-xl border border-border bg-card"
+ data-testid="billing-payment-methods"
>
- <IconCreditCard class="size-6" />
- </span>
+ <li
+ v-for="paymentMethod in paymentMethods"
+ :key="paymentMethod.id"
+ class="flex items-center gap-3 px-4 py-3"
+ :data-testid="`billing-card-${paymentMethod.id}`"
+ >
+ <img
+ :src="cardBrand(paymentMethod.brand).logo"
+ alt=""
+ class="h-7 w-auto shrink-0 rounded-[5px] shadow-xs"
+ :data-testid="`billing-card-logo-${paymentMethod.id}`"
+ />
+ <div class="flex min-w-0 flex-1 flex-col">
+ <p
+ class="flex flex-wrap items-center gap-1.5 text-[13px] leading-5 font-emphasis text-foreground"
+ data-testid="billing-card-label"
+ >
+ {{ cardBrand(paymentMethod.brand).name }}
+ <span class="tabular-nums">•••• {{ paymentMethod.last4 }}</span>
+ <Badge
+ v-if="paymentMethod.is_default"
+ variant="secondary"
+ data-testid="billing-card-default"
+ >
+ {{ $t('billing.subscription.default') }}
+ </Badge>
+ </p>
+ <p class="text-xs leading-4 text-muted-foreground tabular-nums">
+ {{
+ $t('billing.subscription.expires_on', {
+ month: paymentMethod.exp_month
+ .toString()
+ .padStart(2, '0'),
+ year: paymentMethod.exp_year.toString(),
+ })
+ }}
+ </p>
+ </div>
+ </li>
+ </ul>
<div
- v-if="defaultPaymentMethod"
- class="flex min-w-0 flex-1 flex-col gap-1"
+ v-else
+ class="flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3"
>
- <p
- class="text-sm leading-tight font-emphasis text-foreground capitalize"
+ <span
+ class="inline-flex h-7 w-11 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground"
>
- {{ defaultPaymentMethod.brand }} ••••
- {{ defaultPaymentMethod.last4 }}
- </p>
+ <IconCreditCard class="size-5" />
+ </span>
<p class="text-sm text-muted-foreground">
- {{
- $t('billing.subscription.expires_on', {
- month: defaultPaymentMethod.exp_month
- .toString()
- .padStart(2, '0'),
- year: defaultPaymentMethod.exp_year.toString(),
- })
- }}
+ {{ $t('billing.subscription.no_payment_method') }}
</p>
</div>
- <p v-else class="min-w-0 flex-1 text-sm text-muted-foreground">
- {{ $t('billing.subscription.no_payment_method') }}
- </p>
- <Button
- as="a"
- variant="outline"
- :href="portal.url()"
- class="shrink-0"
- >
- {{ $t('billing.subscription.manage_stripe') }}
- </Button>
- </div>
- </SettingsSection>
-
- <Separator v-if="hasSubscription && invoices.length > 0" />
-
- <SettingsSection
- v-if="invoices.length > 0"
- :title="$t('billing.invoices.title')"
- :description="$t('billing.invoices.description')"
- >
- <ul class="flex flex-col gap-2">
- <SettingsListRow
- v-for="invoice in invoices"
- :key="invoice.id"
+ </SettingsSection>
+ </TabsContent>
+
+ <TabsContent value="invoices">
+ <div
+ v-if="invoices.data.length === 0"
+ class="rounded-xl border border-border bg-card"
+ >
+ <EmptyState
:icon="IconFileText"
+ :title="$t('billing.invoices.empty_title')"
+ :description="$t('billing.invoices.empty_description')"
+ data-testid="billing-invoices-empty"
+ />
+ </div>
+
+ <div
+ v-else
+ class="overflow-hidden rounded-xl border border-border bg-card"
+ >
+ <InfiniteScroll
+ data="invoices"
+ items-element="#billing-invoices-body"
+ preserve-url
>
- <p
- class="text-sm leading-tight font-emphasis text-foreground"
- >
- {{ date.formatDate(invoice.date) }}
- </p>
- <p class="text-sm text-muted-foreground tabular-nums">
- {{ invoice.total }}
- </p>
- <template #actions>
- <Badge
- :variant="
- invoice.status === 'paid' ? 'success' : 'secondary'
- "
- >
- {{
- invoice.status === 'paid'
- ? $t('billing.invoices.paid')
- : invoice.status
- }}
- </Badge>
- <Button
- variant="ghost"
- size="icon"
- as="a"
- :href="invoice.invoice_pdf"
- target="_blank"
- class="text-muted-foreground"
- :aria-label="$t('billing.invoices.download')"
- >
- <IconDownload class="size-4" />
- </Button>
+ <div class="overflow-x-auto">
+ <Table data-testid="billing-invoices">
+ <TableHeader>
+ <TableRow class="hover:bg-transparent">
+ <TableHead class="border-r-0 h-11 px-4 sm:px-5">
+ {{ $t('billing.invoices.columns.date') }}
+ </TableHead>
+ <TableHead class="border-r-0 h-11 px-4">
+ {{ $t('billing.invoices.columns.amount') }}
+ </TableHead>
+ <TableHead class="border-r-0 h-11 px-4">
+ {{ $t('billing.invoices.columns.status') }}
+ </TableHead>
+ <TableHead class="border-r-0 h-11 w-14 px-4">
+ <span class="sr-only">
+ {{ $t('billing.invoices.download') }}
+ </span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody id="billing-invoices-body">
+ <TableRow
+ v-for="invoice in invoices.data"
+ :key="invoice.id"
+ class="last:border-b-0"
+ :data-testid="`billing-invoice-${invoice.id}`"
+ >
+ <TableCell
+ class="border-r-0 px-4 py-3 font-emphasis text-foreground sm:px-5"
+ >
+ {{ date.formatDate(invoice.date) }}
+ </TableCell>
+ <TableCell class="border-r-0 px-4 py-3 tabular-nums">
+ {{ invoice.total }}
+ </TableCell>
+ <TableCell class="border-r-0 px-4 py-3">
+ <Badge variant="success">
+ {{ $t('billing.invoices.paid') }}
+ </Badge>
+ </TableCell>
+ <TableCell class="border-r-0 px-2 py-2 text-right">
+ <Button
+ v-if="invoice.invoice_pdf"
+ variant="ghost"
+ size="icon"
+ as="a"
+ :href="invoice.invoice_pdf"
+ target="_blank"
+ rel="noopener"
+ class="text-muted-foreground"
+ :aria-label="$t('billing.invoices.download')"
+ :data-testid="`billing-invoice-download-${invoice.id}`"
+ >
+ <IconDownload class="size-4" />
+ </Button>
+ </TableCell>
+ </TableRow>
+ </TableBody>
+ </Table>
+ </div>
+
+ <template #next="{ loading }">
+ <TableLoadMore v-if="loading" />
</template>
- </SettingsListRow>
- </ul>
- </SettingsSection>
- </div>
+ </InfiniteScroll>
+ </div>
+ </TabsContent>
+ </Tabs>
</SettingsLayout>
</template>
diff --git a/resources/js/pages/welcome/Plan.vue b/resources/js/pages/welcome/Plan.vue
index 85645848f..5059f7dc9 100644
--- a/resources/js/pages/welcome/Plan.vue
+++ b/resources/js/pages/welcome/Plan.vue
@@ -6,22 +6,52 @@ import { computed } from 'vue';
import PlanFeatureList from '@/components/billing/PlanFeatureList.vue';
import ReviewQuote from '@/components/reviews/ReviewQuote.vue';
import WelcomeContinueButton from '@/components/welcome/WelcomeContinueButton.vue';
+import WelcomeOfferBanner from '@/components/welcome/WelcomeOfferBanner.vue';
import { useAutoRotate } from '@/composables/useAutoRotate';
import WelcomeLayout from '@/layouts/WelcomeLayout.vue';
import { REVIEWS } from '@/lib/reviews';
import { store } from '@/routes/app/welcome/plan';
+import type { Offer } from '@/types/offer';
import type { PlanOption } from '@/types/plan';
const props = defineProps<{
plan: PlanOption;
- firstMonthOffer: boolean;
+ offer: Offer | null;
}>();
-const checkoutPriceKey = computed((): string =>
- props.firstMonthOffer
- ? 'billing.subscribe.prices.first_month'
- : 'billing.subscribe.prices.socials.monthly',
-);
+interface PriceCopy {
+ price: string;
+ unit: string | null;
+ period: string | null;
+ checkoutButton: string;
+ terms: string;
+}
+
+const FULL_PRICE_COPY: PriceCopy = {
+ price: 'billing.subscribe.prices.socials.monthly',
+ unit: 'billing.plans.per_month',
+ period: null,
+ checkoutButton: 'welcome.plan_checkout_button',
+ terms: 'welcome.plan_cancel_anytime',
+};
+
+const priceCopy = computed((): PriceCopy => {
+ if (!props.offer?.has_checkout_copy) {
+ return FULL_PRICE_COPY;
+ }
+
+ const offerCopy = `offers.${props.offer.key}`;
+
+ return {
+ price: `${offerCopy}.price`,
+ unit: props.offer.has_unit ? `${offerCopy}.unit` : null,
+ period: `${offerCopy}.period`,
+ checkoutButton: `${offerCopy}.checkout_button`,
+ terms: props.offer.has_terms
+ ? `${offerCopy}.terms`
+ : 'welcome.plan_terms',
+ };
+});
const form = useForm({});
@@ -55,6 +85,8 @@ const submit = (): void => {
:description="$t('welcome.plan_description')"
step="plan"
>
+ <WelcomeOfferBanner v-if="offer?.has_banner" :offer-key="offer.key" />
+
<article
class="grid overflow-hidden rounded-xl text-start sm:grid-cols-[2fr_3fr]"
:data-testid="`plan-card-${plan.slug}`"
@@ -133,22 +165,34 @@ const submit = (): void => {
</div>
</div>
- <p class="flex flex-col gap-1">
- <span
- class="text-5xl leading-none font-strong tabular-nums"
- :data-testid="`plan-price-${plan.slug}`"
- >{{ $t(checkoutPriceKey) }}</span
+ <div class="flex flex-col gap-1">
+ <s
+ v-if="priceCopy.period"
+ class="text-sm text-muted-foreground"
+ :data-testid="`plan-price-original-${plan.slug}`"
+ >{{ $t('billing.subscribe.prices.socials.monthly')
+ }}{{ $t('billing.plans.per_month') }}</s
>
+ <p class="flex items-baseline gap-1 whitespace-nowrap">
+ <span
+ class="text-4xl leading-none font-strong tracking-tight tabular-nums [word-spacing:-0.15em] sm:text-5xl"
+ :data-testid="`plan-price-${plan.slug}`"
+ >{{ $t(priceCopy.price) }}</span
+ >
+ <span
+ v-if="priceCopy.unit"
+ class="text-base text-foreground"
+ :data-testid="`plan-price-unit-${plan.slug}`"
+ >{{ $t(priceCopy.unit) }}</span
+ >
+ </p>
<span
+ v-if="priceCopy.period"
class="text-base text-foreground"
:data-testid="`plan-price-suffix-${plan.slug}`"
- >{{
- firstMonthOffer
- ? $t('welcome.plan_first_month')
- : $t('welcome.plan_per_month')
- }}</span
+ >{{ $t(priceCopy.period) }}</span
>
- </p>
+ </div>
</div>
<PlanFeatureList
@@ -163,9 +207,7 @@ const submit = (): void => {
:processing="form.processing"
:disabled="form.processing"
:label="
- $t('billing.plans.start_first_month', {
- price: $t(checkoutPriceKey),
- })
+ $t(priceCopy.checkoutButton)
"
testid="welcome-plan-continue"
@continue="submit"
@@ -175,11 +217,9 @@ const submit = (): void => {
data-testid="welcome-plan-terms"
>
{{
- firstMonthOffer
- ? $t('welcome.plan_terms', {
- price: $t('billing.subscribe.prices.socials.monthly'),
- })
- : $t('welcome.plan_cancel_anytime')
+ $t(priceCopy.terms, {
+ price: $t('billing.subscribe.prices.socials.monthly'),
+ })
}}
</p>
</template>
diff --git a/resources/js/types/billing.ts b/resources/js/types/billing.ts
new file mode 100644
index 000000000..97c291a69
--- /dev/null
+++ b/resources/js/types/billing.ts
@@ -0,0 +1,27 @@
+export interface Subscription {
+ stripe_status: string;
+ ends_at: string | null;
+}
+
+export interface PaymentMethod {
+ id: string;
+ brand: string;
+ last4: string;
+ exp_month: number;
+ exp_year: number;
+ is_default: boolean;
+}
+
+export interface SubscriptionDiscount {
+ value: string;
+ duration: 'once' | 'repeating' | 'forever';
+ ends_at: string | null;
+}
+
+export interface Invoice {
+ id: string;
+ date: string;
+ total: string;
+ status: string;
+ invoice_pdf: string | null;
+}
diff --git a/resources/js/types/offer.ts b/resources/js/types/offer.ts
new file mode 100644
index 000000000..f804c8b32
--- /dev/null
+++ b/resources/js/types/offer.ts
@@ -0,0 +1,7 @@
+export interface Offer {
+ key: string;
+ has_banner: boolean;
+ has_checkout_copy: boolean;
+ has_unit: boolean;
+ has_terms: boolean;
+}
diff --git a/routes/app.php b/routes/app.php
index ad852b5ef..9e7c47a13 100644
--- a/routes/app.php
+++ b/routes/app.php
@@ -413,6 +413,7 @@ Route::middleware(['auth', EnsureAccountReady::class, EnsureHasWorkspace::class]
Route::get('settings/account/billing', [BillingController::class, 'index'])->name('app.billing.index');
Route::get('settings/account/billing/portal', [BillingController::class, 'portal'])->name('app.billing.portal');
Route::post('settings/account/billing/change-plan', [BillingController::class, 'changePlan'])->name('app.billing.change-plan');
+ Route::post('settings/account/billing/checkout', [BillingController::class, 'checkout'])->name('app.billing.checkout');
});
diff --git a/tests/Browser/BillingPageTest.php b/tests/Browser/BillingPageTest.php
index c1200ec51..b19e65083 100644
--- a/tests/Browser/BillingPageTest.php
+++ b/tests/Browser/BillingPageTest.php
@@ -3,25 +3,17 @@
declare(strict_types=1);
use App\Enums\Plan\Slug;
+use App\Models\Account;
use App\Models\Plan;
use App\Models\User;
use App\Models\Workspace;
+use Stripe\ApiRequestor;
-function waitForBillingPageTestId(mixed $page, string $testId): void
-{
- $page->script(<<<JS
- (async () => {
- const selector = '[data-testid="{$testId}"]';
- for (let attempt = 0; attempt < 200; attempt++) {
- const element = document.querySelector(selector);
- if (element && element.getBoundingClientRect().height > 0) return;
- await new Promise((resolve) => setTimeout(resolve, 50));
- }
- })();
- JS);
-}
+afterEach(function () {
+ ApiRequestor::setHttpClient(null);
+});
-function billingPageOwner(): User
+function billingPageOwner(bool $subscribed = true): User
{
$user = User::factory()->create();
$user->account->update([
@@ -34,7 +26,10 @@ function billingPageOwner(): User
]);
$workspace->members()->attach($user->id, membershipPivot('admin'));
$user->update(['current_workspace_id' => $workspace->id]);
- subscribeAccount($user->account);
+
+ if ($subscribed) {
+ subscribeAccount($user->account);
+ }
return $user->fresh();
}
@@ -45,19 +40,21 @@ test('the billing page shows the current plan and changes plans in a dialog', fu
$this->actingAs(billingPageOwner());
$page = visit(route('app.billing.index'));
- waitForBillingPageTestId($page, 'billing-current-plan');
+ waitFor($page, '@billing-current-plan');
$page->assertSeeIn('@billing-current-plan-name', 'Socials')
- ->assertSeeIn('@billing-current-plan-price', '$19/month')
- ->assertSeeIn('@billing-current-plan-status', 'Renews automatically')
- ->assertSeeIn('@billing-current-plan-usage', 'Workspaces: 1 of 1')
+ ->assertSeeIn('@billing-current-plan-price', '$19')
+ ->assertSeeIn('@billing-current-plan-price', '/month')
+ ->assertSeeIn('@billing-current-plan-badge', 'Active')
+ ->assertMissing('@billing-current-plan-status')
+ ->assertMissing('@billing-current-plan-usage')
->assertVisible('@settings-nav-billing')
->assertMissing('@settings-nav-account')
->assertMissing('@billing-details-form')
->assertMissing('@plan-card-socials');
$page->click('@billing-change-plan');
- waitForBillingPageTestId($page, 'plan-card-workspaces');
+ waitFor($page, '@plan-card-workspaces');
$page->assertVisible('@billing-plan-dialog')
->assertVisible('@plan-card-socials')
@@ -67,7 +64,7 @@ test('the billing page shows the current plan and changes plans in a dialog', fu
->assertSeeIn('@plan-price-socials', '$19');
$page->click('@plan-interval-yearly');
- waitForBillingPageTestId($page, 'plan-save-two-months');
+ waitFor($page, '@plan-save-two-months');
$page->assertSeeIn('@plan-price-socials', '$15.83')
->assertSeeIn('@plan-select-socials', 'Switch to yearly')
@@ -82,9 +79,172 @@ test('self-hosted settings show neither an account nor a billing item', function
$this->actingAs(billingPageOwner());
$page = visit(route('app.profile.edit'));
- waitForBillingPageTestId($page, 'settings-nav-profile');
+ waitFor($page, '@settings-nav-profile');
$page->assertMissing('@settings-nav-account')
->assertMissing('@settings-nav-billing')
->assertNoJavaScriptErrors();
});
+
+test('the billing page explains a discount and lists every card, the default first', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = billingPageOwner(subscribed: false);
+ fakeStripeBilling(
+ $user->account,
+ ['percent_off' => 50, 'amount_off' => null, 'currency' => null, 'duration' => 'repeating', 'duration_in_months' => 3],
+ now()->addMonths(3)->timestamp,
+ 'visa',
+ secondCardBrand: 'mastercard',
+ );
+ $this->actingAs($user->fresh());
+
+ $page = visit(route('app.billing.index'));
+ waitFor($page, '@billing-card-pm_fake_second');
+
+ $page->assertSeeIn('@billing-current-plan-price', '$19')
+ ->assertSeeIn('@billing-current-plan-discount', '50% off until')
+ ->assertSeeIn('@billing-card-pm_fake', 'Visa')
+ ->assertSeeIn('@billing-card-pm_fake', '•••• 4242')
+ ->assertSeeIn('@billing-card-pm_fake', 'Default')
+ ->assertSeeIn('@billing-card-pm_fake_second', 'Mastercard')
+ ->assertSeeIn('@billing-card-pm_fake_second', '•••• 5454')
+ ->assertDontSeeIn('@billing-card-pm_fake_second', 'Default')
+ ->assertVisible('@billing-manage-stripe')
+ ->assertNoJavaScriptErrors();
+
+ $page->assertAttribute('@billing-card-logo-pm_fake', 'src', '/images/card-brands/visa.svg')
+ ->assertAttribute('@billing-card-logo-pm_fake_second', 'src', '/images/card-brands/mastercard.svg');
+
+ waitForState($page, '@billing-card-logo-pm_fake_second', 'element.complete && element.naturalWidth > 0');
+
+ expect($page->script("[...document.querySelectorAll('[data-testid=\"billing-payment-methods\"] > [data-testid^=\"billing-card-\"]')].map((item) => item.dataset.testid)"))
+ ->toBe(['billing-card-pm_fake', 'billing-card-pm_fake_second'])
+ ->and($page->script("document.querySelector('[data-testid=\"billing-card-logo-pm_fake_second\"]').naturalWidth > 0"))->toBeTrue();
+});
+
+test('the billing page shows the generic card for a brand without its own logo', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = billingPageOwner(subscribed: false);
+ fakeStripeBilling($user->account, cardBrand: 'eftpos_au');
+ $this->actingAs($user->fresh());
+
+ $page = visit(route('app.billing.index'));
+ waitFor($page, '@billing-card-label');
+
+ $page->assertSeeIn('@billing-card-label', 'eftpos')
+ ->assertAttribute('@billing-card-logo-pm_fake', 'src', '/images/card-brands/generic.svg')
+ ->assertMissing('@billing-current-plan-discount')
+ ->assertNoJavaScriptErrors();
+});
+
+test('the invoices tab lists the paid invoices and loads more on scroll', function () {
+ config(['trypost.self_hosted' => false, 'app.pagination.default' => 10]);
+
+ $user = billingPageOwner(subscribed: false);
+ fakeStripeBilling($user->account, paidInvoices: 12);
+ $this->actingAs($user->fresh());
+
+ $page = visit(route('app.billing.index'));
+ waitFor($page, '@billing-tab-invoices');
+
+ $page->assertMissing('@billing-invoices')
+ ->click('@billing-tab-invoices');
+ waitFor($page, '@billing-invoice-in_fake_012');
+ waitForCondition($page, "new URLSearchParams(location.search).get('tab') === 'invoices'");
+
+ $page->assertSeeIn('@billing-invoice-in_fake_012', '$19.00')
+ ->assertSeeIn('@billing-invoice-in_fake_012', 'Paid')
+ ->assertVisible('@billing-invoice-download-in_fake_012');
+
+ $page->script('window.scrollTo(0, document.body.scrollHeight)');
+ waitFor($page, '@billing-invoice-in_fake_001');
+
+ $page->assertVisible('@billing-invoice-in_fake_001')
+ ->assertMissing('@billing-current-plan')
+ ->assertNoJavaScriptErrors();
+});
+
+test('the invoices tab opens from the link and says when there are none yet', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = billingPageOwner(subscribed: false);
+ fakeStripeBilling($user->account);
+ $this->actingAs($user->fresh());
+
+ $page = visit(route('app.billing.index', ['tab' => 'invoices']));
+ waitFor($page, '@billing-invoices-empty');
+
+ $page->assertSeeIn('@billing-invoices-empty', 'No invoices yet')
+ ->assertMissing('@billing-invoices')
+ ->assertNoJavaScriptErrors();
+});
+
+test('a trial shows when it ends, with the time in the user\'s time zone', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = billingPageOwner(subscribed: false);
+ $user->update(['timezone' => 'America/Sao_Paulo']);
+ $endsAt = now()->addDays(7)->setTime(15, 30)->utc();
+ $user->account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_trial',
+ 'stripe_status' => 'trialing',
+ 'stripe_price' => 'price_123',
+ 'trial_ends_at' => $endsAt,
+ ]);
+ $this->actingAs($user->fresh());
+
+ $page = visit(route('app.billing.index'));
+ waitFor($page, '@billing-current-plan-status');
+
+ $page->assertSeeIn('@billing-current-plan-badge', 'Trial')
+ ->assertSeeIn('@billing-current-plan-status', 'Trial until '.$endsAt->setTimezone('America/Sao_Paulo')->format('F j, Y g:i A'))
+ ->assertNoJavaScriptErrors();
+});
+
+test('a trial without a card shows when it ends and offers to subscribe', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = billingPageOwner(subscribed: false);
+ $user->update(['timezone' => 'America/Sao_Paulo']);
+ $endsAt = now()->addDays(7)->setTime(15, 30)->utc();
+ $user->account->update(['trial_ends_at' => $endsAt]);
+ $this->actingAs($user->fresh());
+
+ $page = visit(route('app.billing.index'));
+ waitFor($page, '@billing-subscribe');
+
+ $page->assertSeeIn('@billing-current-plan-name', 'Socials')
+ ->assertSeeIn('@billing-current-plan-badge', 'Trial')
+ ->assertSeeIn('@billing-current-plan-status', 'Trial until '.$endsAt->setTimezone('America/Sao_Paulo')->format('F j, Y g:i A'))
+ ->assertVisible('@billing-current-plan-trial-icon')
+ ->assertSeeIn('@billing-subscribe', 'Subscribe now')
+ ->assertMissing('@billing-change-plan')
+ ->assertMissing('@billing-manage-stripe')
+ ->assertNoJavaScriptErrors();
+});
+
+test('a trial cancelled in Stripe shows when it ends instead of the trial', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = billingPageOwner(subscribed: false);
+ $endsAt = now()->addDays(5);
+ $user->account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_trial_cancelled',
+ 'stripe_status' => 'trialing',
+ 'stripe_price' => 'price_123',
+ 'trial_ends_at' => $endsAt,
+ 'ends_at' => $endsAt,
+ ]);
+ $this->actingAs($user->fresh());
+
+ $page = visit(route('app.billing.index'));
+ waitFor($page, '@billing-current-plan-status');
+
+ $page->assertSeeIn('@billing-current-plan-badge', 'Cancelled')
+ ->assertDontSeeIn('@billing-current-plan-status', 'Trial until')
+ ->assertNoJavaScriptErrors();
+});
diff --git a/tests/Browser/BillingProcessingTest.php b/tests/Browser/BillingProcessingTest.php
index d284bd94c..4af2567ba 100644
--- a/tests/Browser/BillingProcessingTest.php
+++ b/tests/Browser/BillingProcessingTest.php
@@ -6,30 +6,6 @@ use App\Models\Plan;
use App\Models\User;
use App\Models\Workspace;
-function waitForBillingProcessingTestId(mixed $page, string $testId): void
-{
- $page->script(<<<JS
- (async () => {
- for (let attempt = 0; attempt < 100; attempt++) {
- if (document.querySelector('[data-testid="{$testId}"]')) return;
- await new Promise((resolve) => setTimeout(resolve, 50));
- }
- })();
- JS);
-}
-
-function waitForBillingProcessingPath(mixed $page, string $path): void
-{
- $page->script(<<<JS
- (async () => {
- for (let attempt = 0; attempt < 200; attempt++) {
- if (window.location.pathname === '{$path}') return;
- await new Promise((resolve) => setTimeout(resolve, 50));
- }
- })();
- JS);
-}
-
function billingProcessingSubscriber(): User
{
$user = User::factory()->create();
@@ -53,12 +29,28 @@ test('once the subscription and plan are ready the processing page sends the use
$mcpPath = parse_url(route('app.welcome.mcp'), PHP_URL_PATH);
$page = visit(route('app.billing.processing'));
- waitForBillingProcessingPath($page, $mcpPath);
+ waitForPath($page, $mcpPath);
$page->assertPathIs($mcpPath)
->assertNoJavaScriptErrors();
});
+test('a subscription started from billing returns to billing, not the onboarding', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = billingProcessingSubscriber();
+ Plan::query()->whereKey($user->account->plan_id)->update(['stripe_monthly_price_id' => 'price_123']);
+ $this->actingAs($user->fresh());
+
+ $billingPath = parse_url(route('app.billing.index'), PHP_URL_PATH);
+
+ $page = visit(route('app.billing.processing', ['from' => 'billing']));
+ waitForPath($page, $billingPath);
+
+ $page->assertPathIs($billingPath)
+ ->assertNoJavaScriptErrors();
+});
+
test('on a phone the processing page skips the MCP step and opens the schedule', function () {
config(['trypost.self_hosted' => false]);
@@ -67,7 +59,7 @@ test('on a phone the processing page skips the MCP step and opens the schedule',
$schedulePath = parse_url(route('app.posts.index'), PHP_URL_PATH);
$page = visit(route('app.billing.processing'))->on()->mobile();
- waitForBillingProcessingPath($page, $schedulePath);
+ waitForPath($page, $schedulePath);
$page->assertPathIs($schedulePath)
->assertNoJavaScriptErrors();
@@ -87,7 +79,7 @@ test('while checkout settles the processing page uses the neutral auth layout, n
$this->actingAs($user);
$page = visit(route('app.billing.processing'));
- waitForBillingProcessingTestId($page, 'billing-processing');
+ waitFor($page, '@billing-processing');
$page->assertSee('Processing your subscription')
->assertVisible('@billing-processing')
diff --git a/tests/Browser/DarkModeSurfacesTest.php b/tests/Browser/DarkModeSurfacesTest.php
index 72ac71d36..209067ad8 100644
--- a/tests/Browser/DarkModeSurfacesTest.php
+++ b/tests/Browser/DarkModeSurfacesTest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
use App\Enums\PostPlatform\ContentType;
use App\Enums\SocialAccount\Platform;
use App\Enums\User\Theme;
diff --git a/tests/Browser/SignupOfferTest.php b/tests/Browser/SignupOfferTest.php
new file mode 100644
index 000000000..8b326b52b
--- /dev/null
+++ b/tests/Browser/SignupOfferTest.php
@@ -0,0 +1,77 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Models\Account;
+use App\Models\Offer;
+use App\Models\User;
+
+beforeEach(function () {
+ config()->set('trypost.self_hosted', false);
+ $this->offer = Offer::factory()->create(['slug' => 'black-friday-2026']);
+});
+
+test('an offer opened on the register page survives a trip to login and back to signup', function () {
+ $page = visit(route('register', ['offer' => 'black-friday-2026']));
+ waitFor($page, '@register-log-in-link');
+
+ $page->click('@register-log-in-link');
+ waitFor($page, '@login-sign-up-link');
+ $page->assertPathIs(parse_url(route('login'), PHP_URL_PATH));
+
+ $page->click('@login-sign-up-link');
+ waitFor($page, '@register-name');
+ $page->assertPathIs(parse_url(route('register'), PHP_URL_PATH));
+
+ $page->type('@register-name', 'Offer Visitor')
+ ->type('@register-email', '[email protected]')
+ ->type('@register-password', strongPassword())
+ ->click('@register-user-button');
+ waitForPath($page, parse_url(route('app.welcome.persona'), PHP_URL_PATH));
+
+ $page->assertNoJavaScriptErrors();
+
+ expect(User::query()->where('email', '[email protected]')->firstOrFail()->account->offers()->pluck('offers.id')->all())
+ ->toBe([$this->offer->id]);
+});
+
+test('an offer opened on the login page survives a trip to signup and back to login', function () {
+ $account = Account::factory()->create();
+ $owner = User::factory()->create(['account_id' => $account->id, 'email' => '[email protected]']);
+ $account->update(['owner_id' => $owner->id]);
+
+ $page = visit(route('login', ['offer' => 'black-friday-2026']));
+ waitFor($page, '@login-sign-up-link');
+
+ $page->click('@login-sign-up-link');
+ waitFor($page, '@register-log-in-link');
+ $page->assertPathIs(parse_url(route('register'), PHP_URL_PATH));
+
+ $page->click('@register-log-in-link');
+ waitFor($page, '@login-email');
+ $page->assertPathIs(parse_url(route('login'), PHP_URL_PATH));
+
+ $page->type('@login-email', '[email protected]')
+ ->type('@login-password', 'password')
+ ->click('@login-submit');
+ waitForPath($page, parse_url(route('app.welcome.persona'), PHP_URL_PATH));
+
+ $page->assertNoJavaScriptErrors();
+
+ expect($account->offers()->pluck('offers.id')->all())->toBe([$this->offer->id]);
+});
+
+test('a link to an unknown offer signs the visitor up without one', function () {
+ $page = visit(route('register', ['offer' => 'no-such-offer']));
+ waitFor($page, '@register-name');
+
+ $page->type('@register-name', 'Plain Visitor')
+ ->type('@register-email', '[email protected]')
+ ->type('@register-password', strongPassword())
+ ->click('@register-user-button');
+ waitForPath($page, parse_url(route('app.welcome.persona'), PHP_URL_PATH));
+
+ $page->assertNoJavaScriptErrors();
+
+ expect(User::query()->where('email', '[email protected]')->firstOrFail()->account->offers()->count())->toBe(0);
+});
diff --git a/tests/Browser/WelcomePlanTest.php b/tests/Browser/WelcomePlanTest.php
index 72675a111..11c01b7cb 100644
--- a/tests/Browser/WelcomePlanTest.php
+++ b/tests/Browser/WelcomePlanTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
use App\Enums\User\Goal;
use App\Enums\User\Persona;
use App\Enums\User\PreviousSoftware;
+use App\Models\Offer;
use App\Models\User;
use App\Models\Workspace;
use Illuminate\Support\Str;
@@ -13,22 +14,6 @@ use Illuminate\Support\Str;
* Wait for a data-testid element to mount and lay out. Pest browser `@`
* selectors resolve to data-testid, and assertions do not auto-wait on SPA paint.
*/
-function waitForWelcomePlanTestId(mixed $page, string $testId): void
-{
- $page->script(<<<JS
- (async () => {
- const sel = '[data-testid="{$testId}"]';
- for (let i = 0; i < 100; i++) {
- const el = document.querySelector(sel);
- if (el && el.getBoundingClientRect().height > 0) return;
- await new Promise((resolve) => setTimeout(resolve, 50));
- }
- })();
- JS);
-
- waitForWebFonts($page);
-}
-
function welcomePlanVisibleReview(mixed $page): ?string
{
return $page->script(<<<'JS'
@@ -131,32 +116,6 @@ function welcomePlanPhoneLayout(mixed $page): array
JS);
}
-function waitForWelcomePlanPopoverOpen(mixed $page): bool
-{
- return $page->script(<<<'JS'
- (async () => {
- for (let i = 0; i < 50; i++) {
- if (document.querySelector('[data-slot="popover-content"]')) return true;
- await new Promise((resolve) => setTimeout(resolve, 50));
- }
- return false;
- })()
- JS);
-}
-
-function waitForWelcomePlanPopoverClosed(mixed $page): bool
-{
- return $page->script(<<<'JS'
- (async () => {
- for (let i = 0; i < 50; i++) {
- if (!document.querySelector('[data-slot="popover-content"]')) return true;
- await new Promise((resolve) => setTimeout(resolve, 50));
- }
- return false;
- })()
- JS);
-}
-
function welcomePlanFocus(mixed $page, string $testId): void
{
$page->script(<<<JS
@@ -207,26 +166,34 @@ function welcomeOwnerOnPlanStep(): User
return $user->fresh();
}
-test('the plan step shows the offer, what is included and the G2 rating', function () {
- config(['trypost.self_hosted' => false, 'cashier.first_month_coupon_ids.socials' => 'coupon_socials']);
+test('the plan step shows the free trial offer, what is included and the G2 rating', function () {
+ config(['trypost.self_hosted' => false]);
- $this->actingAs(welcomeOwnerOnPlanStep());
+ $user = welcomeOwnerOnPlanStep();
+ $user->account->offers()->attach(Offer::factory()->freeTrial()->create(), ['claimed_at' => now()]);
+ $this->actingAs($user);
$page = visit(route('app.welcome.plan'));
- waitForWelcomePlanTestId($page, 'plan-card-socials');
- waitForWelcomePlanTestId($page, 'welcome-plan-reviews');
- waitForWelcomePlanTestId($page, 'welcome-plan-continue');
+ waitFor($page, '@plan-card-socials');
+ waitForWebFonts($page);
+ waitFor($page, '@welcome-plan-reviews');
+ waitForWebFonts($page);
+ waitFor($page, '@welcome-plan-continue');
+ waitForWebFonts($page);
$page->assertRoute('app.welcome.plan')
->assertSee('Activate your account')
->assertSee('Connect your channels and schedule your first post today.')
->assertMissing('@plan-card-workspaces')
- ->assertSeeIn('@plan-price-socials', '$1')
- ->assertSeeIn('@plan-price-suffix-socials', 'for your first month')
+ ->assertSeeIn('@plan-price-socials', 'Free')
+ ->assertSeeIn('@plan-price-suffix-socials', 'for 7 days')
+ ->assertSeeIn('@plan-price-original-socials', '$19/month')
+ ->assertMissing('@plan-price-unit-socials')
->assertVisible('@plan-networks-info-socials')
- ->assertSeeIn('@welcome-plan-continue', 'Activate for $1')
- ->assertSeeIn('@welcome-plan-terms', 'Then $19/month. Cancel anytime.')
+ ->assertSeeIn('@welcome-plan-continue', 'Start free trial')
+ ->assertSeeIn('@welcome-plan-terms', 'Then $19/month. Cancel anytime')
+ ->assertMissing('@welcome-plan-offer')
->assertVisible('@welcome-step-plan')
->assertNoJavaScriptErrors();
@@ -249,22 +216,27 @@ test('the plan step shows the offer, what is included and the G2 rating', functi
->assertVisible('@plan-feature-info-socials-ideas');
});
-test('the plan step shows the full price when checkout will not apply the first-month coupon', function () {
- config(['trypost.self_hosted' => false, 'cashier.first_month_coupon_ids.socials' => '']);
+test('the plan step shows the full price without an offer, even when a trial offer exists', function () {
+ config(['trypost.self_hosted' => false]);
+ Offer::factory()->freeTrial()->create();
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'));
- waitForWelcomePlanTestId($page, 'welcome-plan-continue');
+ waitFor($page, '@welcome-plan-continue');
+ waitForWebFonts($page);
$page->assertSeeIn('@plan-price-socials', '$19')
- ->assertSeeIn('@plan-price-suffix-socials', 'per month')
- ->assertSeeIn('@welcome-plan-continue', 'Activate for $19')
- ->assertSeeIn('@welcome-plan-terms', 'Cancel anytime.')
- ->assertDontSee('first month')
+ ->assertSeeIn('@plan-price-unit-socials', '/month')
+ ->assertMissing('@plan-price-original-socials')
+ ->assertMissing('@plan-price-suffix-socials')
+ ->assertSeeIn('@welcome-plan-continue', 'Activate my account')
+ ->assertSeeIn('@welcome-plan-terms', 'Cancel anytime')
+ ->assertDontSee('7 days')
->assertNoJavaScriptErrors();
- expect(trim((string) $page->text('@plan-price-socials')))->toBe('$19');
+ expect(trim((string) $page->text('@plan-price-socials')))->toBe('$19')
+ ->and(trim((string) $page->text('@welcome-plan-terms')))->toBe('Cancel anytime');
});
test('the plan step does not list the workspace limit, so team members close the list', function () {
@@ -273,7 +245,8 @@ test('the plan step does not list the workspace limit, so team members close the
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'));
- waitForWelcomePlanTestId($page, 'plan-feature-list-socials');
+ waitFor($page, '@plan-feature-list-socials');
+ waitForWebFonts($page);
expect(welcomePlanLastFeatureLabelTestId($page, 'plan-feature-list-socials'))->toBe('plan-feature-label-socials-team');
@@ -288,7 +261,8 @@ test('the review quotes rotate on their own', function () {
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'));
- waitForWelcomePlanTestId($page, 'welcome-plan-review-paulo_dantas');
+ waitFor($page, '@welcome-plan-review-paulo_dantas');
+ waitForWebFonts($page);
expect(welcomePlanVisibleReview($page))->toBe('welcome-plan-review-paulo_dantas')
->and(waitForWelcomePlanReviewOtherThan($page, 'welcome-plan-review-paulo_dantas'))->toBe('welcome-plan-review-diego');
@@ -300,10 +274,12 @@ test('clicking a reviewer photo shows their quote', function () {
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'));
- waitForWelcomePlanTestId($page, 'welcome-plan-reviewer-pedro');
+ waitFor($page, '@welcome-plan-reviewer-pedro');
+ waitForWebFonts($page);
$page->click('@welcome-plan-reviewer-pedro');
- waitForWelcomePlanTestId($page, 'welcome-plan-review-pedro');
+ waitFor($page, '@welcome-plan-review-pedro');
+ waitForWebFonts($page);
$page->assertVisible('@welcome-plan-review-pedro')
->assertAttribute('@welcome-plan-reviewer-pedro', 'aria-pressed', 'true')
@@ -319,7 +295,8 @@ test('the plan step fits a phone without scrolling and hides the quotes there',
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'))->resize(390, 844);
- waitForWelcomePlanTestId($page, 'plan-card-socials');
+ waitFor($page, '@plan-card-socials');
+ waitForWebFonts($page);
expect(welcomePlanPhoneLayout($page))->toBe(['scrolls' => false, 'quoteVisible' => false]);
@@ -333,16 +310,20 @@ test('the feature info opens on a tap or click', function (int $width, int $heig
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'))->resize($width, $height);
- waitForWelcomePlanTestId($page, 'plan-feature-info-socials-team');
+ waitFor($page, '@plan-feature-info-socials-team');
+ waitForWebFonts($page);
$page->click('@plan-feature-info-socials-team');
- waitForWelcomePlanTestId($page, 'plan-feature-info-socials-team');
+ waitFor($page, '@plan-feature-info-socials-team');
+ waitForWebFonts($page);
- expect(waitForWelcomePlanPopoverOpen($page))->toBeTrue()
- ->and(trim((string) $page->text('[data-slot="popover-content"]')))->toStartWith('Invite as many people as you want');
+ waitFor($page, '[data-slot="popover-content"]');
+
+ expect(trim((string) $page->text('[data-slot="popover-content"]')))->toStartWith('Invite as many people as you want');
$page->click('@plan-networks-info-socials');
- waitForWelcomePlanTestId($page, 'plan-networks-socials');
+ waitFor($page, '@plan-networks-socials');
+ waitForWebFonts($page);
$page->assertVisible('@plan-networks-socials')
->assertNoJavaScriptErrors();
@@ -357,16 +338,19 @@ test('the feature info opens from the keyboard and closes with Escape', function
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'))->resize(1440, 900);
- waitForWelcomePlanTestId($page, 'plan-feature-info-socials-team');
+ waitFor($page, '@plan-feature-info-socials-team');
+ waitForWebFonts($page);
welcomePlanFocus($page, 'plan-feature-info-socials-team');
$page->keys('@plan-feature-info-socials-team', 'Enter');
- expect(waitForWelcomePlanPopoverOpen($page))->toBeTrue();
+ waitFor($page, '[data-slot="popover-content"]');
+ $page->assertVisible('[data-slot="popover-content"]');
$page->keys('@plan-feature-info-socials-team', 'Escape');
+ waitForGone($page, '[data-slot="popover-content"]');
- expect(waitForWelcomePlanPopoverClosed($page))->toBeTrue();
+ $page->assertMissing('[data-slot="popover-content"]');
$page->assertNoJavaScriptErrors();
});
@@ -377,10 +361,92 @@ test('the activate button shows a spinner while checkout opens', function () {
$this->actingAs(welcomeOwnerOnPlanStep());
$page = visit(route('app.welcome.plan'));
- waitForWelcomePlanTestId($page, 'welcome-plan-continue');
+ waitFor($page, '@welcome-plan-continue');
+ waitForWebFonts($page);
welcomePlanStallRequests($page);
$page->click('@welcome-plan-continue');
expect(waitForWelcomePlanButtonSpinner($page, 'welcome-plan-continue'))->toBe(['spinner' => true, 'disabled' => true]);
});
+
+test('the plan step shows an offer\'s banner and price', function (string $offer, string $name, string $headline, string $price, ?string $unit, string $period) {
+ config(['trypost.self_hosted' => false]);
+
+ $user = welcomeOwnerOnPlanStep();
+ $user->account->offers()->attach(Offer::factory()->{$offer}()->withBanner()->create(), ['claimed_at' => now()]);
+ $this->actingAs($user);
+
+ $page = visit(route('app.welcome.plan'));
+ waitFor($page, '@welcome-plan-offer');
+
+ $page->assertSeeIn('@welcome-plan-offer-name', $name)
+ ->assertSeeIn('@welcome-plan-offer-headline', $headline)
+ ->assertSeeIn('@plan-price-original-socials', '$19/month')
+ ->assertSeeIn('@plan-price-socials', $price)
+ ->assertSeeIn('@plan-price-suffix-socials', $period)
+ ->assertSeeIn('@welcome-plan-continue', 'Activate my account')
+ ->assertSeeIn('@welcome-plan-terms', 'Then $19/month. Cancel anytime')
+ ->assertNoJavaScriptErrors();
+
+ if ($unit === null) {
+ $page->assertMissing('@plan-price-unit-socials');
+ } else {
+ $page->assertSeeIn('@plan-price-unit-socials', $unit);
+ }
+})->with([
+ 'black friday shows its unit' => ['blackFriday', 'Black Friday', '50% off your first 3 months', '$9.50', '/month', 'for your first 3 months'],
+ 'first month has no unit' => ['firstMonth', 'First month', 'Your first month for $1', '$1', null, 'for your first month'],
+]);
+
+test('the plan step keeps an offer\'s price but hides its banner when the offer does not show one', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = welcomeOwnerOnPlanStep();
+ $user->account->offers()->attach(Offer::factory()->blackFriday()->create(['show_banner' => false]), ['claimed_at' => now()]);
+ $this->actingAs($user);
+
+ $page = visit(route('app.welcome.plan'));
+ waitFor($page, '@plan-price-socials');
+
+ $page->assertMissing('@welcome-plan-offer')
+ ->assertSeeIn('@plan-price-socials', '$9.50')
+ ->assertNoJavaScriptErrors();
+});
+
+test('the plan step shows neither a banner nor an offer price for an offer without copy', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = welcomeOwnerOnPlanStep();
+ $user->account->offers()->attach(Offer::factory()->create(), ['claimed_at' => now()]);
+ $this->actingAs($user);
+
+ $page = visit(route('app.welcome.plan'));
+ waitFor($page, '@plan-price-socials');
+
+ $page->assertMissing('@welcome-plan-offer')
+ ->assertSeeIn('@plan-price-unit-socials', '/month')
+ ->assertMissing('@plan-price-original-socials')
+ ->assertDontSee('offers.')
+ ->assertNoJavaScriptErrors();
+
+ expect(trim((string) $page->text('@plan-price-socials')))->toBe('$19');
+});
+
+test('a trial without a card says so under the button', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $user = welcomeOwnerOnPlanStep();
+ $user->account->offers()->attach(Offer::factory()->freeTrial()->withoutCard()->create(['slug' => 'ft7dnc']), ['claimed_at' => now()]);
+ $this->actingAs($user);
+
+ $page = visit(route('app.welcome.plan'));
+ waitFor($page, '@welcome-plan-terms');
+
+ $page->assertSeeIn('@plan-price-socials', 'Free')
+ ->assertSeeIn('@welcome-plan-continue', 'Start free trial')
+ ->assertSeeIn('@welcome-plan-terms', 'No credit card required')
+ ->assertDontSee('Cancel anytime')
+ ->assertDontSee('Then $19/month')
+ ->assertNoJavaScriptErrors();
+});
diff --git a/tests/Feature/Actions/Account/ResolveLifecycleStageTest.php b/tests/Feature/Actions/Account/ResolveLifecycleStageTest.php
index 107bffb04..42834ca35 100644
--- a/tests/Feature/Actions/Account/ResolveLifecycleStageTest.php
+++ b/tests/Feature/Actions/Account/ResolveLifecycleStageTest.php
@@ -76,9 +76,7 @@ test('a paying account keeps its stage while past due or cancelled on its grace
'cancelled on its grace period' => ['active', true],
]);
-test('a generic trial without a card and without channels is onboarding', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
+test('a trial without a card and without channels is onboarding', function () {
$account = Account::factory()->create(['trial_ends_at' => now()->addDays(5)]);
expect(ResolveLifecycleStage::execute($account->load('subscriptions'), null, false))->toBe(LifecycleStage::Onboarding);
diff --git a/tests/Feature/Ai/PostAiAssistantTest.php b/tests/Feature/Ai/PostAiAssistantTest.php
index bcf2a372e..1b1184e76 100644
--- a/tests/Feature/Ai/PostAiAssistantTest.php
+++ b/tests/Feature/Ai/PostAiAssistantTest.php
@@ -245,7 +245,7 @@ test('an unsubscribed account is stopped before the model is called', function (
'mode' => 'generate',
'prompt' => 'announce our summer launch today',
])
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
PostWritingAssistant::assertNeverPrompted();
});
diff --git a/tests/Feature/Api/LoadWorkspaceFromTokenTest.php b/tests/Feature/Api/LoadWorkspaceFromTokenTest.php
index 03628d5a2..856c24c89 100644
--- a/tests/Feature/Api/LoadWorkspaceFromTokenTest.php
+++ b/tests/Feature/Api/LoadWorkspaceFromTokenTest.php
@@ -12,7 +12,6 @@ use Symfony\Component\HttpFoundation\Response;
beforeEach(function () {
config([
'trypost.self_hosted' => false,
- 'trypost.billing.require_card_for_trial' => true,
]);
$result = createApiTestToken();
@@ -52,21 +51,6 @@ test('rejects a personal access token after its stored expiration', function ()
->assertJson(['message' => 'Token expired.']);
});
-test('allows api requests for generic-trial accounts with app access', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
- $this->user->account->update([
- 'trial_ends_at' => now()->addDays(8),
- ]);
-
- expect($this->user->account->fresh()->hasAppAccess())->toBeTrue()
- ->and($this->user->account->fresh()->subscribed(Account::SUBSCRIPTION_NAME))->toBeFalse();
-
- $this->withHeaders(['Authorization' => 'Bearer '.$this->plainToken])
- ->getJson(route('api.workspace.show'))
- ->assertOk();
-});
-
test('allows personal access tokens without a subscription in self-hosted mode', function () {
config(['trypost.self_hosted' => true]);
@@ -513,3 +497,16 @@ test('a workspace query parameter does not break the api rate limiter', function
->getJson(route('api.workspace.show', ['workspace' => 'foo']))
->assertOk();
});
+
+test('allows api requests during a trial without a card', function () {
+ $this->user->account->update([
+ 'trial_ends_at' => now()->addDays(7),
+ ]);
+
+ expect($this->user->account->fresh()->hasAppAccess())->toBeTrue()
+ ->and($this->user->account->fresh()->subscribed(Account::SUBSCRIPTION_NAME))->toBeFalse();
+
+ $this->withHeaders(['Authorization' => 'Bearer '.$this->plainToken])
+ ->getJson(route('api.workspace.show'))
+ ->assertOk();
+});
diff --git a/tests/Feature/Auth/SignupRequiresCheckoutTest.php b/tests/Feature/Auth/SignupRequiresCheckoutTest.php
index 28b88d3c3..089f03468 100644
--- a/tests/Feature/Auth/SignupRequiresCheckoutTest.php
+++ b/tests/Feature/Auth/SignupRequiresCheckoutTest.php
@@ -3,12 +3,10 @@
declare(strict_types=1);
use App\Actions\User\CreateUser;
-use App\Enums\Plan\Slug;
use Database\Seeders\PlanSeeder;
beforeEach(function () {
config(['trypost.self_hosted' => false]);
- config(['trypost.billing.require_card_for_trial' => true]);
$this->seed(PlanSeeder::class);
});
@@ -24,17 +22,3 @@ test('new signup does not create a trial before checkout', function () {
expect($user->account->trial_ends_at)->toBeNull();
expect($user->account->stripe_id)->toBeNull();
});
-
-test('new signup creates generic trial when card is not required', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
- $user = CreateUser::execute([
- 'name' => 'Alice',
- 'email' => '[email protected]',
- 'password' => 'password123',
- 'registration_ip' => '127.0.0.1',
- ]);
-
- expect($user->account->plan->slug)->toBe(Slug::Socials);
- expect($user->account->trial_ends_at)->not->toBeNull();
-});
diff --git a/tests/Feature/Billing/ChangePlanTest.php b/tests/Feature/Billing/ChangePlanTest.php
index b74a6253c..4ed44c26f 100644
--- a/tests/Feature/Billing/ChangePlanTest.php
+++ b/tests/Feature/Billing/ChangePlanTest.php
@@ -33,6 +33,7 @@ beforeEach(function () {
afterEach(function () {
RecordingSwapSubscription::$swappedPrices = [];
+ RecordingSwapSubscription::$swapOptions = [];
Cashier::useSubscriptionModel(Subscription::class);
});
@@ -258,6 +259,58 @@ test('change-plan swaps to the yearly price', function () use ($withWorkspace) {
->and(RecordingSwapSubscription::$swappedPrices)->toBe(['price_workspaces_yearly']);
});
+test('a swap to a yearly price removes the discount, so an offer never discounts a whole year', function () use ($withWorkspace) {
+ Cashier::useSubscriptionModel(RecordingSwapSubscription::class);
+
+ $user = User::factory()->create();
+ $account = $user->account;
+ $account->update(['plan_id' => $this->socials->id]);
+ $withWorkspace($user);
+
+ $account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_'.fake()->uuid(),
+ 'stripe_status' => 'active',
+ 'stripe_price' => 'price_socials_monthly',
+ ]);
+
+ $this->actingAs($user->fresh())
+ ->post(route('app.billing.change-plan'), [
+ 'plan_id' => $this->socials->id,
+ 'interval' => 'yearly',
+ ])
+ ->assertRedirect(route('app.billing.index'));
+
+ expect(RecordingSwapSubscription::$swappedPrices)->toBe(['price_socials_yearly'])
+ ->and(RecordingSwapSubscription::$swapOptions)->toBe([['discounts' => '']]);
+});
+
+test('a swap to a monthly price keeps the discount the owner still has', function () use ($withWorkspace) {
+ Cashier::useSubscriptionModel(RecordingSwapSubscription::class);
+
+ $user = User::factory()->create();
+ $account = $user->account;
+ $account->update(['plan_id' => $this->socials->id]);
+ $withWorkspace($user);
+
+ $account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_'.fake()->uuid(),
+ 'stripe_status' => 'active',
+ 'stripe_price' => 'price_socials_monthly',
+ ]);
+
+ $this->actingAs($user->fresh())
+ ->post(route('app.billing.change-plan'), [
+ 'plan_id' => $this->workspaces->id,
+ 'interval' => 'monthly',
+ ])
+ ->assertRedirect(route('app.billing.index'));
+
+ expect(RecordingSwapSubscription::$swappedPrices)->toBe(['price_workspaces_monthly'])
+ ->and(RecordingSwapSubscription::$swapOptions)->toBe([[]]);
+});
+
test('change-plan downgrades workspaces to socials', function () use ($withWorkspace) {
Cashier::useSubscriptionModel(RecordingSwapSubscription::class);
@@ -431,6 +484,11 @@ class RecordingSwapSubscription extends Subscription
*/
public static array $swappedPrices = [];
+ /**
+ * @var list<array<string, mixed>>
+ */
+ public static array $swapOptions = [];
+
public function getForeignKey(): string
{
return 'subscription_id';
@@ -439,6 +497,7 @@ class RecordingSwapSubscription extends Subscription
public function swap(string|array $prices, array $options = []): static
{
self::$swappedPrices[] = $prices;
+ self::$swapOptions[] = $options;
return $this;
}
diff --git a/tests/Feature/Billing/CheckoutPromotionCodeTest.php b/tests/Feature/Billing/CheckoutPromotionCodeTest.php
new file mode 100644
index 000000000..2e806b79e
--- /dev/null
+++ b/tests/Feature/Billing/CheckoutPromotionCodeTest.php
@@ -0,0 +1,71 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Actions\Billing\StartSubscriptionCheckout;
+use App\Enums\Plan\Slug;
+use App\Models\Account;
+use App\Models\Offer;
+use App\Models\Plan;
+use App\Models\User;
+use Stripe\ApiRequestor;
+use Stripe\HttpClient\ClientInterface;
+
+beforeEach(function () {
+ config(['cashier.secret' => 'sk_test_fake']);
+
+ $this->socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $this->socials->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+
+ $this->account = Account::factory()->create();
+ $this->account->update(['owner_id' => User::factory()->create(['account_id' => $this->account->id])->id]);
+
+ $this->stripe = new class implements ClientInterface
+ {
+ /** @var array<string, mixed> */
+ public array $session = [];
+
+ public function request($method, $absUrl, $headers, $params, $hasFile, $apiMode = 'v1', $maxNetworkRetries = null): array
+ {
+ if (str_contains($absUrl, '/v1/checkout/sessions')) {
+ $this->session = $params;
+
+ return [json_encode(['id' => 'cs_fake', 'object' => 'checkout.session', 'url' => 'https://checkout.stripe.test/session']), 200, []];
+ }
+
+ if (str_contains($absUrl, '/v1/coupons/')) {
+ return [json_encode(['id' => 'BF26_TEST', 'object' => 'coupon', 'percent_off' => 50, 'duration' => 'repeating', 'duration_in_months' => 3]), 200, []];
+ }
+
+ return [json_encode(['id' => 'cus_fake', 'object' => 'customer']), 200, []];
+ }
+ };
+
+ ApiRequestor::setHttpClient($this->stripe);
+});
+
+test('a checkout without an offer charges the full price and takes a promotion code', function () {
+ app(StartSubscriptionCheckout::class)->redirect($this->account, 'price_socials_monthly', route('app.welcome.plan'), $this->socials);
+
+ expect(data_get($this->stripe->session, 'allow_promotion_codes'))->toBe('true')
+ ->and(data_get($this->stripe->session, 'discounts'))->toBeNull()
+ ->and(data_get($this->stripe->session, 'subscription_data.trial_end'))->toBeNull();
+});
+
+test('a coupon offer sends its coupon and no promotion code field, which Stripe rejects together', function () {
+ $offer = Offer::factory()->create(['stripe_coupon_id' => 'BF26_TEST']);
+
+ app(StartSubscriptionCheckout::class)->redirect($this->account, 'price_socials_monthly', route('app.welcome.plan'), $this->socials, $offer);
+
+ expect(data_get($this->stripe->session, 'discounts.0.coupon'))->toBe('BF26_TEST')
+ ->and(data_get($this->stripe->session, 'allow_promotion_codes'))->toBeNull();
+});
+
+test('a trial offer that does not allow promotion codes sends the trial without the field', function () {
+ $offer = Offer::factory()->trial(8)->create();
+
+ app(StartSubscriptionCheckout::class)->redirect($this->account, 'price_socials_monthly', route('app.welcome.plan'), $this->socials, $offer);
+
+ expect(data_get($this->stripe->session, 'subscription_data.trial_end'))->not->toBeNull()
+ ->and(data_get($this->stripe->session, 'allow_promotion_codes'))->toBeNull();
+});
diff --git a/tests/Feature/Billing/TrialLengthTest.php b/tests/Feature/Billing/TrialLengthTest.php
deleted file mode 100644
index 7a61dc5e9..000000000
--- a/tests/Feature/Billing/TrialLengthTest.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-use App\Actions\User\CreateUser;
-
-test('the default trial length is 8 days', function () {
- expect(config('cashier.trial_days'))->toBe(8);
-});
-
-test('allow_promotion_codes defaults to false for saas recipe A', function () {
- expect(config('cashier.allow_promotion_codes'))->toBeFalse();
-});
-
-test('signup grants a trial of cashier.trial_days in no-card mode', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
- $user = CreateUser::execute([
- 'name' => 'Trial User',
- 'email' => '[email protected]',
- 'password' => 'secret123',
- ]);
-
- expect($user->account->trial_ends_at->toDateString())
- ->toBe(now()->addDays(config('cashier.trial_days'))->toDateString());
-});
diff --git a/tests/Feature/BillingControllerTest.php b/tests/Feature/BillingControllerTest.php
index 47a272ee1..d97967d96 100644
--- a/tests/Feature/BillingControllerTest.php
+++ b/tests/Feature/BillingControllerTest.php
@@ -2,14 +2,19 @@
declare(strict_types=1);
+use App\Actions\Billing\StartSubscriptionCheckout;
+use App\Enums\Billing\CheckoutOrigin;
+use App\Enums\Plan\Slug;
use App\Models\Account;
+use App\Models\Offer;
use App\Models\Plan;
use App\Models\User;
use App\Models\Workspace;
use Illuminate\Support\Facades\Route;
+use Stripe\ApiRequestor;
+use Stripe\HttpClient\ClientInterface;
beforeEach(function () {
- config(['trypost.billing.require_card_for_trial' => true]);
$this->account = Account::factory()->create();
$this->user = User::factory()->create([
@@ -24,6 +29,10 @@ beforeEach(function () {
$this->user->update(['current_workspace_id' => $this->workspace->id]);
});
+afterEach(function () {
+ ApiRequestor::setHttpClient(null);
+});
+
// Subscribe tests
test('subscribe requires authentication', function () {
$response = $this->get(route('app.subscribe'));
@@ -36,7 +45,7 @@ test('subscribe redirects to welcome', function () {
$response = $this->actingAs($this->user)->get(route('app.subscribe'));
- $response->assertRedirect(route('app.welcome.persona'));
+ $response->assertRedirect(route('app.welcome.plan'));
});
test('changePlan redirects to calendar in self hosted mode', function () {
@@ -150,7 +159,7 @@ test('billing processing shows processing page', function () {
$response->assertOk();
$response->assertInertia(fn ($page) => $page
->component('billing/Processing', false)
- ->has('subscriptionActive')
+ ->has('ready')
->missing('redirectToOnboarding')
);
});
@@ -171,7 +180,7 @@ test('billing processing keeps auth.plan null until the webhook writes plan_id',
->assertOk()
->assertInertia(fn ($page) => $page
->component('billing/Processing', false)
- ->where('subscriptionActive', true)
+ ->where('ready', true)
->where('auth.plan', null)
);
});
@@ -306,7 +315,7 @@ test('changePlan requires authentication', function () {
$response->assertRedirect(route('login'));
});
-test('billing index exposes the plan usage and no account details', function (string $slug, ?int $limit) {
+test('billing index exposes the plan and no account details', function (string $slug) {
config(['trypost.self_hosted' => false]);
$this->account->update([
@@ -322,12 +331,12 @@ test('billing index exposes the plan usage and no account details', function (st
->missing('account')
->where('plan.slug', $slug)
->where('workspaceCount', 1)
- ->where('workspaceLimit', $limit)
+ ->missing('workspaceLimit')
->where('subscription.ends_at', null)
);
})->with([
- 'socials' => ['socials', 1],
- 'workspaces' => ['workspaces', null],
+ 'socials' => ['socials'],
+ 'workspaces' => ['workspaces'],
]);
test('billing index exposes the end date of a cancelled subscription', function () {
@@ -375,3 +384,467 @@ test('the account settings page no longer exists', function () {
expect(Route::has('app.account.edit'))->toBeFalse()
->and(Route::has('app.account.update'))->toBeFalse();
});
+
+test('billing index shows a percentage discount and when it ends', function () {
+ config(['trypost.self_hosted' => false]);
+ $endsAt = now()->addMonths(3)->startOfSecond();
+ fakeStripeBilling($this->account, ['percent_off' => 50, 'amount_off' => null, 'currency' => null, 'duration' => 'repeating', 'duration_in_months' => 3], $endsAt->timestamp);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->where('discount.value', '50%')
+ ->where('discount.duration', 'repeating')
+ ->where('discount.ends_at', $endsAt->toIso8601String())
+ );
+});
+
+test('billing index shows an amount discount that never ends', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, ['percent_off' => null, 'amount_off' => 1800, 'currency' => 'usd', 'duration' => 'forever', 'duration_in_months' => null]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->where('discount.value', '$18.00')
+ ->where('discount.duration', 'forever')
+ ->where('discount.ends_at', null)
+ );
+});
+
+test('billing index sends no discount without one', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page->where('discount', null));
+});
+
+test('billing index does not ask Stripe for a discount without a Stripe customer', function () {
+ config(['trypost.self_hosted' => false]);
+ $this->account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_no_customer',
+ 'stripe_status' => 'active',
+ 'stripe_price' => 'price_123',
+ ]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page->where('discount', null));
+});
+
+test('billing index sends the card brand Stripe reports', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, cardBrand: 'mastercard');
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->has('paymentMethods', 1)
+ ->where('paymentMethods.0.brand', 'mastercard')
+ ->where('paymentMethods.0.last4', '4242')
+ ->where('paymentMethods.0.is_default', true)
+ );
+});
+
+test('billing index lists every card, the default one first', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, cardBrand: 'visa', secondCardBrand: 'mastercard');
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->has('paymentMethods', 2)
+ ->where('paymentMethods.0.id', 'pm_fake')
+ ->where('paymentMethods.0.brand', 'visa')
+ ->where('paymentMethods.0.is_default', true)
+ ->where('paymentMethods.1.id', 'pm_fake_second')
+ ->where('paymentMethods.1.brand', 'mastercard')
+ ->where('paymentMethods.1.last4', '5454')
+ ->where('paymentMethods.1.exp_year', 2055)
+ ->where('paymentMethods.1.is_default', false)
+ );
+});
+
+test('billing index takes the first card as the default when the customer has none', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, cardBrand: 'visa', secondCardBrand: 'mastercard', customerHasDefault: false);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->where('paymentMethods.0.id', 'pm_fake_second')
+ ->where('paymentMethods.0.is_default', true)
+ ->where('paymentMethods.1.is_default', false)
+ );
+});
+
+test('billing index marks the subscription card as the default when the customer has none', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, cardBrand: 'visa', secondCardBrand: 'mastercard', customerHasDefault: false, subscriptionCard: 'pm_fake');
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->where('paymentMethods.0.id', 'pm_fake')
+ ->where('paymentMethods.0.is_default', true)
+ ->where('paymentMethods.1.id', 'pm_fake_second')
+ ->where('paymentMethods.1.is_default', false)
+ );
+});
+
+test('billing index lists no cards without any', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page->where('paymentMethods', []));
+});
+
+test('billing index lists the paid invoices a page at a time, newest first', function () {
+ config(['trypost.self_hosted' => false, 'app.pagination.default' => 10]);
+ fakeStripeBilling($this->account, paidInvoices: 12);
+
+ $nextPage = null;
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(function ($page) use (&$nextPage) {
+ $page->has('invoices.data', 10)
+ ->where('invoices.data.0.id', 'in_fake_012')
+ ->where('invoices.data.0.total', '$19.00')
+ ->where('invoices.data.0.invoice_pdf', 'https://pay.stripe.com/invoice/in_fake_12/pdf')
+ ->where('invoices.data.9.id', 'in_fake_003')
+ ->whereType('invoices.meta.next_cursor', 'string');
+
+ $nextPage = $page->toArray()['props']['invoices']['meta']['next_cursor'];
+ });
+
+ $this->get(route('app.billing.index', ['cursor' => $nextPage]))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->has('invoices.data', 2)
+ ->where('invoices.data.0.id', 'in_fake_002')
+ ->where('invoices.data.1.id', 'in_fake_001')
+ ->where('invoices.meta.next_cursor', null)
+ );
+});
+
+test('billing index lists no invoices for an account without any', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->has('invoices.data', 0)
+ ->where('invoices.meta.next_cursor', null)
+ );
+});
+
+test('an owner on a generic trial subscribes through Checkout on the monthly price', function () {
+ config(['trypost.self_hosted' => false]);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $socials->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $this->account->update(['plan_id' => $socials->id, 'trial_ends_at' => now()->addDays(5)]);
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $offer, $origin): bool => $account->is($this->account)
+ && $priceId === 'price_socials_monthly'
+ && $cancelUrl === route('app.billing.index')
+ && $plan->is($socials)
+ && $offer === null
+ && $origin === CheckoutOrigin::Billing)
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.billing.checkout'))
+ ->assertRedirect('https://checkout.stripe.test/session');
+});
+
+test('a subscribed owner is sent back to billing instead of a second checkout', function () {
+ config(['trypost.self_hosted' => false]);
+ subscribeAccount($this->account);
+
+ $this->mock(StartSubscriptionCheckout::class)->shouldReceive('redirect')->never();
+
+ $this->actingAs($this->user)
+ ->post(route('app.billing.checkout'))
+ ->assertRedirect(route('app.billing.index'));
+});
+
+test('a member cannot open the billing checkout', function () {
+ config(['trypost.self_hosted' => false]);
+ $member = User::factory()->create(['account_id' => $this->account->id]);
+ $this->workspace->members()->attach($member->id, membershipPivot('member'));
+ $member->update(['current_workspace_id' => $this->workspace->id]);
+ $this->account->update(['plan_id' => Plan::where('slug', Slug::Socials)->value('id'), 'trial_ends_at' => now()->addDays(5)]);
+
+ $this->actingAs($member->fresh())
+ ->post(route('app.billing.checkout'))
+ ->assertSessionHas('flash.error', __('billing.flash.cannot_manage'));
+});
+
+test('subscribing from a generic trial applies an offer claimed meanwhile', function () {
+ config(['trypost.self_hosted' => false]);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $socials->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $this->account->update(['plan_id' => $socials->id, 'trial_ends_at' => now()->addDays(5)]);
+ $blackFriday = Offer::factory()->blackFriday()->create();
+ $this->account->offers()->attach($blackFriday, ['claimed_at' => now()]);
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $offer): bool => $offer?->is($blackFriday) === true)
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.billing.checkout'))
+ ->assertRedirect('https://checkout.stripe.test/session');
+});
+
+test('processing returns a billing checkout to billing', function () {
+ config(['trypost.self_hosted' => false]);
+
+ $this->actingAs($this->user)
+ ->get(route('app.billing.processing', ['from' => 'billing']))
+ ->assertInertia(fn ($page) => $page->where('returnsToBilling', true));
+
+ $this->actingAs($this->user)
+ ->get(route('app.billing.processing', ['from' => 'welcome']))
+ ->assertInertia(fn ($page) => $page->where('returnsToBilling', false));
+
+ $this->actingAs($this->user)
+ ->get(route('app.billing.processing', ['from' => ['billing']]))
+ ->assertInertia(fn ($page) => $page->where('returnsToBilling', false));
+});
+
+test('loading more invoices does not ask Stripe for the cards or the discount', function () {
+ config(['trypost.self_hosted' => false, 'app.pagination.default' => 10]);
+ fakeStripeBilling($this->account, paidInvoices: 12);
+ $recorder = new class(ApiRequestor::httpClient()) implements ClientInterface
+ {
+ /** @var list<string> */
+ public array $urls = [];
+
+ public function __construct(private ClientInterface $client) {}
+
+ public function request($method, $absUrl, $headers, $params, $hasFile, $apiMode = 'v1', $maxNetworkRetries = null): array
+ {
+ $this->urls[] = $absUrl;
+
+ return $this->client->request($method, $absUrl, $headers, $params, $hasFile, $apiMode, $maxNetworkRetries);
+ }
+ };
+ ApiRequestor::setHttpClient($recorder);
+
+ $page = $this->actingAs($this->user->fresh())->get(route('app.billing.index'))->assertOk()->viewData('page');
+ $recorder->urls = [];
+
+ $this->withHeaders([
+ 'X-Inertia' => 'true',
+ 'X-Inertia-Version' => (string) $page['version'],
+ 'X-Inertia-Partial-Component' => 'settings/account/Billing',
+ 'X-Inertia-Partial-Data' => 'invoices',
+ ])->get(route('app.billing.index'))->assertOk();
+
+ expect($recorder->urls)->not->toBeEmpty()
+ ->and(collect($recorder->urls)->contains(fn (string $url): bool => str_contains($url, 'payment_methods') || str_contains($url, '/v1/subscriptions/') || str_contains($url, '/v1/customers/cus_fake')))->toBeFalse();
+});
+
+test('subscribing from a generic trial never adds another trial', function () {
+ config(['trypost.self_hosted' => false]);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $socials->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $this->account->update(['plan_id' => $socials->id, 'trial_ends_at' => now()->addDays(5)]);
+ $this->account->offers()->attach(Offer::factory()->trial(14)->create(), ['claimed_at' => now()]);
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $offer): bool => $offer === null)
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.billing.checkout'))
+ ->assertRedirect('https://checkout.stripe.test/session');
+});
+
+test('subscribing from a generic trial picks the newest coupon offer over a newer trial claim', function () {
+ config(['trypost.self_hosted' => false]);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $socials->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $this->account->update(['plan_id' => $socials->id, 'trial_ends_at' => now()->addDays(5)]);
+ $blackFriday = Offer::factory()->blackFriday()->create();
+ $this->account->offers()->attach($blackFriday, ['claimed_at' => now()->subDay()]);
+ $this->account->offers()->attach(Offer::factory()->trial(14)->create(), ['claimed_at' => now()]);
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $offer): bool => $offer?->is($blackFriday) === true)
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.billing.checkout'))
+ ->assertRedirect('https://checkout.stripe.test/session');
+});
+
+test('billing does not show the discount of a subscription that ended', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, ['percent_off' => 50, 'amount_off' => null, 'currency' => null, 'duration' => 'forever', 'duration_in_months' => null]);
+ $this->account->subscriptions()->update(['stripe_status' => 'canceled', 'ends_at' => now()->subDay()]);
+ $this->account->update(['trial_ends_at' => now()->addDays(5)]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertInertia(fn ($page) => $page->where('discount', null)->where('onTrial', true));
+});
+
+test('changing plan during a generic trial subscribes to the picked plan through Checkout', function () {
+ config(['trypost.self_hosted' => false]);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $workspaces = Plan::where('slug', Slug::Workspaces)->firstOrFail();
+ $workspaces->update(['stripe_yearly_price_id' => 'price_workspaces_yearly']);
+ $this->account->update(['plan_id' => $socials->id, 'trial_ends_at' => now()->addDays(5)]);
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $offer, $origin): bool => $priceId === 'price_workspaces_yearly'
+ && $plan->is($workspaces)
+ && $origin === CheckoutOrigin::Billing)
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.billing.change-plan'), ['plan_id' => $workspaces->id, 'interval' => 'yearly'])
+ ->assertRedirect('https://checkout.stripe.test/session');
+});
+
+test('changing plan without a subscription or a trial sends the owner to Welcome', function () {
+ config(['trypost.self_hosted' => false]);
+ $workspaces = Plan::where('slug', Slug::Workspaces)->firstOrFail();
+
+ $this->mock(StartSubscriptionCheckout::class)->shouldReceive('redirect')->never();
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.billing.change-plan'), ['plan_id' => $workspaces->id, 'interval' => 'monthly'])
+ ->assertRedirect(route('app.welcome.plan'));
+});
+
+test('processing is ready at once for a trial without a card from Welcome', function () {
+ config(['trypost.self_hosted' => false]);
+ $this->account->update(['trial_ends_at' => now()->addDays(7)]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.processing', ['from' => 'welcome']))
+ ->assertInertia(fn ($page) => $page->where('ready', true)->where('returnsToBilling', false));
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.processing', ['from' => 'billing']))
+ ->assertInertia(fn ($page) => $page->where('ready', false));
+});
+
+test('an amount discount is formatted in the user\'s language', function () {
+ config(['trypost.self_hosted' => false]);
+ $this->user->update(['locale' => 'pt-BR']);
+ fakeStripeBilling($this->account, ['percent_off' => null, 'amount_off' => 1800, 'currency' => 'usd', 'duration' => 'forever', 'duration_in_months' => null]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertInertia(fn ($page) => $page->where('discount.value', "US$\u{a0}18,00"));
+});
+
+test('processing waits for the plan of the new subscription before returning to billing', function () {
+ config(['trypost.self_hosted' => false]);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $workspaces = Plan::where('slug', Slug::Workspaces)->firstOrFail();
+ $workspaces->update(['stripe_monthly_price_id' => 'price_workspaces_monthly']);
+ $this->account->update(['plan_id' => $socials->id]);
+ $this->account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_upgrade',
+ 'stripe_status' => 'active',
+ 'stripe_price' => 'price_workspaces_monthly',
+ ]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.processing', ['from' => 'billing']))
+ ->assertInertia(fn ($page) => $page->where('ready', false));
+
+ $this->account->update(['plan_id' => $workspaces->id]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.processing', ['from' => 'billing']))
+ ->assertInertia(fn ($page) => $page->where('ready', true));
+});
+
+test('an amount discount in a currency without cents keeps its value', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, ['percent_off' => null, 'amount_off' => 1000, 'currency' => 'jpy', 'duration' => 'forever', 'duration_in_months' => null]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertInertia(fn ($page) => $page->where('discount.value', '¥1,000'));
+});
+
+test('a trial without a card shows the trial, not the ended subscription before it', function () {
+ config(['trypost.self_hosted' => false]);
+ $this->account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_ended',
+ 'stripe_status' => 'canceled',
+ 'stripe_price' => 'price_123',
+ 'ends_at' => now()->subMonth(),
+ ]);
+ $this->account->update(['plan_id' => Plan::where('slug', Slug::Socials)->value('id'), 'trial_ends_at' => now()->addDays(7)]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertInertia(fn ($page) => $page
+ ->where('subscription', null)
+ ->where('onTrial', true)
+ ->where('hasSubscription', false)
+ );
+});
+
+test('subscribe now never opens a checkout on an archived plan', function () {
+ config(['trypost.self_hosted' => false]);
+ $this->account->update(['plan_id' => Plan::where('slug', Slug::Workspace)->value('id'), 'trial_ends_at' => now()->addDays(5)]);
+
+ $this->mock(StartSubscriptionCheckout::class)->shouldReceive('redirect')->never();
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.billing.checkout'))
+ ->assertRedirect(route('app.billing.index'));
+});
+
+test('billing index skips a default that is not a card and marks the subscription card', function () {
+ config(['trypost.self_hosted' => false]);
+ fakeStripeBilling($this->account, cardBrand: 'visa', secondCardBrand: 'mastercard', subscriptionCard: 'pm_fake', customerDefaultIsLink: true);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.billing.index'))
+ ->assertInertia(fn ($page) => $page
+ ->where('paymentMethods.0.id', 'pm_fake')
+ ->where('paymentMethods.0.is_default', true)
+ ->where('paymentMethods.1.is_default', false)
+ );
+});
diff --git a/tests/Feature/Channels/ChannelPostingScheduleTest.php b/tests/Feature/Channels/ChannelPostingScheduleTest.php
index 6bfd379c2..2b9db6263 100644
--- a/tests/Feature/Channels/ChannelPostingScheduleTest.php
+++ b/tests/Feature/Channels/ChannelPostingScheduleTest.php
@@ -99,11 +99,10 @@ test('generate from a goal saves the goal and a matching schedule', function ()
test('an owner without app access can still generate during onboarding', function () {
config()->set('trypost.self_hosted', false);
- config()->set('trypost.billing.require_card_for_trial', true);
$this->actingAs($this->user)
->get(route('app.calendar'))
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
$this->actingAs($this->user)
->postJson(route('app.channels.posting-schedule.generate', $this->channel), ['mode' => 'goal', 'goal' => 4])
@@ -115,7 +114,6 @@ test('an owner without app access can still generate during onboarding', functio
test('an owner without app access cannot update or copy a schedule', function () {
config()->set('trypost.self_hosted', false);
- config()->set('trypost.billing.require_card_for_trial', true);
$source = SocialAccount::factory()->x()->create([
'workspace_id' => $this->workspace->id,
'posting_schedule' => PostingSchedule::empty()->withTime(0, '10:00'),
@@ -123,11 +121,11 @@ test('an owner without app access cannot update or copy a schedule', function ()
$this->actingAs($this->user)
->putJson(route('app.channels.posting-schedule.update', $this->channel), schedulePayload())
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
$this->actingAs($this->user)
->postJson(route('app.channels.posting-schedule.copy', $this->channel), ['from' => $source->id])
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
expect($this->channel->fresh()->posting_schedule)->toBeNull();
});
diff --git a/tests/Feature/Jobs/PostHog/TrackBillingTest.php b/tests/Feature/Jobs/PostHog/TrackBillingTest.php
index cd004e7bb..a10ded8a2 100644
--- a/tests/Feature/Jobs/PostHog/TrackBillingTest.php
+++ b/tests/Feature/Jobs/PostHog/TrackBillingTest.php
@@ -71,38 +71,30 @@ test('handle updates the account group with the current subscription state', fun
&& $job->payload['groupKey'] === (string) $this->account->id
&& $job->payload['properties']['subscription_status'] === 'active'
&& $job->payload['properties']['has_active_subscription'] === true
- && ! array_key_exists('first_month_offer_ends_at', $job->payload['properties']);
+ && ! array_key_exists('offer', $job->payload['properties']);
});
});
-test('subscription creation sets the first month offer end on the account group', function () {
- $periodEndsAt = now()->addMonth()->startOfSecond();
- $this->payload['data']['object']['metadata'] = [
- 'trypost_first_month_coupon_id' => 'WORKSPACES_88USD',
- ];
- $this->payload['data']['object']['items']['data'][0]['current_period_end'] = $periodEndsAt->timestamp;
+test('subscription creation sets the offer slug on the account group', function () {
+ $this->payload['data']['object']['metadata'] = ['trypost_offer_slug' => 'bf26'];
Queue::fake();
(new TrackBilling((string) $this->account->id, BillingEvent::Created, $this->payload))
->handle(app(PostHogService::class));
- Queue::assertPushed(SendEvent::class, function (SendEvent $job) use ($periodEndsAt): bool {
- return $job->method === 'groupIdentify'
- && $job->payload['properties']['first_month_offer_ends_at'] === $periodEndsAt->toIso8601String();
- });
+ Queue::assertPushed(SendEvent::class, fn (SendEvent $job): bool => $job->method === 'groupIdentify'
+ && $job->payload['properties']['offer'] === 'bf26');
});
-test('subscription creation clears a previous first month offer when the new subscription has none', function () {
+test('subscription creation clears a previous offer when the new subscription has none', function () {
Queue::fake();
(new TrackBilling((string) $this->account->id, BillingEvent::Created, $this->payload))
->handle(app(PostHogService::class));
- Queue::assertPushed(SendEvent::class, function (SendEvent $job): bool {
- return $job->method === 'groupIdentify'
- && array_key_exists('first_month_offer_ends_at', $job->payload['properties'])
- && $job->payload['properties']['first_month_offer_ends_at'] === null;
- });
+ Queue::assertPushed(SendEvent::class, fn (SendEvent $job): bool => $job->method === 'groupIdentify'
+ && array_key_exists('offer', $job->payload['properties'])
+ && $job->payload['properties']['offer'] === null);
});
test('subscription cancellation updates the account group after Cashier marks it ended', function () {
diff --git a/tests/Feature/Jobs/PostHog/TrackCheckoutCompletedTest.php b/tests/Feature/Jobs/PostHog/TrackCheckoutCompletedTest.php
index b9664e21a..6d6a3754c 100644
--- a/tests/Feature/Jobs/PostHog/TrackCheckoutCompletedTest.php
+++ b/tests/Feature/Jobs/PostHog/TrackCheckoutCompletedTest.php
@@ -15,7 +15,6 @@ use Illuminate\Support\Facades\Queue;
beforeEach(function () {
config(['services.posthog.enabled' => true, 'services.posthog.api_key' => 'phc_test_key']);
- config(['cashier.first_month_coupon_ids.workspaces' => 'WORKSPACES_88USD']);
$this->plan = Plan::where('slug', Slug::Workspaces)->firstOrFail();
$this->plan->update([
@@ -65,46 +64,18 @@ test('handle captures checkout.completed with plan, interval and conversion data
&& $job->payload['properties']['conversion_value'] === 99.0
&& $job->payload['properties']['conversion_currency'] === 'USD'
&& $job->payload['properties']['conversion_transaction_id'] === 'sub_test123'
- && $job->payload['properties']['is_first_month_offer'] === false;
+ && $job->payload['properties']['offer'] === null;
});
});
-test('handle marks checkout.completed when the subscription uses the configured first month coupon', function () {
- $periodEndsAt = now()->addMonth()->startOfSecond();
- $this->payload['data']['object']['metadata'] = [
- 'trypost_first_month_coupon_id' => 'WORKSPACES_88USD',
- ];
- $this->payload['data']['object']['items']['data'][0]['current_period_end'] = $periodEndsAt->timestamp;
+test('handle sends the slug of the offer the checkout applied', function () {
+ $this->payload['data']['object']['metadata'] = ['trypost_offer_slug' => 'bf26'];
Queue::fake();
(new TrackCheckoutCompleted((string) $this->account->id, $this->payload))
->handle(app(PostHogService::class));
- Queue::assertPushed(SendEvent::class, function (SendEvent $job) use ($periodEndsAt): bool {
- $properties = $job->payload['properties'];
-
- return $properties['is_first_month_offer'] === true
- && $properties['first_month_coupon_id'] === 'WORKSPACES_88USD'
- && $properties['first_month_offer_ends_at'] === $periodEndsAt->toIso8601String();
- });
-});
-
-test('handle uses the checkout marker even when the coupon configuration changes before the job runs', function () {
- $this->payload['data']['object']['metadata'] = [
- 'trypost_first_month_coupon_id' => 'WORKSPACES_88USD',
- ];
- config(['cashier.first_month_coupon_ids.workspaces' => null]);
- Queue::fake();
-
- (new TrackCheckoutCompleted((string) $this->account->id, $this->payload))
- ->handle(app(PostHogService::class));
-
- Queue::assertPushed(SendEvent::class, function (SendEvent $job): bool {
- $properties = $job->payload['properties'];
-
- return $properties['is_first_month_offer'] === true
- && $properties['first_month_coupon_id'] === 'WORKSPACES_88USD';
- });
+ Queue::assertPushed(SendEvent::class, fn (SendEvent $job): bool => $job->payload['properties']['offer'] === 'bf26');
});
test('handle resolves the yearly interval from the price id', function () {
diff --git a/tests/Feature/Jobs/PostHog/TrackCheckoutExpiredTest.php b/tests/Feature/Jobs/PostHog/TrackCheckoutExpiredTest.php
index 95d192411..3bb8540ef 100644
--- a/tests/Feature/Jobs/PostHog/TrackCheckoutExpiredTest.php
+++ b/tests/Feature/Jobs/PostHog/TrackCheckoutExpiredTest.php
@@ -29,7 +29,7 @@ beforeEach(function () {
'metadata' => [
'trypost_plan_slug' => 'socials',
'trypost_interval' => 'monthly',
- 'trypost_first_month_offer' => 'true',
+ 'trypost_offer_slug' => 'bf26',
],
]],
];
@@ -58,13 +58,13 @@ test('captures checkout.expired on the owner with plan and offer', function () {
&& $properties['$groups']['account'] === (string) $this->account->id
&& $properties['plan_name'] === Plan::where('slug', Slug::Socials)->value('name')
&& $properties['interval'] === 'monthly'
- && $properties['is_first_month_offer'] === true
+ && $properties['offer'] === 'bf26'
&& $properties['checkout_session_id'] === 'cs_test_expired';
});
});
-test('marks the offer false when the session had no first month offer', function () {
- $this->payload['data']['object']['metadata']['trypost_first_month_offer'] = 'false';
+test('sends no offer when the session had none', function () {
+ unset($this->payload['data']['object']['metadata']['trypost_offer_slug']);
Queue::fake();
(new TrackCheckoutExpired((string) $this->account->id, $this->payload))
@@ -72,7 +72,7 @@ test('marks the offer false when the session had no first month offer', function
Queue::assertPushed(
SendEvent::class,
- fn (SendEvent $job): bool => $job->payload['properties']['is_first_month_offer'] === false,
+ fn (SendEvent $job): bool => $job->payload['properties']['offer'] === null,
);
});
@@ -101,7 +101,7 @@ test('sends empty plan, interval and offer when the session has no metadata', fu
return $properties['plan_name'] === null
&& $properties['interval'] === null
- && $properties['is_first_month_offer'] === false;
+ && $properties['offer'] === null;
});
});
diff --git a/tests/Feature/Jobs/PostHog/TrackTrialConvertedTest.php b/tests/Feature/Jobs/PostHog/TrackTrialConvertedTest.php
index c676043d1..1a49509d7 100644
--- a/tests/Feature/Jobs/PostHog/TrackTrialConvertedTest.php
+++ b/tests/Feature/Jobs/PostHog/TrackTrialConvertedTest.php
@@ -70,6 +70,18 @@ test('handle captures trial.converted with plan, interval and conversion data',
});
});
+test('a conversion whose payment checkout.completed already reports carries no revenue', function () {
+ Queue::fake();
+
+ (new TrackTrialConverted((string) $this->account->id, $this->payload, withRevenue: false))
+ ->handle(app(PostHogService::class));
+
+ Queue::assertPushed(SendEvent::class, fn (SendEvent $job): bool => $job->payload['event'] === TrialEvent::Converted->value
+ && $job->payload['properties']['plan_name'] === $this->plan->name
+ && ! array_key_exists('conversion_value', $job->payload['properties'])
+ && ! array_key_exists('conversion_transaction_id', $job->payload['properties']));
+});
+
test('handle resolves the yearly interval from the price id', function () {
$this->payload['data']['object']['items']['data'][0]['price']['id'] = 'price_workspace_yearly';
Queue::fake();
diff --git a/tests/Feature/Listeners/StripeBillingSignalListenerTest.php b/tests/Feature/Listeners/StripeBillingSignalListenerTest.php
index 1896de1be..c209880ca 100644
--- a/tests/Feature/Listeners/StripeBillingSignalListenerTest.php
+++ b/tests/Feature/Listeners/StripeBillingSignalListenerTest.php
@@ -34,7 +34,7 @@ beforeEach(function () {
'metadata' => [
'trypost_plan_slug' => 'socials',
'trypost_interval' => 'monthly',
- 'trypost_first_month_offer' => 'true',
+ 'trypost_offer_slug' => 'bf26',
],
]],
];
diff --git a/tests/Feature/Listeners/StripeEventListenerTest.php b/tests/Feature/Listeners/StripeEventListenerTest.php
index 43d9e5830..7b08174a3 100644
--- a/tests/Feature/Listeners/StripeEventListenerTest.php
+++ b/tests/Feature/Listeners/StripeEventListenerTest.php
@@ -13,6 +13,7 @@ use App\Jobs\PostHog\TrackTrialConverted;
use App\Jobs\PostHog\TrackTrialStarted;
use App\Listeners\StripeEventListener;
use App\Models\Account;
+use App\Models\Offer;
use App\Models\Plan;
use App\Models\User;
use Illuminate\Support\Facades\Bus;
@@ -63,26 +64,6 @@ test('subscription created handles event without error', function () {
expect(true)->toBeTrue();
});
-test('subscription created clears the generic trial_ends_at on the account', function () {
- $this->account->update(['trial_ends_at' => now()->addDays(3)]);
-
- $this->listener->handle(new WebhookHandled([
- 'type' => 'customer.subscription.created',
- 'data' => ['object' => [
- 'customer' => 'cus_test123',
- 'id' => 'sub_123',
- 'status' => 'active',
- 'items' => ['data' => [['price' => ['id' => 'price_workspace_monthly']]]],
- ]],
- ]));
-
- expect($this->account->fresh()->trial_ends_at)->toBeNull();
-});
-
-// ========================================
-// customer.subscription.updated
-// ========================================
-
test('subscription updated handles event without error', function () {
$this->listener->handle(new WebhookHandled([
'type' => 'customer.subscription.updated',
@@ -589,7 +570,7 @@ test('subscription created dispatches TrackCheckoutCompleted when status is acti
'customer' => 'cus_test123',
'id' => 'sub_123',
'status' => 'active',
- 'metadata' => ['trypost_first_month_coupon_id' => 'WORKSPACES_88USD'],
+ 'metadata' => ['trypost_offer_slug' => 'bf26'],
'items' => ['data' => [['price' => ['id' => 'price_workspaces_monthly']]]],
]],
]));
@@ -597,7 +578,7 @@ test('subscription created dispatches TrackCheckoutCompleted when status is acti
Bus::assertDispatched(
TrackCheckoutCompleted::class,
fn ($job) => $job->accountId === (string) $this->account->id
- && data_get($job->payload, 'data.object.metadata.trypost_first_month_coupon_id') === 'WORKSPACES_88USD',
+ && data_get($job->payload, 'data.object.metadata.trypost_offer_slug') === 'bf26',
);
Bus::assertNotDispatched(TrackTrialStarted::class);
});
@@ -1019,8 +1000,8 @@ test('subscription updated still syncs plan_id when TrackPlanChanged dispatch fa
expect($this->account->fresh()->plan_id)->toBe($this->workspaces->id);
});
-test('subscription created still syncs plan_id and clears trial_ends_at when the start tracking dispatch fails', function (string $status, string $job) {
- $this->account->update(['plan_id' => null, 'trial_ends_at' => now()->addDays(3)]);
+test('subscription created still syncs plan_id when the start tracking dispatch fails', function (string $status, string $job) {
+ $this->account->update(['plan_id' => null]);
failDispatchOf($job);
$this->listener->handle(new WebhookHandled([
@@ -1034,10 +1015,7 @@ test('subscription created still syncs plan_id and clears trial_ends_at when the
]],
]));
- $account = $this->account->fresh();
-
- expect($account->plan_id)->toBe($this->socials->id)
- ->and($account->trial_ends_at)->toBeNull();
+ expect($this->account->fresh()->plan_id)->toBe($this->socials->id);
})->with([
'trialing' => ['trialing', TrackTrialStarted::class],
'active' => ['active', TrackCheckoutCompleted::class],
@@ -1125,7 +1103,7 @@ test('a trial records no payment until it converts, and a later activation keeps
});
test('a trial cancelled through the real Cashier webhook is signed up, a paid subscription cancelled the same way is churned', function (bool $paid, LifecycleStage $expected) {
- config(['cashier.webhook.secret' => null, 'trypost.self_hosted' => false, 'trypost.billing.require_card_for_trial' => true]);
+ config(['cashier.webhook.secret' => null, 'trypost.self_hosted' => false]);
$this->account->forceFill(['trial_ends_at' => null, 'first_paid_at' => $paid ? now()->subMonth() : null])->save();
$this->account->subscriptions()->create([
'type' => Account::SUBSCRIPTION_NAME,
@@ -1149,3 +1127,172 @@ test('a trial cancelled through the real Cashier webhook is signed up, a paid su
'trial' => [false, LifecycleStage::SignedUp],
'paid' => [true, LifecycleStage::Churned],
]);
+
+test('an old subscription ending during a trial without a card keeps the trial plan', function () {
+ $this->account->update(['plan_id' => $this->socials->id, 'trial_ends_at' => now()->addDays(5)]);
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.deleted',
+ 'data' => ['object' => ['customer' => 'cus_test123', 'id' => 'sub_old', 'status' => 'canceled']],
+ ]));
+
+ expect($this->account->fresh()->plan_id)->toBe($this->socials->id);
+});
+
+test('a trial without a card that subscribes counts as a trial conversion', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => null])->save();
+ $this->account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subDays(5), 'redeemed_at' => now()->subDays(5)]);
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.created',
+ 'data' => ['object' => [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]],
+ ]],
+ ]));
+
+ Bus::assertDispatched(TrackTrialConverted::class, fn ($job) => $job->accountId === (string) $this->account->id && ! $job->withRevenue);
+ Bus::assertDispatchedTimes(TrackCheckoutCompleted::class, 1);
+});
+
+test('a first paid subscription without a trial is not a trial conversion', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => null])->save();
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.created',
+ 'data' => ['object' => [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]],
+ ]],
+ ]));
+
+ Bus::assertNotDispatched(TrackTrialConverted::class);
+});
+
+test('a trial without a card converts when an incomplete subscription becomes active', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => null])->save();
+ $this->account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subDays(2), 'redeemed_at' => now()->subDays(2)]);
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.updated',
+ 'data' => [
+ 'object' => [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]],
+ ],
+ 'previous_attributes' => ['status' => 'incomplete'],
+ ],
+ ]));
+
+ Bus::assertDispatchedTimes(TrackTrialConverted::class, 1);
+ Bus::assertDispatched(TrackTrialConverted::class, fn ($job) => $job->withRevenue);
+ Bus::assertNotDispatched(TrackCheckoutCompleted::class);
+});
+
+test('subscribing long after a trial without a card ended is not a trial conversion', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => null])->save();
+ $this->account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subMonths(5), 'redeemed_at' => now()->subMonths(5)]);
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.created',
+ 'data' => ['object' => [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]],
+ ]],
+ ]));
+
+ Bus::assertNotDispatched(TrackTrialConverted::class);
+});
+
+test('a subscription created during a trial without a card still converts when its webhook arrives after the trial', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => null])->save();
+ $redeemedAt = now()->subDays(9);
+ $this->account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => $redeemedAt, 'redeemed_at' => $redeemedAt]);
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.updated',
+ 'data' => [
+ 'object' => [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'created' => $redeemedAt->copy()->addDays(6)->timestamp,
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]],
+ ],
+ 'previous_attributes' => ['status' => 'incomplete'],
+ ],
+ ]));
+
+ Bus::assertDispatchedTimes(TrackTrialConverted::class, 1);
+});
+
+test('a trial without a card converts once when its created and updated webhooks both report it active', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => null])->save();
+ $this->account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subDays(2), 'redeemed_at' => now()->subDays(2)]);
+ $object = [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]],
+ ];
+ $stale = Account::query()->find($this->account->id);
+
+ $this->listener->handle(new WebhookHandled(['id' => 'evt_created', 'type' => 'customer.subscription.created', 'data' => ['object' => $object]]));
+ $stale->forceFill(['first_paid_at' => null])->save();
+ $this->listener->handle(new WebhookHandled(['id' => 'evt_updated', 'type' => 'customer.subscription.updated', 'data' => ['object' => $object, 'previous_attributes' => ['status' => 'incomplete']]]));
+
+ Bus::assertDispatchedTimes(TrackTrialConverted::class, 1);
+});
+
+test('a former customer who subscribes during a trial without a card counts as a trial conversion', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => now()->subYear()])->save();
+ $this->account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subDays(3), 'redeemed_at' => now()->subDays(3)]);
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.created',
+ 'data' => ['object' => [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]],
+ ]],
+ ]));
+
+ Bus::assertDispatchedTimes(TrackTrialConverted::class, 1);
+});
+
+test('a later update of a subscription that was already active is not a trial conversion', function () {
+ Bus::fake([TrackTrialConverted::class, TrackCheckoutCompleted::class]);
+ $this->account->forceFill(['first_paid_at' => null])->save();
+ $this->account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subDays(3), 'redeemed_at' => now()->subDays(3)]);
+
+ $this->listener->handle(new WebhookHandled([
+ 'type' => 'customer.subscription.updated',
+ 'data' => [
+ 'object' => [
+ 'customer' => 'cus_test123',
+ 'id' => 'sub_123',
+ 'status' => 'active',
+ 'items' => ['data' => [['price' => ['id' => 'price_socials_yearly']]]],
+ ],
+ 'previous_attributes' => ['items' => ['data' => [['price' => ['id' => 'price_socials_monthly']]]]],
+ ],
+ ]));
+
+ Bus::assertNotDispatched(TrackTrialConverted::class);
+});
diff --git a/tests/Feature/Mcp/ChatGptSignInTest.php b/tests/Feature/Mcp/ChatGptSignInTest.php
index f25758799..74453d787 100644
--- a/tests/Feature/Mcp/ChatGptSignInTest.php
+++ b/tests/Feature/Mcp/ChatGptSignInTest.php
@@ -230,7 +230,7 @@ describe('a signed-in user gets the same answers from every client', function ()
]);
test('an account without a subscription still gets the 402', function (string $ip) {
- config(['trypost.self_hosted' => false, 'trypost.billing.require_card_for_trial' => true]);
+ config(['trypost.self_hosted' => false]);
$unsubscribed = createApiTestToken();
$token = mcpBearerToken($unsubscribed['user'], $unsubscribed['workspace'])['plain_token'];
diff --git a/tests/Feature/McpSettingsControllerTest.php b/tests/Feature/McpSettingsControllerTest.php
index 7ec2969fb..625d54a2f 100644
--- a/tests/Feature/McpSettingsControllerTest.php
+++ b/tests/Feature/McpSettingsControllerTest.php
@@ -398,5 +398,5 @@ it('redirects to welcome when the account has no app access', function (): void
$this->actingAs($this->user->fresh())
->get(route('app.mcp.index'))
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
});
diff --git a/tests/Feature/Middleware/EnsureAccountReadyTest.php b/tests/Feature/Middleware/EnsureAccountReadyTest.php
index da23ee976..90f5bdf21 100644
--- a/tests/Feature/Middleware/EnsureAccountReadyTest.php
+++ b/tests/Feature/Middleware/EnsureAccountReadyTest.php
@@ -2,6 +2,9 @@
declare(strict_types=1);
+use App\Enums\User\Goal;
+use App\Enums\User\Persona;
+use App\Enums\User\PreviousSoftware;
use App\Models\Account;
use App\Models\User;
use App\Models\Workspace;
@@ -16,7 +19,7 @@ test('redirects owners to welcome when account has no active subscription', func
$this->actingAs($user)
->get(route('app.calendar'))
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
});
test('redirects members without app access straight to subscription required', function () {
@@ -95,3 +98,34 @@ test('redirects to workspace create when self-hosted and no workspace', function
->get(route('app.calendar'))
->assertRedirect(route('app.workspaces.create'));
});
+
+test('a former customer who already answered Welcome lands straight on the plan step', function () {
+ $owner = User::factory()->create([
+ 'persona' => Persona::Agency,
+ 'goals' => [Goal::SaveTime->value],
+ 'previous_software' => PreviousSoftware::Buffer,
+ ]);
+ $owner->account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_former',
+ 'stripe_status' => 'canceled',
+ 'stripe_price' => 'price_123',
+ 'ends_at' => now()->subDay(),
+ ]);
+
+ $this->actingAs($owner->fresh())
+ ->get(route('app.calendar'))
+ ->assertRedirect(route('app.welcome.plan'));
+
+ $this->actingAs($owner->fresh())
+ ->get(route('app.welcome.plan'))
+ ->assertOk();
+});
+
+test('a new owner still starts Welcome at the first step', function () {
+ $owner = User::factory()->create(['persona' => null]);
+
+ $this->actingAs($owner)
+ ->get(route('app.welcome.plan'))
+ ->assertRedirect(route('app.welcome.persona'));
+});
diff --git a/tests/Feature/Middleware/TrialMiddlewareAccessTest.php b/tests/Feature/Middleware/TrialMiddlewareAccessTest.php
index 227c9d22b..d81138972 100644
--- a/tests/Feature/Middleware/TrialMiddlewareAccessTest.php
+++ b/tests/Feature/Middleware/TrialMiddlewareAccessTest.php
@@ -10,7 +10,6 @@ use Database\Seeders\PlanSeeder;
beforeEach(function () {
config(['trypost.self_hosted' => false]);
- config(['trypost.billing.require_card_for_trial' => true]);
$this->seed(PlanSeeder::class);
});
@@ -31,7 +30,7 @@ test('user without subscription is redirected to subscribe', function () {
$response = $this->actingAs($user->fresh())->get(route('app.workspace.channels'));
- $response->assertRedirect(route('app.welcome.persona'));
+ $response->assertRedirect(route('app.welcome.plan'));
});
test('user with active subscription can access the app', function () {
@@ -117,15 +116,14 @@ test('user with past_due subscription can access the app instead of being forced
$response->assertSessionMissing('errors');
});
-test('user on generic trial can access the app when card is not required', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
+test('a trial without a card can use the app until it ends', function () {
$user = CreateUser::execute([
'name' => 'Alice',
'email' => '[email protected]',
'password' => 'password123',
'registration_ip' => '127.0.0.1',
]);
+ $user->account->update(['trial_ends_at' => now()->addDays(7)]);
$workspace = Workspace::factory()->create([
'account_id' => $user->account_id,
@@ -134,7 +132,9 @@ test('user on generic trial can access the app when card is not required', funct
$workspace->members()->attach($user->id, membershipPivot('member'));
$user->update(['current_workspace_id' => $workspace->id]);
- $response = $this->actingAs($user->fresh())->get(route('app.workspace.channels'));
+ $this->actingAs($user->fresh())->get(route('app.workspace.channels'))->assertOk();
- $response->assertOk();
+ $this->travel(8)->days();
+
+ $this->actingAs($user->fresh())->get(route('app.workspace.channels'))->assertRedirect(route('app.welcome.plan'));
});
diff --git a/tests/Feature/Models/OfferTest.php b/tests/Feature/Models/OfferTest.php
new file mode 100644
index 000000000..d02e5b2c3
--- /dev/null
+++ b/tests/Feature/Models/OfferTest.php
@@ -0,0 +1,136 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Models\Account;
+use App\Models\Offer;
+
+test('an offer that started and has no end is available', function () {
+ $offer = Offer::factory()->create();
+
+ expect(Offer::available()->pluck('id')->all())->toBe([$offer->id]);
+});
+
+test('an offer that has not started is not available', function () {
+ Offer::factory()->upcoming()->create();
+
+ expect(Offer::available()->count())->toBe(0);
+});
+
+test('an offer past its end is not available', function () {
+ Offer::factory()->expired()->create();
+
+ expect(Offer::available()->count())->toBe(0);
+});
+
+test('an offer with an end in the future is available', function () {
+ Offer::factory()->create(['ends_at' => now()->addDay()]);
+
+ expect(Offer::available()->count())->toBe(1);
+});
+
+test('a full offer is not available', function () {
+ $offer = Offer::factory()->limitedTo(1)->create();
+ $offer->accounts()->attach(Account::factory()->create(), ['claimed_at' => now(), 'redeemed_at' => now()]);
+
+ expect(Offer::available()->count())->toBe(0);
+});
+
+test('claims do not use up places', function () {
+ $offer = Offer::factory()->limitedTo(1)->create();
+ $offer->accounts()->attach(Account::factory()->create(), ['claimed_at' => now()]);
+
+ expect(Offer::available()->count())->toBe(1);
+});
+
+test('current offer is the latest claimed unredeemed available offer', function () {
+ $account = Account::factory()->create();
+ [$earlier, $later, $redeemed] = Offer::factory()->count(3)->create();
+
+ $account->offers()->attach($earlier, ['claimed_at' => now()->subDays(2)]);
+ $account->offers()->attach($later, ['claimed_at' => now()->subDay()]);
+ $account->offers()->attach($redeemed, ['claimed_at' => now(), 'redeemed_at' => now()]);
+
+ expect($account->currentOffer()?->id)->toBe($later->id);
+});
+
+test('current offer ignores expired claims', function () {
+ $account = Account::factory()->create();
+ $account->offers()->attach(Offer::factory()->expired()->create(), ['claimed_at' => now()]);
+
+ expect($account->currentOffer())->toBeNull();
+});
+
+test('lang key replaces dashes', function () {
+ expect(Offer::factory()->make(['slug' => 'black-friday-2026'])->langKey())->toBe('black_friday_2026');
+});
+
+test('deleting an account removes its offer claims', function () {
+ $account = Account::factory()->create();
+ $offer = Offer::factory()->create();
+ $account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ $account->delete();
+
+ $this->assertDatabaseMissing('account_offer', ['offer_id' => $offer->id]);
+});
+
+test('an offer the account redeemed is no longer available to it, only to others', function () {
+ $offer = Offer::factory()->create();
+ $account = Account::factory()->create();
+ $account->offers()->attach($offer, ['claimed_at' => now(), 'redeemed_at' => now()]);
+
+ expect(Offer::availableTo($account)->whereKey($offer->id)->exists())->toBeFalse()
+ ->and(Offer::availableTo(Account::factory()->create())->whereKey($offer->id)->exists())->toBeTrue();
+});
+
+test('a first-subscription offer is not available to an account that was billed before', function () {
+ $offer = Offer::factory()->firstSubscriptionOnly()->create();
+ $account = Account::factory()->create();
+ $account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_former',
+ 'stripe_status' => 'canceled',
+ 'stripe_price' => 'price_monthly_test',
+ ]);
+
+ expect(Offer::availableTo($account)->whereKey($offer->id)->exists())->toBeFalse()
+ ->and(Offer::availableTo(Account::factory()->create())->whereKey($offer->id)->exists())->toBeTrue();
+});
+
+test('current offer is empty without a claim', function () {
+ Offer::factory()->create();
+
+ expect(Account::factory()->create()->currentOffer())->toBeNull();
+});
+
+test('the factory builds the three real offers with their copy', function (string $state, string $slug) {
+ $offer = Offer::factory()->{$state}()->create();
+
+ expect($offer->slug)->toBe($slug)
+ ->and(__("offers.{$offer->langKey()}.price"))->not->toBe("offers.{$offer->langKey()}.price");
+})->with([
+ 'black friday' => ['blackFriday', 'bf26'],
+ 'first month' => ['firstMonth', 'fm1'],
+ 'free trial' => ['freeTrial', 'ft7d'],
+]);
+
+test('a first-subscription offer is not available to an account that had a trial without a card, even once Cashier cleared it', function () {
+ $offer = Offer::factory()->firstSubscriptionOnly()->create();
+ $account = Account::factory()->create(['trial_ends_at' => null]);
+ $account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subWeek(), 'redeemed_at' => now()->subWeek()]);
+
+ expect(Offer::availableTo($account)->whereKey($offer->id)->exists())->toBeFalse()
+ ->and($account->isFirstTimeSubscriber())->toBeFalse();
+});
+
+test('a trial needs at least one day', function (?int $days, bool $hasTrial) {
+ $offer = Offer::factory()->withoutCard()->make(['trial_days' => $days]);
+
+ expect($offer->hasTrial())->toBe($hasTrial)
+ ->and($offer->startsWithoutCard())->toBe($hasTrial);
+})->with([
+ 'no trial' => [null, false],
+ 'zero days' => [0, false],
+ 'seven days' => [7, true],
+]);
diff --git a/tests/Feature/Offer/ClaimOfferTest.php b/tests/Feature/Offer/ClaimOfferTest.php
new file mode 100644
index 000000000..2bbb4f039
--- /dev/null
+++ b/tests/Feature/Offer/ClaimOfferTest.php
@@ -0,0 +1,329 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Actions\Offer\ClaimOffer;
+use App\Http\Middleware\App\CaptureOffer;
+use App\Models\Account;
+use App\Models\Offer;
+use App\Models\User;
+use App\Models\Workspace;
+use Laravel\Socialite\Facades\Socialite;
+use Laravel\Socialite\Two\User as SocialiteUser;
+
+beforeEach(function () {
+ config(['trypost.self_hosted' => false]);
+
+ $this->offer = Offer::factory()->create(['slug' => 'black-friday-2026']);
+});
+
+function offerTestOwner(): User
+{
+ $account = Account::factory()->create();
+ $user = User::factory()->create(['account_id' => $account->id]);
+ $account->update(['owner_id' => $user->id]);
+ $workspace = Workspace::factory()->create(['account_id' => $account->id, 'user_id' => $user->id]);
+ $workspace->members()->attach($user->id, membershipPivot('member'));
+ $user->update(['current_workspace_id' => $workspace->id]);
+
+ return $user->refresh();
+}
+
+function offerTestSubscribe(Account $account, string $status = 'active'): void
+{
+ $account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_test_'.fake()->uuid(),
+ 'stripe_status' => $status,
+ 'stripe_price' => 'price_123',
+ 'ends_at' => $status === 'canceled' ? now()->subDay() : null,
+ ]);
+}
+
+test('a guest\'s offer is claimed when they register', function () {
+ $this->get(route('register', ['offer' => 'black-friday-2026']));
+
+ $this->followingRedirects()->post(route('register.store'), [
+ 'name' => 'Offer User',
+ 'email' => '[email protected]',
+ 'password' => strongPassword(),
+ 'locale' => 'en',
+ ]);
+
+ $account = User::query()->where('email', '[email protected]')->firstOrFail()->account;
+
+ expect($account->offers()->pluck('offers.id')->all())->toBe([$this->offer->id]);
+});
+
+test('claims a pending offer after login', function () {
+ $owner = offerTestOwner();
+ offerTestSubscribe($owner->account, 'canceled');
+
+ $this->get(route('login', ['offer' => 'black-friday-2026']));
+
+ $this->followingRedirects()->post(route('login.store'), [
+ 'email' => $owner->email,
+ 'password' => 'password',
+ ]);
+
+ expect($owner->account->offers()->pluck('offers.id')->all())->toBe([$this->offer->id]);
+});
+
+test('a logged-in owner without a subscription claims on any page', function () {
+ $owner = offerTestOwner();
+
+ $this->actingAs($owner)->get(route('app.welcome.plan', ['offer' => 'black-friday-2026']));
+
+ expect($owner->account->offers()->pluck('offers.id')->all())->toBe([$this->offer->id]);
+});
+
+test('ignores accounts with an active subscription', function () {
+ $owner = offerTestOwner();
+ offerTestSubscribe($owner->account);
+
+ $this->actingAs($owner)->get(route('app.calendar', ['offer' => 'black-friday-2026']));
+
+ expect($owner->account->offers()->count())->toBe(0);
+});
+
+test('ignores members who are not the owner', function () {
+ $owner = offerTestOwner();
+ $member = User::factory()->create(['account_id' => $owner->account_id]);
+
+ $this->actingAs($member)
+ ->get(route('app.welcome.subscription-required', ['offer' => 'black-friday-2026']))
+ ->assertSessionMissing(CaptureOffer::SESSION_KEY);
+
+ expect($owner->account->offers()->count())->toBe(0);
+});
+
+test('ignores unknown, upcoming, expired and full offers', function (Closure $makeOffer) {
+ $slug = $makeOffer();
+ $owner = offerTestOwner();
+
+ $this->actingAs($owner)->get(route('app.welcome.plan', ['offer' => $slug]));
+
+ expect($owner->account->offers()->count())->toBe(0);
+})->with([
+ 'unknown' => fn () => fn (): string => 'no-such-offer',
+ 'upcoming' => fn () => fn (): string => Offer::factory()->upcoming()->create()->slug,
+ 'expired' => fn () => fn (): string => Offer::factory()->expired()->create()->slug,
+ 'full' => fn () => function (): string {
+ $offer = Offer::factory()->limitedTo(1)->create();
+ $offer->accounts()->attach(Account::factory()->create(), ['claimed_at' => now(), 'redeemed_at' => now()]);
+
+ return $offer->slug;
+ },
+]);
+
+test('ignores a non-string or blank offer', function (array $query) {
+ $this->get(route('register', $query))
+ ->assertOk()
+ ->assertSessionMissing(CaptureOffer::SESSION_KEY);
+})->with([
+ 'array' => [['offer' => ['black-friday-2026']]],
+ 'blank' => [['offer' => '']],
+ 'huge' => [['offer' => str_repeat('a', 10_000)]],
+]);
+
+test('matches the slug exactly', function () {
+ $owner = offerTestOwner();
+
+ expect(ClaimOffer::execute($owner->account, 'BLACK-FRIDAY-2026'))->toBeNull()
+ ->and($owner->account->offers()->count())->toBe(0);
+});
+
+test('does not re-offer a redeemed offer', function () {
+ $owner = offerTestOwner();
+ $redeemedAt = now()->subMonth()->startOfSecond();
+ $owner->account->offers()->attach($this->offer, ['claimed_at' => $redeemedAt, 'redeemed_at' => $redeemedAt]);
+
+ expect(ClaimOffer::execute($owner->account, 'black-friday-2026'))->toBeNull()
+ ->and($owner->account->offers()->first()->pivot->redeemed_at)->toEqual($redeemedAt->toDateTimeString());
+});
+
+test('re-claiming refreshes claimed_at', function () {
+ $owner = offerTestOwner();
+
+ $this->travelTo(now()->subDay());
+ ClaimOffer::execute($owner->account, 'black-friday-2026');
+ $this->travelBack();
+
+ $secondClaim = now()->startOfSecond();
+ $this->travelTo($secondClaim);
+ ClaimOffer::execute($owner->account, 'black-friday-2026');
+
+ expect($owner->account->offers()->first()->pivot->claimed_at)->toEqual($secondClaim->toDateTimeString());
+});
+
+test('self-hosted never claims', function () {
+ config(['trypost.self_hosted' => true]);
+ $owner = offerTestOwner();
+
+ $this->actingAs($owner)->get(route('app.calendar', ['offer' => 'black-friday-2026']));
+
+ expect($owner->account->offers()->count())->toBe(0);
+});
+
+test('a guest\'s link to an offer that has not started is not kept for later', function () {
+ Offer::factory()->create(['slug' => 'cyber-monday-2026', 'starts_at' => now()->addHour()]);
+
+ $this->get(route('register', ['offer' => 'cyber-monday-2026']))
+ ->assertSessionMissing(CaptureOffer::SESSION_KEY);
+
+ $this->travel(2)->hours();
+
+ $this->followingRedirects()->post(route('register.store'), [
+ 'name' => 'Early User',
+ 'email' => '[email protected]',
+ 'password' => strongPassword(),
+ 'locale' => 'en',
+ ]);
+
+ expect(User::query()->where('email', '[email protected]')->firstOrFail()->account->offers()->count())->toBe(0);
+});
+
+test('a guest\'s wrong-case slug is not kept in the session', function () {
+ $this->get(route('register', ['offer' => 'BLACK-FRIDAY-2026']))
+ ->assertSessionMissing(CaptureOffer::SESSION_KEY);
+});
+
+test('a signed-in owner claims without going through the session', function () {
+ $owner = offerTestOwner();
+
+ $this->actingAs($owner)
+ ->get(route('app.welcome.plan', ['offer' => 'black-friday-2026']))
+ ->assertSessionMissing(CaptureOffer::SESSION_KEY);
+
+ expect($owner->account->offers()->count())->toBe(1);
+});
+
+test('a user without an account claims nothing and keeps no slug', function () {
+ $user = User::factory()->create(['account_id' => null]);
+
+ $this->actingAs($user)
+ ->get(route('app.welcome.subscription-required', ['offer' => 'black-friday-2026']))
+ ->assertSessionMissing(CaptureOffer::SESSION_KEY);
+
+ $this->assertDatabaseCount('account_offer', 0);
+});
+
+test('a guest\'s offer is claimed when they sign up with google', function () {
+ config(['trypost.google_auth_enabled' => true]);
+ $this->get(route('auth.google.redirect', ['offer' => 'black-friday-2026']));
+
+ $socialiteUser = new SocialiteUser;
+ $socialiteUser->id = 'g-offer';
+ $socialiteUser->name = 'Google Offer';
+ $socialiteUser->email = '[email protected]';
+ Socialite::shouldReceive('driver')->with('google-auth')->andReturn($driver = Mockery::mock());
+ $driver->shouldReceive('user')->andReturn($socialiteUser);
+
+ $this->followingRedirects()->get(route('auth.google.callback'));
+
+ expect(User::query()->where('email', '[email protected]')->firstOrFail()->account->offers()->pluck('offers.id')->all())
+ ->toBe([$this->offer->id]);
+});
+
+test('a guest\'s offer is claimed when they sign up with github', function () {
+ config(['trypost.github_auth_enabled' => true]);
+ $this->get(route('auth.github.redirect', ['offer' => 'black-friday-2026']));
+
+ $socialiteUser = new SocialiteUser;
+ $socialiteUser->id = 'gh-offer';
+ $socialiteUser->name = 'GitHub Offer';
+ $socialiteUser->email = '[email protected]';
+ $socialiteUser->nickname = 'github-offer';
+ Socialite::shouldReceive('driver')->with('github')->andReturn($driver = Mockery::mock());
+ $driver->shouldReceive('user')->andReturn($socialiteUser);
+
+ $this->followingRedirects()->get(route('auth.github.callback'));
+
+ expect(User::query()->where('email', '[email protected]')->firstOrFail()->account->offers()->pluck('offers.id')->all())
+ ->toBe([$this->offer->id]);
+});
+
+test('the offer survives moving from the register page to login', function () {
+ $owner = offerTestOwner();
+
+ $this->get(route('register', ['offer' => 'black-friday-2026']));
+ $this->get(route('login'));
+ $this->get(route('register'));
+
+ $this->followingRedirects()->post(route('login.store'), [
+ 'email' => $owner->email,
+ 'password' => 'password',
+ ]);
+
+ expect($owner->account->offers()->pluck('offers.id')->all())->toBe([$this->offer->id]);
+});
+
+test('a former customer cannot claim a first-subscription offer', function () {
+ $owner = User::factory()->create();
+ $owner->account->update(['owner_id' => $owner->id]);
+ $owner->account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_former',
+ 'stripe_status' => 'canceled',
+ 'stripe_price' => 'price_123',
+ 'ends_at' => now()->subDay(),
+ ]);
+ $offer = Offer::factory()->firstSubscriptionOnly()->create(['slug' => 'fm1']);
+
+ expect(ClaimOffer::execute($owner->account->fresh(), 'fm1'))->toBeNull()
+ ->and($owner->account->offers()->whereKey($offer->id)->exists())->toBeFalse();
+});
+
+test('a waiting offer is still claimed when the first signed-in page links to one that cannot be', function () {
+ $this->withSession([CaptureOffer::SESSION_KEY => 'black-friday-2026']);
+ $owner = offerTestOwner();
+
+ $this->actingAs($owner)
+ ->get(route('app.welcome.plan', ['offer' => 'no-such-offer']))
+ ->assertSessionMissing(CaptureOffer::SESSION_KEY);
+
+ expect($owner->account->offers()->pluck('offers.id')->all())->toBe([$this->offer->id]);
+});
+
+test('an offer limited to two places takes two redemptions and refuses a third account', function () {
+ $offer = Offer::factory()->limitedTo(2)->create();
+ $first = offerTestOwner();
+ $second = offerTestOwner();
+ $third = offerTestOwner();
+
+ expect(ClaimOffer::execute($first->account, $offer->slug)?->is($offer))->toBeTrue();
+ $first->account->offers()->updateExistingPivot($offer->id, ['redeemed_at' => now()]);
+
+ expect(ClaimOffer::execute($second->account, $offer->slug)?->is($offer))->toBeTrue();
+ $second->account->offers()->updateExistingPivot($offer->id, ['redeemed_at' => now()]);
+
+ expect(ClaimOffer::execute($third->account, $offer->slug))->toBeNull()
+ ->and($third->account->offers()->count())->toBe(0)
+ ->and($third->account->currentOffer())->toBeNull();
+});
+
+test('an owner who claimed an offer before its last place went pays the full price', function () {
+ $offer = Offer::factory()->limitedTo(1)->create();
+ $owner = offerTestOwner();
+ ClaimOffer::execute($owner->account, $offer->slug);
+
+ $other = offerTestOwner();
+ $other->account->offers()->attach($offer, ['claimed_at' => now(), 'redeemed_at' => now()]);
+
+ expect($owner->account->offers()->count())->toBe(1)
+ ->and($owner->account->currentOffer())->toBeNull();
+});
+
+test('a guest\'s offer that ends before they sign in is not claimed', function () {
+ $offer = Offer::factory()->create(['ends_at' => now()->addHour()]);
+ $owner = offerTestOwner();
+
+ $this->get(route('login', ['offer' => $offer->slug]))->assertSessionHas(CaptureOffer::SESSION_KEY, $offer->slug);
+
+ $this->travel(2)->hours();
+
+ $this->post(route('login.store'), ['email' => $owner->email, 'password' => 'password']);
+ $this->get(route('app.welcome.plan'));
+
+ expect($owner->account->offers()->count())->toBe(0);
+});
diff --git a/tests/Feature/Offer/OfferCopyTest.php b/tests/Feature/Offer/OfferCopyTest.php
new file mode 100644
index 000000000..820352cba
--- /dev/null
+++ b/tests/Feature/Offer/OfferCopyTest.php
@@ -0,0 +1,21 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\User\Locale;
+use Illuminate\Support\Facades\Lang;
+
+test('every offer has its price in every locale, and its banner in all or none', function () {
+ $offers = Lang::get('offers', [], Locale::DEFAULT->value);
+
+ $missing = collect(Locale::cases())->flatMap(fn (Locale $locale) => collect($offers)
+ ->flatMap(fn (array $copy, string $offer): array => collect(['price', 'period', 'checkout_button'])
+ ->when(array_key_exists('name', $copy) || array_key_exists('headline', $copy), fn ($fields) => $fields->push('name', 'headline'))
+ ->map(fn (string $field): string => "offers.{$offer}.{$field}")
+ ->all())
+ ->reject(fn (string $key): bool => Lang::has($key, $locale->value, false))
+ ->map(fn (string $key): string => "{$locale->value}: {$key}"));
+
+ expect($offers)->not->toBeEmpty()
+ ->and($missing->values()->all())->toBe([]);
+});
diff --git a/tests/Feature/Offer/RedeemOfferTest.php b/tests/Feature/Offer/RedeemOfferTest.php
new file mode 100644
index 000000000..578c253e8
--- /dev/null
+++ b/tests/Feature/Offer/RedeemOfferTest.php
@@ -0,0 +1,105 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Listeners\StripeEventListener;
+use App\Models\Account;
+use App\Models\Offer;
+use App\Models\User;
+use Laravel\Cashier\Events\WebhookHandled;
+
+beforeEach(function () {
+ $this->account = Account::factory()->create(['stripe_id' => 'cus_offer123']);
+ $this->account->update(['owner_id' => User::factory()->create(['account_id' => $this->account->id])->id]);
+ $this->offer = Offer::factory()->limitedTo(1)->create();
+});
+
+function subscriptionCreatedWithOffer(?string $offerId, string $status = 'active', string $type = 'customer.subscription.created'): WebhookHandled
+{
+ return new WebhookHandled([
+ 'id' => 'evt_'.fake()->uuid(),
+ 'type' => $type,
+ 'data' => ['object' => [
+ 'customer' => 'cus_offer123',
+ 'id' => 'sub_offer',
+ 'status' => $status,
+ 'metadata' => array_filter(['trypost_offer_id' => $offerId]),
+ ]],
+ ]);
+}
+
+test('marks the claimed offer redeemed', function () {
+ $this->account->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id));
+
+ expect($this->account->offers()->first()->pivot->redeemed_at)->not->toBeNull();
+});
+
+test('does not overwrite an earlier redemption', function () {
+ $redeemedAt = now()->subMonth()->startOfSecond();
+ $this->account->offers()->attach($this->offer, ['claimed_at' => $redeemedAt, 'redeemed_at' => $redeemedAt]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id));
+
+ expect($this->account->offers()->first()->pivot->redeemed_at)->toEqual($redeemedAt->toDateTimeString());
+});
+
+test('ignores a subscription without offer metadata', function () {
+ $this->account->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer(null));
+
+ expect($this->account->offers()->first()->pivot->redeemed_at)->toBeNull();
+});
+
+test('ignores an offer the account never claimed', function () {
+ $other = Account::factory()->create();
+ $other->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id));
+
+ expect($this->account->offers()->count())->toBe(0)
+ ->and($other->offers()->first()->pivot->redeemed_at)->toBeNull();
+});
+
+test('a redeemed offer uses up a place', function () {
+ $this->account->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id));
+
+ expect(Offer::available()->whereKey($this->offer->id)->exists())->toBeFalse();
+});
+
+test('an incomplete subscription does not redeem the offer', function () {
+ $this->account->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id, 'incomplete'));
+
+ expect($this->account->offers()->first()->pivot->redeemed_at)->toBeNull();
+});
+
+test('the offer is redeemed once an incomplete subscription becomes active', function () {
+ $this->account->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id, 'incomplete'));
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id, 'active', 'customer.subscription.updated'));
+
+ expect($this->account->offers()->first()->pivot->redeemed_at)->not->toBeNull();
+});
+
+test('a trialing subscription redeems the offer', function () {
+ $this->account->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer($this->offer->id, 'trialing'));
+
+ expect($this->account->offers()->first()->pivot->redeemed_at)->not->toBeNull();
+});
+
+test('ignores offer metadata that is not an offer id', function () {
+ $this->account->offers()->attach($this->offer, ['claimed_at' => now()]);
+
+ (new StripeEventListener)->handle(subscriptionCreatedWithOffer('not-a-uuid'));
+
+ expect($this->account->offers()->first()->pivot->redeemed_at)->toBeNull();
+});
diff --git a/tests/Feature/OfferSeederTest.php b/tests/Feature/OfferSeederTest.php
new file mode 100644
index 000000000..50b712886
--- /dev/null
+++ b/tests/Feature/OfferSeederTest.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Models\Offer;
+use Database\Seeders\OfferSeeder;
+
+test('seeds the local offers and can run again', function () {
+ (new OfferSeeder)->run();
+ (new OfferSeeder)->run();
+
+ expect(Offer::query()->orderBy('slug')->pluck('slug')->all())->toBe(['bf26', 'fm1', 'ft7d', 'ft7dnc'])
+ ->and(Offer::query()->where('slug', 'bf26')->value('show_banner'))->toBeTrue()
+ ->and(Offer::query()->where('slug', 'ft7dnc')->value('requires_card'))->toBeFalse()
+ ->and(Offer::query()->where('slug', 'ft7dnc')->value('first_subscription_only'))->toBeTrue();
+});
diff --git a/tests/Feature/Welcome/WelcomeControllerTest.php b/tests/Feature/Welcome/WelcomeControllerTest.php
index d601a26f5..566904562 100644
--- a/tests/Feature/Welcome/WelcomeControllerTest.php
+++ b/tests/Feature/Welcome/WelcomeControllerTest.php
@@ -2,16 +2,21 @@
declare(strict_types=1);
+use App\Actions\Billing\StartGenericTrial;
use App\Actions\Billing\StartSubscriptionCheckout;
use App\Enums\Plan\Slug;
use App\Enums\PostHog\CheckoutEvent;
+use App\Enums\PostHog\TrialEvent;
use App\Enums\PostHog\WelcomeEvent;
use App\Enums\User\Goal;
use App\Enums\User\Locale;
use App\Enums\User\Persona;
use App\Enums\User\PreviousSoftware;
+use App\Jobs\PostHog\CaptureAccountEvent;
use App\Jobs\PostHog\SendEvent;
+use App\Jobs\PostHog\SyncUser;
use App\Models\Account;
+use App\Models\Offer;
use App\Models\Plan;
use App\Models\SocialAccount;
use App\Models\User;
@@ -196,24 +201,31 @@ test('plan shows the Socials plan', function () {
);
});
-test('plan offers the first month only when checkout will apply the coupon', function (Closure $setup, bool $offered) {
- config(['cashier.first_month_coupon_ids.socials' => 'coupon_socials']);
+test('plan sends a claimed trial offer only to an account that may use it', function (Closure $setup, bool $claims, bool $offered) {
+ $trial = Offer::factory()->freeTrial()->create();
completeWelcomeThroughSoftware($this->user);
$setup($this->user);
+ if ($claims) {
+ $this->user->account->offers()->attach($trial, ['claimed_at' => now()]);
+ }
+
$this->actingAs($this->user->fresh())
->get(route('app.welcome.plan'))
->assertOk()
- ->assertInertia(fn ($page) => $page->where('firstMonthOffer', $offered));
+ ->assertInertia(fn ($page) => $offered
+ ? $page->where('offer.key', 'ft7d')
+ : $page->where('offer', null));
})->with([
- 'first-time subscriber' => [fn () => null, true],
+ 'no claim pays the full price' => [fn () => null, false, false],
+ 'first-time subscriber' => [fn () => null, true, true],
'retrying an incomplete checkout' => [fn (User $user) => $user->account->subscriptions()->create([
'type' => Account::SUBSCRIPTION_NAME,
'stripe_id' => 'sub_incomplete',
'stripe_status' => 'incomplete',
'stripe_price' => 'price_monthly_test',
'quantity' => 1,
- ]), true],
+ ]), true, true],
'former subscriber' => [fn (User $user) => $user->account->subscriptions()->create([
'type' => Account::SUBSCRIPTION_NAME,
'stripe_id' => 'sub_canceled',
@@ -221,8 +233,7 @@ test('plan offers the first month only when checkout will apply the coupon', fun
'stripe_price' => 'price_monthly_test',
'quantity' => 1,
'ends_at' => now()->subDay(),
- ]), false],
- 'no coupon configured' => [fn () => config(['cashier.first_month_coupon_ids.socials' => '']), false],
+ ]), true, false],
]);
test('plan store sends the owner to Stripe checkout on the Socials monthly price', function () {
@@ -247,33 +258,6 @@ test('plan store sends the owner to Stripe checkout on the Socials monthly price
->assertRedirect('https://checkout.stripe.test/session');
});
-test('checkout.started records whether the first-month offer was shown', function (string $couponId, bool $offered) {
- config([
- 'services.posthog.enabled' => true,
- 'services.posthog.api_key' => 'phc_test',
- 'cashier.first_month_coupon_ids.socials' => $couponId,
- ]);
- Bus::fake();
- completeWelcomeThroughSoftware($this->user);
- Plan::where('slug', Slug::Socials)->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
-
- $this->mock(StartSubscriptionCheckout::class)
- ->shouldReceive('redirect')
- ->once()
- ->andReturn(redirect('https://checkout.stripe.test/session'));
-
- $this->actingAs($this->user->fresh())
- ->post(route('app.welcome.plan.store'))
- ->assertRedirect('https://checkout.stripe.test/session');
-
- Bus::assertDispatched(SendEvent::class, fn (SendEvent $event): bool => $event->method === 'capture'
- && data_get($event->payload, 'event') === CheckoutEvent::Started->value
- && data_get($event->payload, 'properties.is_first_month_offer') === $offered);
-})->with([
- 'with the coupon' => ['coupon_socials', true],
- 'without the coupon' => ['', false],
-]);
-
test('picking an AI app on the MCP step records which one', function (string $client) {
config(['services.posthog.enabled' => true, 'services.posthog.api_key' => 'phc_test']);
Bus::fake();
@@ -324,7 +308,7 @@ test('skipping the MCP step without app access goes back to Welcome and records
$this->actingAs($this->user)
->get(route('app.welcome.mcp.skip'))
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
Bus::assertNotDispatched(SendEvent::class);
});
@@ -396,7 +380,7 @@ test('the MCP step sends an account without app access back to Welcome', functio
$this->actingAs($this->user->fresh())
->get(route('app.welcome.mcp'))
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
});
test('plan store fails loudly when the Socials price is not configured', function () {
@@ -451,7 +435,7 @@ test('completed welcome steps remain reachable when going back', function () {
->assertInertia(fn ($page) => $page->component('welcome/Plan', false));
});
-test('welcome funnel captures every step before checkout.started', function () {
+test('welcome funnel captures every step up to the plan, in order', function () {
config(['services.posthog.enabled' => true, 'services.posthog.api_key' => 'phc_test']);
Bus::fake();
$workspace = attachCurrentWorkspace($this->user);
@@ -483,7 +467,7 @@ test('welcome funnel captures every step before checkout.started', function () {
->post(route('app.welcome.plan.store'))
->assertRedirect('https://checkout.stripe.test/session');
- $funnel = WelcomeEvent::funnel();
+ $funnel = array_values(array_diff(WelcomeEvent::funnel(), [CheckoutEvent::Started->value]));
$captured = collect(Bus::dispatched(SendEvent::class))
->filter(fn (SendEvent $event): bool => $event->method === 'capture')
@@ -525,21 +509,6 @@ test('welcome steps redirect to calendar for subscribed accounts', function (str
'plan store' => ['app.welcome.plan.store', 'post'],
]);
-test('welcome redirects generic-trial accounts with app access to calendar', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
- $this->user->account->forceFill([
- 'trial_ends_at' => now()->addDays(8),
- ])->save();
-
- expect($this->user->account->fresh()->hasAppAccess())->toBeTrue()
- ->and($this->user->account->fresh()->subscribed(Account::SUBSCRIPTION_NAME))->toBeFalse();
-
- $this->actingAs($this->user->fresh())
- ->get(route('app.welcome.persona'))
- ->assertRedirect(route('app.calendar'));
-});
-
test('welcome steps redirect to calendar in self hosted mode', function (string $routeName, string $method, array $payload = []) {
config(['trypost.self_hosted' => true]);
@@ -631,7 +600,7 @@ test('subscription required screen renders for members without app access', func
test('subscription required screen sends owners back to the welcome flow', function () {
$this->actingAs($this->user)
->get(route('app.welcome.subscription-required'))
- ->assertRedirect(route('app.welcome.persona'));
+ ->assertRedirect(route('app.welcome.plan'));
});
test('subscription required screen sends subscribed users to the calendar', function () {
@@ -695,3 +664,210 @@ function attachCurrentWorkspace(User $user): Workspace
return $workspace;
}
+
+test('the plan step sends the current offer', function () {
+ completeWelcomeThroughSoftware($this->user);
+ $offer = Offer::factory()->create(['slug' => 'black-friday-2026']);
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.welcome.plan'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->where('offer.key', 'black_friday_2026')
+ ->where('offer.has_banner', false)
+ ->where('offer.has_checkout_copy', false)
+ );
+});
+
+test('the plan step sends no offer once it expired', function () {
+ completeWelcomeThroughSoftware($this->user);
+ $offer = Offer::factory()->create(['ends_at' => now()->addHour()]);
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ $this->travel(2)->hours();
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.welcome.plan'))
+ ->assertOk()
+ ->assertInertia(fn ($page) => $page
+ ->where('offer', null)
+ );
+});
+
+test('plan store hands checkout the offer it tracked', function () {
+ completeWelcomeThroughSoftware($this->user);
+ Plan::where('slug', Slug::Socials)->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $offer = Offer::factory()->create();
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $checkoutOffer = null): bool => $checkoutOffer?->is($offer) === true)
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.welcome.plan.store'))
+ ->assertRedirect('https://checkout.stripe.test/session');
+});
+
+test('the plan step sends the banner only for an offer that shows one', function () {
+ app('translator')->addLines([
+ 'offers.black_friday_2026.name' => 'Black Friday',
+ 'offers.black_friday_2026.headline' => '50% off your first 3 months',
+ ], 'en');
+ completeWelcomeThroughSoftware($this->user);
+ $this->user->account->offers()->attach(Offer::factory()->create(['slug' => 'black-friday-2026']), ['claimed_at' => now()]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.welcome.plan'))
+ ->assertInertia(fn ($page) => $page->where('offer.has_banner', false));
+});
+
+test('the plan step sends the offer copy only when it exists in the user\'s language', function (string $locale, bool $hasCopy) {
+ app('translator')->addLines([
+ 'offers.black_friday_2026.name' => 'Black Friday',
+ 'offers.black_friday_2026.headline' => '50% off your first 3 months',
+ 'offers.black_friday_2026.price' => '$9.50',
+ 'offers.black_friday_2026.unit' => '/month',
+ 'offers.black_friday_2026.period' => 'for your first 3 months',
+ 'offers.black_friday_2026.checkout_button' => 'Activate my account',
+ ], 'en');
+ completeWelcomeThroughSoftware($this->user);
+ $this->user->update(['locale' => $locale]);
+ $this->user->account->offers()->attach(Offer::factory()->withBanner()->create(['slug' => 'black-friday-2026']), ['claimed_at' => now()]);
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.welcome.plan'))
+ ->assertInertia(fn ($page) => $page
+ ->where('offer.has_banner', $hasCopy)
+ ->where('offer.has_checkout_copy', $hasCopy)
+ ->where('offer.has_unit', $hasCopy)
+ );
+})->with([
+ 'english copy for an english user' => ['en', true],
+ 'english copy only for a portuguese user' => ['pt-BR', false],
+]);
+
+test('a trial without a card starts in the app, without Stripe', function () {
+ config(['services.posthog.enabled' => true, 'services.posthog.api_key' => 'phc_test']);
+ Bus::fake();
+ completeWelcomeThroughSoftware($this->user);
+ Plan::where('slug', Slug::Socials)->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $offer = Offer::factory()->trial(7)->withoutCard()->create(['slug' => 'ft7dnc']);
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ $this->mock(StartSubscriptionCheckout::class)->shouldReceive('redirect')->never();
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.welcome.plan.store'))
+ ->assertRedirect(route('app.billing.processing', ['from' => 'welcome']));
+
+ $account = $this->user->account->fresh();
+
+ expect($account->plan->slug)->toBe(Slug::Socials)
+ ->and($account->trial_ends_at->toDateString())->toBe(now()->addDays(7)->toDateString())
+ ->and($account->hasAppAccess())->toBeTrue()
+ ->and($account->stripe_id)->toBeNull()
+ ->and($account->offers()->first()->pivot->redeemed_at)->not->toBeNull();
+
+ Bus::assertDispatched(CaptureAccountEvent::class, fn (CaptureAccountEvent $job): bool => $job->event === TrialEvent::Started
+ && $job->properties['offer'] === 'ft7dnc');
+ Bus::assertDispatched(SyncUser::class, fn (SyncUser $job): bool => $job->userId === (string) $this->user->id);
+ Bus::assertNotDispatched(CaptureAccountEvent::class, fn (CaptureAccountEvent $job): bool => $job->event === CheckoutEvent::Started);
+});
+
+test('a second submit does not start the trial without a card again', function () {
+ config(['services.posthog.enabled' => true, 'services.posthog.api_key' => 'phc_test']);
+ Bus::fake();
+ completeWelcomeThroughSoftware($this->user);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $socials->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $offer = Offer::factory()->trial(7)->withoutCard()->create(['slug' => 'ft7dnc']);
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ StartGenericTrial::execute($this->user->fresh(), $socials, $offer);
+ StartGenericTrial::execute($this->user->fresh(), $socials, $offer);
+
+ Bus::assertDispatchedTimes(CaptureAccountEvent::class, 1);
+});
+
+test('a trial without a card whose last place went opens the full price checkout instead of a free trial', function () {
+ completeWelcomeThroughSoftware($this->user);
+ Plan::where('slug', Slug::Socials)->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $offer = Offer::factory()->trial(7)->withoutCard()->limitedTo(1)->create();
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+ Account::factory()->create()->offers()->attach($offer, ['claimed_at' => now(), 'redeemed_at' => now()]);
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $checkoutOffer = null): bool => blank($checkoutOffer))
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.welcome.plan.store'))
+ ->assertRedirect('https://checkout.stripe.test/session');
+
+ expect($this->user->account->fresh()->trial_ends_at)->toBeNull()
+ ->and($this->user->account->fresh()->hasAppAccess())->toBeFalse();
+});
+
+test('an offer that ends before the plan is submitted opens the full price checkout', function () {
+ completeWelcomeThroughSoftware($this->user);
+ Plan::where('slug', Slug::Socials)->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $offer = Offer::factory()->create(['ends_at' => now()->addHour()]);
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ $this->travel(2)->hours();
+
+ $this->mock(StartSubscriptionCheckout::class)
+ ->shouldReceive('redirect')
+ ->once()
+ ->withArgs(fn ($account, $priceId, $cancelUrl, $plan, $checkoutOffer = null): bool => blank($checkoutOffer))
+ ->andReturn(redirect('https://checkout.stripe.test/session'));
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.welcome.plan.store'))
+ ->assertRedirect('https://checkout.stripe.test/session');
+});
+
+test('when a trial without a card ends the owner loses access and is back at the plan step', function () {
+ completeWelcomeThroughSoftware($this->user);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $offer = Offer::factory()->trial(7)->withoutCard()->create();
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+ StartGenericTrial::execute($this->user->fresh(), $socials, $offer);
+
+ $this->travel(8)->days();
+
+ expect($this->user->account->fresh()->hasAppAccess())->toBeFalse();
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.calendar'))
+ ->assertRedirect(route('app.welcome.plan'));
+
+ $this->actingAs($this->user->fresh())
+ ->get(route('app.welcome.plan'))
+ ->assertInertia(fn ($page) => $page->where('offer', null));
+});
+
+test('an owner on a trial without a card never reaches checkout or a second trial from Welcome', function () {
+ completeWelcomeThroughSoftware($this->user);
+ $socials = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $socials->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $offer = Offer::factory()->trial(7)->withoutCard()->create();
+ $this->user->account->offers()->attach($offer, ['claimed_at' => now()]);
+ StartGenericTrial::execute($this->user->fresh(), $socials, $offer);
+ $trialEndsAt = $this->user->account->fresh()->trial_ends_at;
+ $this->user->account->offers()->attach(Offer::factory()->trial(14)->withoutCard()->create(), ['claimed_at' => now()->addMinute()]);
+
+ $this->mock(StartSubscriptionCheckout::class)->shouldReceive('redirect')->never();
+
+ $this->actingAs($this->user->fresh())
+ ->post(route('app.welcome.plan.store'))
+ ->assertRedirect(route('app.calendar'));
+
+ expect($this->user->account->fresh()->trial_ends_at->equalTo($trialEndsAt))->toBeTrue();
+});
diff --git a/tests/Feature/WorkspaceBillingTest.php b/tests/Feature/WorkspaceBillingTest.php
index bd31dd04b..44ad4dc08 100644
--- a/tests/Feature/WorkspaceBillingTest.php
+++ b/tests/Feature/WorkspaceBillingTest.php
@@ -56,7 +56,7 @@ test('ensure subscribed middleware redirects without subscription in saas mode',
$response = $this->actingAs($this->user)->get(route('app.calendar'));
- $response->assertRedirect(route('app.welcome.persona'));
+ $response->assertRedirect(route('app.welcome.plan'));
});
test('billing page is accessible by account owner', function () {
@@ -100,7 +100,7 @@ test('subscribe redirects to welcome', function () {
$response = $this->actingAs($this->user)->get(route('app.subscribe'));
- $response->assertRedirect(route('app.welcome.persona'));
+ $response->assertRedirect(route('app.welcome.plan'));
});
test('stripe email returns account owner email', function () {
diff --git a/tests/Pest.php b/tests/Pest.php
index 6f95121ea..c898f16e0 100644
--- a/tests/Pest.php
+++ b/tests/Pest.php
@@ -22,6 +22,8 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Str;
use Illuminate\Testing\TestResponse;
+use Stripe\ApiRequestor;
+use Stripe\HttpClient\ClientInterface;
use Tests\BrowserTestCase;
use Tests\TestCase;
@@ -350,6 +352,112 @@ function subscribeAccount(Account $account): void
]);
}
+/**
+ * Answers Stripe from memory for an account billed as `cus_fake` on
+ * `sub_fake`: the subscription with an optional coupon, the customer with an
+ * optional card, and no invoices. Reset with ApiRequestor::setHttpClient(null).
+ *
+ * @param array<string, mixed>|null $coupon
+ */
+function fakeStripeBilling(Account $account, ?array $coupon = null, ?int $discountEndsAt = null, ?string $cardBrand = null, int $paidInvoices = 0, ?string $secondCardBrand = null, bool $customerHasDefault = true, ?string $subscriptionCard = null, bool $customerDefaultIsLink = false): void
+{
+ config(['cashier.secret' => 'sk_test_fake']);
+ $account->forceFill(['stripe_id' => 'cus_fake'])->save();
+ $account->subscriptions()->create([
+ 'type' => Account::SUBSCRIPTION_NAME,
+ 'stripe_id' => 'sub_fake',
+ 'stripe_status' => 'active',
+ 'stripe_price' => 'price_123',
+ ]);
+
+ ApiRequestor::setHttpClient(new class($coupon, $discountEndsAt, $cardBrand, $paidInvoices, $secondCardBrand, $customerHasDefault, $subscriptionCard, $customerDefaultIsLink) implements ClientInterface
+ {
+ public function __construct(private ?array $coupon, private ?int $discountEndsAt, private ?string $cardBrand, private int $paidInvoices, private ?string $secondCardBrand, private bool $customerHasDefault, private ?string $subscriptionCard, private bool $customerDefaultIsLink) {}
+
+ public function request($method, $absUrl, $headers, $params, $hasFile, $apiMode = 'v1', $maxNetworkRetries = null): array
+ {
+ $card = blank($this->cardBrand) ? null : [
+ 'id' => 'pm_fake',
+ 'object' => 'payment_method',
+ 'customer' => 'cus_fake',
+ 'type' => 'card',
+ 'card' => ['brand' => $this->cardBrand, 'last4' => '4242', 'exp_month' => 4, 'exp_year' => 2044],
+ ];
+ $secondCard = blank($this->secondCardBrand) ? null : [
+ 'id' => 'pm_fake_second',
+ 'object' => 'payment_method',
+ 'customer' => 'cus_fake',
+ 'type' => 'card',
+ 'card' => ['brand' => $this->secondCardBrand, 'last4' => '5454', 'exp_month' => 5, 'exp_year' => 2055],
+ ];
+
+ $body = match (true) {
+ str_contains($absUrl, '/v1/subscriptions/') => [
+ 'id' => 'sub_fake',
+ 'object' => 'subscription',
+ 'default_payment_method' => $this->subscriptionCard,
+ 'discounts' => blank($this->coupon) ? [] : [[
+ 'id' => 'di_fake',
+ 'object' => 'discount',
+ 'coupon' => ['object' => 'coupon', 'id' => 'FAKE', ...$this->coupon],
+ 'start' => now()->subDay()->timestamp,
+ 'end' => $this->discountEndsAt,
+ ]],
+ ],
+ str_contains($absUrl, '/v1/customers/cus_fake/payment_methods'), str_contains($absUrl, '/v1/payment_methods') => ['object' => 'list', 'data' => array_values(array_filter([$secondCard, $card])), 'has_more' => false, 'url' => '/v1/payment_methods'],
+ str_contains($absUrl, '/v1/customers/') => [
+ 'id' => 'cus_fake',
+ 'object' => 'customer',
+ 'invoice_settings' => ['default_payment_method' => match (true) {
+ $this->customerDefaultIsLink => ['id' => 'pm_link', 'object' => 'payment_method', 'customer' => 'cus_fake', 'type' => 'link'],
+ $this->customerHasDefault => $card,
+ default => null,
+ }],
+ ],
+ str_contains($absUrl, '/v1/invoices') => $this->invoices($params),
+ default => ['object' => 'list', 'data' => [], 'has_more' => false, 'url' => '/v1/invoices'],
+ };
+
+ return [json_encode($body), 200, []];
+ }
+
+ /**
+ * The paid invoices, newest first, paged the way Stripe pages them:
+ * `limit` and `starting_after`, and only when `status` is `paid`.
+ *
+ * @param array<string, mixed> $params
+ * @return array<string, mixed>
+ */
+ private function invoices(array $params): array
+ {
+ $invoices = collect($this->paidInvoices > 0 ? range($this->paidInvoices, 1) : [])
+ ->filter(fn (): bool => data_get($params, 'status') === 'paid')
+ ->map(fn (int $number): array => [
+ 'id' => sprintf('in_fake_%03d', $number),
+ 'object' => 'invoice',
+ 'customer' => 'cus_fake',
+ 'status' => 'paid',
+ 'currency' => 'usd',
+ 'total' => 1900,
+ 'created' => now()->subMonths($this->paidInvoices - $number)->timestamp,
+ 'invoice_pdf' => "https://pay.stripe.com/invoice/in_fake_{$number}/pdf",
+ ])
+ ->values();
+
+ $after = data_get($params, 'starting_after');
+ $start = blank($after) ? 0 : $invoices->search(fn (array $invoice): bool => $invoice['id'] === $after) + 1;
+ $limit = (int) data_get($params, 'limit', 10);
+
+ return [
+ 'object' => 'list',
+ 'data' => $invoices->slice($start, $limit)->values()->all(),
+ 'has_more' => $invoices->count() > $start + $limit,
+ 'url' => '/v1/invoices',
+ ];
+ }
+ });
+}
+
/**
* Turns PostHog on for the test, as on an install with an API key.
*/
diff --git a/tests/Unit/Actions/Billing/StartSubscriptionCheckoutTest.php b/tests/Unit/Actions/Billing/StartSubscriptionCheckoutTest.php
index 935aa25b5..54bc5a2aa 100644
--- a/tests/Unit/Actions/Billing/StartSubscriptionCheckoutTest.php
+++ b/tests/Unit/Actions/Billing/StartSubscriptionCheckoutTest.php
@@ -4,14 +4,18 @@ declare(strict_types=1);
use App\Actions\Billing\StartSubscriptionCheckout;
use App\Enums\Plan\Slug;
+use App\Enums\PostHog\CheckoutEvent;
use App\Enums\User\Persona;
use App\Enums\User\PreviousSoftware;
use App\Enums\User\ReferralSource;
+use App\Jobs\PostHog\CaptureAccountEvent;
use App\Models\Account;
+use App\Models\Offer;
use App\Models\Plan;
use App\Models\User;
use App\Models\Workspace;
use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Support\Facades\Bus;
use Laravel\Cashier\SubscriptionBuilder;
use Mockery\MockInterface;
use Stripe\ApiRequestor;
@@ -45,6 +49,7 @@ function fakeStripeCustomerClient(): ClientInterface
function checkoutCustomerBuilder(): SubscriptionBuilder
{
$builder = Mockery::mock(SubscriptionBuilder::class);
+ $builder->shouldReceive('allowPromotionCodes')->andReturnSelf();
$builder->shouldReceive('withMetadata')->andReturnSelf();
$builder->shouldReceive('trialDays')->andReturnSelf();
$builder->shouldReceive('checkout')->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
@@ -57,15 +62,6 @@ afterEach(function () {
});
test('redirect keeps the attribution metadata on the stripe customer, not on the subscription', function () {
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids' => [
- 'socials' => '',
- 'workspaces' => '',
- ],
- 'cashier.allow_promotion_codes' => false,
- ]);
$account = Account::factory()->create();
Workspace::factory()->create(['account_id' => $account->id]);
@@ -93,17 +89,16 @@ test('redirect keeps the attribution metadata on the stripe customer, not on the
$builder = Mockery::mock(SubscriptionBuilder::class);
$builder->shouldReceive('withMetadata')->once()->with([])->andReturnSelf();
- $builder->shouldReceive('trialDays')->once()->with(8)->andReturnSelf();
+ $builder->shouldReceive('trialDays')->never();
$builder->shouldReceive('withCoupon')->never();
- $builder->shouldReceive('allowPromotionCodes')->never();
+ $builder->shouldReceive('allowPromotionCodes')->once()->andReturnSelf();
$builder->shouldReceive('checkout')
->once()
->with([
- 'success_url' => route('app.billing.processing').'?session_id={CHECKOUT_SESSION_ID}',
+ 'success_url' => route('app.billing.processing', ['from' => 'welcome']).'&session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => $cancelUrl,
'metadata' => [
'trypost_interval' => 'monthly',
- 'trypost_first_month_offer' => 'false',
],
])
->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
@@ -145,15 +140,6 @@ test('redirect keeps the attribution metadata on the stripe customer, not on the
});
test('redirect sends no metadata for an account whose owner left every field empty', function () {
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids' => [
- 'socials' => '',
- 'workspaces' => '',
- ],
- 'cashier.allow_promotion_codes' => false,
- ]);
$account = Account::factory()->create();
Workspace::factory()->create(['account_id' => $account->id]);
@@ -163,8 +149,9 @@ test('redirect sends no metadata for an account whose owner left every field emp
$cancelUrl = route('app.welcome');
$builder = Mockery::mock(SubscriptionBuilder::class);
+ $builder->shouldReceive('allowPromotionCodes')->once()->andReturnSelf();
$builder->shouldReceive('withMetadata')->once()->with([])->andReturnSelf();
- $builder->shouldReceive('trialDays')->once()->andReturnSelf();
+ $builder->shouldReceive('trialDays')->never();
$builder->shouldReceive('checkout')
->once()
->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
@@ -180,15 +167,6 @@ test('redirect sends no metadata for an account whose owner left every field emp
});
test('redirect cuts an oversized click id to the stripe metadata limit', function () {
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids' => [
- 'socials' => '',
- 'workspaces' => '',
- ],
- 'cashier.allow_promotion_codes' => false,
- ]);
$account = Account::factory()->create();
Workspace::factory()->create(['account_id' => $account->id]);
@@ -209,16 +187,13 @@ test('redirect cuts an oversized click id to the stripe metadata limit', functio
app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_monthly_test', route('app.welcome'));
});
-test('redirect applies the plan first-month coupon on a monthly price', function () {
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => false,
- ]);
+test('checkout session carries the plan and interval of a yearly price', function () {
- $plan = Plan::where('slug', Slug::Socials)->firstOrFail();
- $plan->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $plan = Plan::where('slug', Slug::Workspaces)->firstOrFail();
+ $plan->update([
+ 'stripe_monthly_price_id' => 'price_workspaces_monthly',
+ 'stripe_yearly_price_id' => 'price_workspaces_yearly',
+ ]);
$account = Account::factory()->create();
Workspace::factory()->create(['account_id' => $account->id]);
@@ -226,23 +201,15 @@ test('redirect applies the plan first-month coupon on a monthly price', function
$account->refresh();
$builder = Mockery::mock(SubscriptionBuilder::class);
- $builder->shouldReceive('withCoupon')
- ->once()
- ->with('SOCIALS_18USD')
- ->ordered()
- ->andReturnUsing(function () use ($builder): SubscriptionBuilder {
- $builder->couponId = 'SOCIALS_18USD';
-
- return $builder;
- });
- $builder->shouldReceive('withMetadata')
- ->once()
- ->with(['trypost_first_month_coupon_id' => 'SOCIALS_18USD'])
- ->ordered()
- ->andReturnSelf();
+ $builder->shouldReceive('allowPromotionCodes')->once()->andReturnSelf();
+ $builder->shouldReceive('withMetadata')->once()->andReturnSelf();
$builder->shouldReceive('trialDays')->never();
$builder->shouldReceive('checkout')
->once()
+ ->withArgs(fn (array $options): bool => data_get($options, 'metadata') === [
+ 'trypost_plan_slug' => 'workspaces',
+ 'trypost_interval' => 'yearly',
+ ])
->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
/** @var Account&MockInterface $accountMock */
@@ -252,19 +219,108 @@ test('redirect applies the plan first-month coupon on a monthly price', function
app(StartSubscriptionCheckout::class)->redirect(
$accountMock,
- 'price_socials_monthly',
- route('app.welcome.software'),
+ 'price_workspaces_yearly',
+ route('app.welcome.plan'),
$plan,
);
});
-test('checkout session carries plan, interval and first month offer metadata', function () {
+test('redirect clears a leftover plan_id before opening checkout', function () {
+
+ $workspaces = Plan::where('slug', Slug::Workspaces)->firstOrFail();
+ $account = Account::factory()->create(['plan_id' => $workspaces->id]);
+ Workspace::factory()->create(['account_id' => $account->id]);
+ User::factory()->create(['account_id' => $account->id, 'referral_source' => null]);
+ $account->refresh();
+
+ $builder = Mockery::mock(SubscriptionBuilder::class);
+ $builder->shouldReceive('allowPromotionCodes')->once()->andReturnSelf();
+ $builder->shouldReceive('withMetadata')->once()->andReturnSelf();
+ $builder->shouldReceive('trialDays')->never();
+ $builder->shouldReceive('checkout')
+ ->once()
+ ->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
+
+ /** @var Account&MockInterface $accountMock */
+ $accountMock = Mockery::mock($account)->makePartial();
+ $accountMock->shouldReceive('syncOrCreateStripeCustomer')->once()->andReturnNull();
+ $accountMock->shouldReceive('newSubscription')->once()->andReturn($builder);
+
+ app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_monthly_test', route('app.welcome.software'));
+
+ expect($account->fresh()->plan_id)->toBeNull();
+});
+
+test('redirect creates a new stripe customer with the owner email, the owner name and the metadata', function () {
+ config([
+ 'cashier.secret' => 'sk_test_fake',
+ ]);
+ $client = fakeStripeCustomerClient();
+
+ $account = Account::factory()->create(['name' => "Ada's Account"]);
+ $owner = User::factory()->create([
+ 'account_id' => $account->id,
+ 'name' => 'Ada Lovelace',
+ 'email' => '[email protected]',
+ 'utm_source' => 'google',
+ 'previous_software' => PreviousSoftware::Metricool,
+ 'referral_source' => null,
+ ]);
+ $account->update(['owner_id' => $owner->id]);
+ $account->refresh();
+
+ /** @var Account&MockInterface $accountMock */
+ $accountMock = Mockery::mock($account)->makePartial();
+ $accountMock->shouldReceive('newSubscription')->once()->andReturn(checkoutCustomerBuilder());
+
+ app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_monthly_test', route('app.welcome.software'));
+
+ expect($client->requests)->toHaveCount(1)
+ ->and($client->requests[0]['method'])->toBe('post')
+ ->and($client->requests[0]['url'])->toEndWith('/v1/customers')
+ ->and($client->requests[0]['params'])->toMatchArray([
+ 'email' => '[email protected]',
+ 'name' => 'Ada Lovelace',
+ 'metadata' => ['utm_source' => 'google', 'previous_software' => 'metricool'],
+ ])
+ ->and($account->fresh()->stripe_id)->toBe('cus_new');
+});
+
+test('redirect updates an existing stripe customer with the current details and metadata', function () {
config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => false,
+ 'cashier.secret' => 'sk_test_fake',
]);
+ $client = fakeStripeCustomerClient();
+
+ $account = Account::factory()->create(['name' => "Ada's Account", 'stripe_id' => 'cus_existing']);
+ $owner = User::factory()->create([
+ 'account_id' => $account->id,
+ 'name' => 'New Owner',
+ 'email' => '[email protected]',
+ 'persona' => Persona::Agency,
+ 'referral_source' => null,
+ ]);
+ $account->update(['owner_id' => $owner->id]);
+ $account->refresh();
+
+ /** @var Account&MockInterface $accountMock */
+ $accountMock = Mockery::mock($account)->makePartial();
+ $accountMock->shouldReceive('newSubscription')->once()->andReturn(checkoutCustomerBuilder());
+
+ app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_monthly_test', route('app.welcome.software'));
+
+ expect($client->requests)->toHaveCount(1)
+ ->and($client->requests[0]['method'])->toBe('post')
+ ->and($client->requests[0]['url'])->toEndWith('/v1/customers/cus_existing')
+ ->and($client->requests[0]['params'])->toMatchArray([
+ 'email' => '[email protected]',
+ 'name' => 'New Owner',
+ ])
+ ->and($client->requests[0]['params']['metadata'])->toMatchArray(['persona' => 'agency', 'referral_source' => ''])
+ ->and($account->fresh()->stripe_id)->toBe('cus_existing');
+});
+
+test('stores the offer id and slug in subscription and checkout metadata', function () {
$plan = Plan::where('slug', Slug::Socials)->firstOrFail();
$plan->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
@@ -272,22 +328,23 @@ test('checkout session carries plan, interval and first month offer metadata', f
$account = Account::factory()->create();
Workspace::factory()->create(['account_id' => $account->id]);
User::factory()->create(['account_id' => $account->id, 'referral_source' => null]);
+ $offer = Offer::factory()->create(['stripe_coupon_id' => 'BLACK_FRIDAY_50']);
+ $account->offers()->attach($offer, ['claimed_at' => now()]);
$account->refresh();
$builder = Mockery::mock(SubscriptionBuilder::class);
- $builder->shouldReceive('withCoupon')->once()->andReturnUsing(function () use ($builder): SubscriptionBuilder {
- $builder->couponId = 'SOCIALS_18USD';
+ $builder->shouldReceive('withCoupon')->once()->with('BLACK_FRIDAY_50')->andReturnUsing(function () use ($builder): SubscriptionBuilder {
+ $builder->couponId = 'BLACK_FRIDAY_50';
return $builder;
});
- $builder->shouldReceive('withMetadata')->once()->andReturnSelf();
+ $builder->shouldReceive('withMetadata')
+ ->once()
+ ->with(['trypost_offer_id' => $offer->id, 'trypost_offer_slug' => $offer->slug])
+ ->andReturnSelf();
$builder->shouldReceive('checkout')
->once()
- ->withArgs(fn (array $options): bool => data_get($options, 'metadata') === [
- 'trypost_plan_slug' => 'socials',
- 'trypost_interval' => 'monthly',
- 'trypost_first_month_offer' => 'true',
- ])
+ ->withArgs(fn (array $options): bool => data_get($options, 'metadata.trypost_offer_slug') === $offer->slug)
->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
/** @var Account&MockInterface $accountMock */
@@ -300,65 +357,54 @@ test('checkout session carries plan, interval and first month offer metadata', f
'price_socials_monthly',
route('app.welcome.plan'),
$plan,
+ $offer,
);
});
-test('checkout session marks a yearly price without the first month offer', function () {
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids.workspaces' => 'WORKSPACES_88USD',
- 'cashier.allow_promotion_codes' => false,
- ]);
+test('redirect uses the offer it is given and never looks one up', function () {
- $plan = Plan::where('slug', Slug::Workspaces)->firstOrFail();
- $plan->update([
- 'stripe_monthly_price_id' => 'price_workspaces_monthly',
- 'stripe_yearly_price_id' => 'price_workspaces_yearly',
- ]);
+ $plan = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $plan->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
$account = Account::factory()->create();
Workspace::factory()->create(['account_id' => $account->id]);
User::factory()->create(['account_id' => $account->id, 'referral_source' => null]);
+ $offer = Offer::factory()->create(['stripe_coupon_id' => 'BLACK_FRIDAY_50']);
$account->refresh();
$builder = Mockery::mock(SubscriptionBuilder::class);
- $builder->shouldReceive('withMetadata')->once()->andReturnSelf();
- $builder->shouldReceive('trialDays')->once()->andReturnSelf();
- $builder->shouldReceive('checkout')
+ $builder->shouldReceive('withCoupon')->once()->with('BLACK_FRIDAY_50')->andReturnUsing(function () use ($builder): SubscriptionBuilder {
+ $builder->couponId = 'BLACK_FRIDAY_50';
+
+ return $builder;
+ });
+ $builder->shouldReceive('withMetadata')
->once()
- ->withArgs(fn (array $options): bool => data_get($options, 'metadata') === [
- 'trypost_plan_slug' => 'workspaces',
- 'trypost_interval' => 'yearly',
- 'trypost_first_month_offer' => 'false',
- ])
- ->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
+ ->with(['trypost_offer_id' => $offer->id, 'trypost_offer_slug' => $offer->slug])
+ ->andReturnSelf();
+ $builder->shouldReceive('checkout')->once()->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
/** @var Account&MockInterface $accountMock */
$accountMock = Mockery::mock($account)->makePartial();
$accountMock->shouldReceive('syncOrCreateStripeCustomer')->once()->andReturnNull();
$accountMock->shouldReceive('newSubscription')->once()->andReturn($builder);
+ $accountMock->shouldReceive('currentOffer')->never();
app(StartSubscriptionCheckout::class)->redirect(
$accountMock,
- 'price_workspaces_yearly',
+ 'price_socials_monthly',
route('app.welcome.plan'),
$plan,
+ $offer,
);
});
-test('redirect skips the first-month coupon on a yearly price', function () {
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids.workspaces' => 'WORKSPACES_88USD',
- 'cashier.allow_promotion_codes' => false,
- ]);
+test('redirect skips the offer on a yearly price', function () {
- $plan = Plan::where('slug', Slug::Workspaces)->firstOrFail();
+ $plan = Plan::where('slug', Slug::Socials)->firstOrFail();
$plan->update([
- 'stripe_monthly_price_id' => 'price_workspaces_monthly',
- 'stripe_yearly_price_id' => 'price_workspaces_yearly',
+ 'stripe_monthly_price_id' => 'price_socials_monthly',
+ 'stripe_yearly_price_id' => 'price_socials_yearly',
]);
$account = Account::factory()->create();
@@ -367,12 +413,11 @@ test('redirect skips the first-month coupon on a yearly price', function () {
$account->refresh();
$builder = Mockery::mock(SubscriptionBuilder::class);
+ $builder->shouldReceive('allowPromotionCodes')->once()->andReturnSelf();
$builder->shouldReceive('withMetadata')->once()->with([])->andReturnSelf();
$builder->shouldReceive('withCoupon')->never();
- $builder->shouldReceive('trialDays')->once()->with(8)->andReturnSelf();
- $builder->shouldReceive('checkout')
- ->once()
- ->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
+ $builder->shouldReceive('trialDays')->never();
+ $builder->shouldReceive('checkout')->once()->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
/** @var Account&MockInterface $accountMock */
$accountMock = Mockery::mock($account)->makePartial();
@@ -381,119 +426,112 @@ test('redirect skips the first-month coupon on a yearly price', function () {
app(StartSubscriptionCheckout::class)->redirect(
$accountMock,
- 'price_workspaces_yearly',
- route('app.welcome.software'),
+ 'price_socials_yearly',
+ route('app.welcome.plan'),
$plan,
+ Offer::factory()->create(),
);
});
-test('redirect clears a leftover plan_id before opening checkout', function () {
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids' => [
- 'socials' => '',
- 'workspaces' => '',
- ],
- 'cashier.allow_promotion_codes' => false,
- ]);
+test('redirect gives the trial of the offer it is given', function () {
+ $plan = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $plan->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
- $workspaces = Plan::where('slug', Slug::Workspaces)->firstOrFail();
- $account = Account::factory()->create(['plan_id' => $workspaces->id]);
- Workspace::factory()->create(['account_id' => $account->id]);
+ $account = Account::factory()->create();
User::factory()->create(['account_id' => $account->id, 'referral_source' => null]);
+ $offer = Offer::factory()->freeTrial()->create();
$account->refresh();
$builder = Mockery::mock(SubscriptionBuilder::class);
- $builder->shouldReceive('withMetadata')->once()->andReturnSelf();
- $builder->shouldReceive('trialDays')->once()->andReturnSelf();
- $builder->shouldReceive('checkout')
+ $builder->shouldReceive('trialDays')->once()->with(8)->andReturnSelf();
+ $builder->shouldReceive('withCoupon')->never();
+ $builder->shouldReceive('withMetadata')
->once()
- ->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
+ ->with(['trypost_offer_id' => $offer->id, 'trypost_offer_slug' => 'ft7d'])
+ ->andReturnSelf();
+ $builder->shouldReceive('checkout')->once()->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
/** @var Account&MockInterface $accountMock */
$accountMock = Mockery::mock($account)->makePartial();
$accountMock->shouldReceive('syncOrCreateStripeCustomer')->once()->andReturnNull();
$accountMock->shouldReceive('newSubscription')->once()->andReturn($builder);
- app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_monthly_test', route('app.welcome.software'));
-
- expect($account->fresh()->plan_id)->toBeNull();
+ app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_socials_monthly', route('app.welcome.plan'), $plan, $offer);
});
-test('redirect creates a new stripe customer with the owner email, the owner name and the metadata', function () {
- config([
- 'cashier.secret' => 'sk_test_fake',
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids' => ['socials' => '', 'workspaces' => ''],
- 'cashier.allow_promotion_codes' => false,
- ]);
- $client = fakeStripeCustomerClient();
+test('redirect from a generic trial charges at once and keeps the trial plan', function () {
+ $plan = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $plan->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
+ $trialEndsAt = now()->addDays(4)->startOfSecond();
- $account = Account::factory()->create(['name' => "Ada's Account"]);
- $owner = User::factory()->create([
- 'account_id' => $account->id,
- 'name' => 'Ada Lovelace',
- 'email' => '[email protected]',
- 'utm_source' => 'google',
- 'previous_software' => PreviousSoftware::Metricool,
- 'referral_source' => null,
- ]);
- $account->update(['owner_id' => $owner->id]);
+ $account = Account::factory()->create(['plan_id' => $plan->id, 'trial_ends_at' => $trialEndsAt]);
+ User::factory()->create(['account_id' => $account->id, 'referral_source' => null]);
$account->refresh();
+ $builder = Mockery::mock(SubscriptionBuilder::class);
+ $builder->shouldReceive('allowPromotionCodes')->once()->andReturnSelf();
+ $builder->shouldReceive('trialUntil')->never();
+ $builder->shouldReceive('trialDays')->never();
+ $builder->shouldReceive('withMetadata')->once()->andReturnSelf();
+ $builder->shouldReceive('checkout')->once()->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
+
/** @var Account&MockInterface $accountMock */
$accountMock = Mockery::mock($account)->makePartial();
- $accountMock->shouldReceive('newSubscription')->once()->andReturn(checkoutCustomerBuilder());
+ $accountMock->shouldReceive('syncOrCreateStripeCustomer')->once()->andReturnNull();
+ $accountMock->shouldReceive('newSubscription')->once()->andReturn($builder);
- app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_monthly_test', route('app.welcome.software'));
+ app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_socials_monthly', route('app.billing.index'), $plan);
- expect($client->requests)->toHaveCount(1)
- ->and($client->requests[0]['method'])->toBe('post')
- ->and($client->requests[0]['url'])->toEndWith('/v1/customers')
- ->and($client->requests[0]['params'])->toMatchArray([
- 'email' => '[email protected]',
- 'name' => 'Ada Lovelace',
- 'metadata' => ['utm_source' => 'google', 'previous_software' => 'metricool'],
- ])
- ->and($account->fresh()->stripe_id)->toBe('cus_new');
+ expect($account->fresh()->plan_id)->toBe($plan->id);
});
-test('redirect updates an existing stripe customer with the current details and metadata', function () {
- config([
- 'cashier.secret' => 'sk_test_fake',
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids' => ['socials' => '', 'workspaces' => ''],
- 'cashier.allow_promotion_codes' => false,
- ]);
- $client = fakeStripeCustomerClient();
+test('redirect tracks checkout.started on the owner with the plan, interval and offer', function () {
+ config(['services.posthog.enabled' => true, 'services.posthog.api_key' => 'phc_test']);
+ Bus::fake([CaptureAccountEvent::class]);
+ $plan = Plan::where('slug', Slug::Socials)->firstOrFail();
+ $plan->update(['stripe_monthly_price_id' => 'price_socials_monthly']);
- $account = Account::factory()->create(['name' => "Ada's Account", 'stripe_id' => 'cus_existing']);
- $owner = User::factory()->create([
- 'account_id' => $account->id,
- 'name' => 'New Owner',
- 'email' => '[email protected]',
- 'persona' => Persona::Agency,
- 'referral_source' => null,
- ]);
+ $account = Account::factory()->create();
+ $owner = User::factory()->create(['account_id' => $account->id, 'referral_source' => null]);
$account->update(['owner_id' => $owner->id]);
+ $offer = Offer::factory()->blackFriday()->create();
$account->refresh();
+ $builder = Mockery::mock(SubscriptionBuilder::class);
+ $builder->shouldReceive('withCoupon')->once()->andReturnSelf();
+ $builder->shouldReceive('withMetadata')->once()->andReturnSelf();
+ $builder->shouldReceive('checkout')->once()->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
+
/** @var Account&MockInterface $accountMock */
$accountMock = Mockery::mock($account)->makePartial();
- $accountMock->shouldReceive('newSubscription')->once()->andReturn(checkoutCustomerBuilder());
+ $accountMock->shouldReceive('syncOrCreateStripeCustomer')->once()->andReturnNull();
+ $accountMock->shouldReceive('newSubscription')->once()->andReturn($builder);
- app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_monthly_test', route('app.welcome.software'));
+ app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_socials_monthly', route('app.welcome.plan'), $plan, $offer);
- expect($client->requests)->toHaveCount(1)
- ->and($client->requests[0]['method'])->toBe('post')
- ->and($client->requests[0]['url'])->toEndWith('/v1/customers/cus_existing')
- ->and($client->requests[0]['params'])->toMatchArray([
- 'email' => '[email protected]',
- 'name' => 'New Owner',
- ])
- ->and($client->requests[0]['params']['metadata'])->toMatchArray(['persona' => 'agency', 'referral_source' => ''])
- ->and($account->fresh()->stripe_id)->toBe('cus_existing');
+ Bus::assertDispatched(CaptureAccountEvent::class, fn (CaptureAccountEvent $job): bool => $job->event === CheckoutEvent::Started
+ && $job->distinctId === (string) $owner->id
+ && $job->properties === ['plan_name' => 'Socials', 'interval' => 'monthly', 'offer' => 'bf26']);
+});
+
+test('redirect gives no offer to a plan other than Socials monthly', function () {
+ $workspaces = Plan::where('slug', Slug::Workspaces)->firstOrFail();
+ $workspaces->update(['stripe_monthly_price_id' => 'price_workspaces_monthly']);
+
+ $account = Account::factory()->create();
+ User::factory()->create(['account_id' => $account->id, 'referral_source' => null]);
+ $account->refresh();
+
+ $builder = Mockery::mock(SubscriptionBuilder::class);
+ $builder->shouldReceive('allowPromotionCodes')->once()->andReturnSelf();
+ $builder->shouldReceive('withCoupon')->never();
+ $builder->shouldReceive('withMetadata')->once()->with([])->andReturnSelf();
+ $builder->shouldReceive('checkout')->once()->andReturn((object) ['url' => 'https://checkout.stripe.test/session']);
+
+ /** @var Account&MockInterface $accountMock */
+ $accountMock = Mockery::mock($account)->makePartial();
+ $accountMock->shouldReceive('syncOrCreateStripeCustomer')->once()->andReturnNull();
+ $accountMock->shouldReceive('newSubscription')->once()->andReturn($builder);
+
+ app(StartSubscriptionCheckout::class)->redirect($accountMock, 'price_workspaces_monthly', route('app.billing.index'), $workspaces, Offer::factory()->blackFriday()->create());
});
diff --git a/tests/Unit/Models/AccountTest.php b/tests/Unit/Models/AccountTest.php
index a91c98191..5422f75bc 100644
--- a/tests/Unit/Models/AccountTest.php
+++ b/tests/Unit/Models/AccountTest.php
@@ -4,12 +4,12 @@ declare(strict_types=1);
use App\Enums\Plan\Slug;
use App\Models\Account;
+use App\Models\Offer;
use App\Models\Plan;
use Carbon\Carbon;
use Database\Seeders\PlanSeeder;
beforeEach(function () {
- config(['trypost.billing.require_card_for_trial' => true]);
$this->seed(PlanSeeder::class);
Carbon::setTestNow('2026-05-14 12:00:00');
});
@@ -117,15 +117,7 @@ test('isPastDue returns false when self-hosted', function () {
expect($account->isPastDue())->toBeFalse();
});
-test('isOnTrial ignores generic trial when there is no subscription', function () {
- $account = Account::factory()->create(['trial_ends_at' => now()->addDays(7)]);
-
- expect($account->isOnTrial())->toBeFalse();
-});
-
-test('isOnTrial includes generic trial when card is not required', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
+test('isOnTrial includes a generic trial without a subscription', function () {
$account = Account::factory()->create(['trial_ends_at' => now()->addDays(7)]);
expect($account->isOnTrial())->toBeTrue();
@@ -163,17 +155,7 @@ test('activeTrialEndsAt returns generic trial date when only generic is active',
$endsAt = now()->addDays(7);
$account = Account::factory()->create(['trial_ends_at' => $endsAt]);
- expect($account->activeTrialEndsAt())->toBeNull();
-});
-
-test('activeTrialEndsAt returns generic trial date when card is not required', function () {
- config(['trypost.billing.require_card_for_trial' => false]);
-
- $endsAt = now()->addDays(7);
- $account = Account::factory()->create(['trial_ends_at' => $endsAt]);
-
- expect($account->activeTrialEndsAt()?->toDateTimeString())
- ->toBe($endsAt->toDateTimeString());
+ expect($account->activeTrialEndsAt()?->toDateTimeString())->toBe($endsAt->toDateTimeString());
});
test('activeTrialEndsAt returns subscription date when only subscription trial is active', function () {
@@ -300,39 +282,37 @@ test('hasAppAccess is true for a past_due subscription', function () {
expect($account->fresh()->hasAppAccess())->toBeTrue();
});
-test('hasAppAccess ignores generic trial when card is required', function () {
- config([
- 'trypost.self_hosted' => false,
- 'trypost.billing.require_card_for_trial' => true,
- ]);
+test('hasAppAccess lasts as long as a generic trial', function () {
+ config(['trypost.self_hosted' => false]);
$account = Account::factory()->create(['trial_ends_at' => now()->addDays(7)]);
- expect($account->hasAppAccess())->toBeFalse()
- ->and($account->isOnTrial())->toBeFalse();
-});
+ expect($account->hasAppAccess())->toBeTrue();
-test('hasAppAccess allows generic trial when card is not required', function () {
- config([
- 'trypost.self_hosted' => false,
- 'trypost.billing.require_card_for_trial' => false,
- ]);
+ Carbon::setTestNow(now()->addDays(8));
- $account = Account::factory()->create(['trial_ends_at' => now()->addDays(7)]);
+ expect($account->fresh()->hasAppAccess())->toBeFalse()
+ ->and($account->fresh()->isOnTrial())->toBeFalse();
+});
+
+test('a subscription created during a redeemed trial without a card was subscribed during that trial', function () {
+ $account = Account::factory()->create();
+ $account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subDays(3), 'redeemed_at' => now()->subDays(3)]);
- expect($account->hasAppAccess())->toBeTrue()
- ->and($account->isOnTrial())->toBeTrue()
- ->and($account->subscribed(Account::SUBSCRIPTION_NAME))->toBeFalse();
+ expect($account->subscribedDuringTrialWithoutCard(now()))->toBeTrue()
+ ->and($account->subscribedDuringTrialWithoutCard(now()->addDays(5)))->toBeFalse();
});
-test('hasAppAccess denies expired generic trial when card is not required', function () {
- config([
- 'trypost.self_hosted' => false,
- 'trypost.billing.require_card_for_trial' => false,
- ]);
+test('a trial that asked for a card is not a trial without a card', function () {
+ $account = Account::factory()->create();
+ $account->offers()->attach(Offer::factory()->trial(7)->create(), ['claimed_at' => now()->subDay(), 'redeemed_at' => now()->subDay()]);
+
+ expect($account->subscribedDuringTrialWithoutCard(now()))->toBeFalse();
+});
- $account = Account::factory()->create(['trial_ends_at' => now()->subDay()]);
+test('a claimed trial without a card that was never redeemed is not a trial', function () {
+ $account = Account::factory()->create();
+ $account->offers()->attach(Offer::factory()->trial(7)->withoutCard()->create(), ['claimed_at' => now()->subDay()]);
- expect($account->hasAppAccess())->toBeFalse()
- ->and($account->isOnTrial())->toBeFalse();
+ expect($account->subscribedDuringTrialWithoutCard(now()))->toBeFalse();
});
diff --git a/tests/Unit/Support/Billing/ConfigureSubscriptionCheckoutTest.php b/tests/Unit/Support/Billing/ConfigureSubscriptionCheckoutTest.php
index c466e00aa..8da44e41d 100644
--- a/tests/Unit/Support/Billing/ConfigureSubscriptionCheckoutTest.php
+++ b/tests/Unit/Support/Billing/ConfigureSubscriptionCheckoutTest.php
@@ -4,8 +4,8 @@ declare(strict_types=1);
use App\Enums\Plan\Slug;
use App\Models\Account;
+use App\Models\Offer;
use App\Models\Plan;
-use App\Models\Workspace;
use App\Support\Billing\ConfigureSubscriptionCheckout;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -15,23 +15,8 @@ uses(RefreshDatabase::class);
beforeEach(function () {
$this->account = Account::factory()->create();
-
- config([
- 'trypost.billing.require_card_for_trial' => true,
- 'cashier.trial_days' => 8,
- 'cashier.first_month_coupon_ids' => [
- 'socials' => '',
- 'workspaces' => '',
- ],
- 'cashier.allow_promotion_codes' => false,
- ]);
});
-function checkoutSubscription(Account $account): SubscriptionBuilder
-{
- return $account->newSubscription(Account::SUBSCRIPTION_NAME, 'price_monthly_test');
-}
-
function givePriorSubscription(Account $account, string $status = 'canceled'): void
{
$account->subscriptions()->create([
@@ -40,6 +25,7 @@ function givePriorSubscription(Account $account, string $status = 'canceled'): v
'stripe_status' => $status,
'stripe_price' => 'price_monthly_test',
]);
+ $account->unsetRelation('subscriptions');
}
function trialExpiresAt(SubscriptionBuilder $subscription): ?Carbon
@@ -54,298 +40,126 @@ function socialsPlan(): Plan
return Plan::where('slug', Slug::Socials)->firstOrFail();
}
-function workspacesPlan(): Plan
+function claimOfferFor(Account $account, Offer $offer): Offer
{
- return Plan::where('slug', Slug::Workspaces)->firstOrFail();
+ $account->offers()->attach($offer, ['claimed_at' => now()]);
+
+ return $offer;
}
-test('recipe A applies an eight-day trial without coupon or promotion codes', function () {
- Workspace::factory()->create(['account_id' => $this->account->id]);
+function configureCheckout(Account $account): SubscriptionBuilder
+{
+ $subscription = $account->newSubscription(Account::SUBSCRIPTION_NAME, 'price_monthly_test');
- Carbon::setTestNow('2026-08-07 12:00:00');
+ ConfigureSubscriptionCheckout::apply($subscription, $account->currentOffer());
- $subscription = checkoutSubscription($this->account);
+ return $subscription;
+}
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
+test('without an offer the checkout charges the full price at once and takes a promotion code', function () {
+ $subscription = configureCheckout($this->account);
expect($subscription->couponId)->toBeNull()
- ->and($subscription->allowPromotionCodes)->toBeFalse()
- ->and(trialExpiresAt($subscription)?->toDateTimeString())->toBe('2026-08-15 12:00:00');
-});
-
-test('recipe B applies the socials first-month coupon and skips trial days', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => false,
- 'cashier.trial_days' => 8,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
- $subscription = checkoutSubscription($this->account);
-
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
-
- expect($subscription->couponId)->toBe('SOCIALS_18USD')
- ->and($subscription->allowPromotionCodes)->toBeFalse()
- ->and(trialExpiresAt($subscription))->toBeNull();
-});
-
-test('applies the workspaces first-month coupon for that plan', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.first_month_coupon_ids.workspaces' => 'WORKSPACES_88USD',
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
- $subscription = checkoutSubscription($this->account);
-
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, workspacesPlan());
-
- expect($subscription->couponId)->toBe('WORKSPACES_88USD')
- ->and(trialExpiresAt($subscription))->toBeNull();
+ ->and(trialExpiresAt($subscription))->toBeNull()
+ ->and($subscription->allowPromotionCodes)->toBeTrue();
});
-test('does not apply the other plan\'s first-month coupon', function () {
- config([
- 'cashier.first_month_coupon_ids.workspaces' => 'WORKSPACES_88USD',
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
- Carbon::setTestNow('2026-08-07 12:00:00');
-
- $subscription = checkoutSubscription($this->account);
-
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
+test('an offer that does not allow promotion codes hides the field', function () {
+ claimOfferFor($this->account, Offer::factory()->trial(8)->create());
- expect($subscription->couponId)->toBeNull()
- ->and(trialExpiresAt($subscription)?->toDateTimeString())->toBe('2026-08-15 12:00:00');
+ expect(configureCheckout($this->account)->allowPromotionCodes)->toBeFalse();
});
-test('does not apply a first-month coupon when no plan is given', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.first_month_coupon_ids.workspaces' => 'WORKSPACES_88USD',
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
- Carbon::setTestNow('2026-08-07 12:00:00');
-
- $subscription = checkoutSubscription($this->account);
+test('an offer that allows promotion codes shows the field', function () {
+ claimOfferFor($this->account, Offer::factory()->trial(8)->allowingPromotionCodes()->create());
- ConfigureSubscriptionCheckout::apply($subscription, $this->account);
-
- expect($subscription->couponId)->toBeNull()
- ->and(trialExpiresAt($subscription)?->toDateTimeString())->toBe('2026-08-15 12:00:00');
+ expect(configureCheckout($this->account)->allowPromotionCodes)->toBeTrue();
});
-test('recipe C applies trial days and allows promotion codes', function () {
- config(['cashier.allow_promotion_codes' => true]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
+test('a trial offer gives a first-time subscriber its trial', function () {
Carbon::setTestNow('2026-08-07 12:00:00');
+ claimOfferFor($this->account, Offer::factory()->trial(8)->firstSubscriptionOnly()->create());
- $subscription = checkoutSubscription($this->account);
-
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
+ $subscription = configureCheckout($this->account);
expect($subscription->couponId)->toBeNull()
- ->and($subscription->allowPromotionCodes)->toBeTrue()
->and(trialExpiresAt($subscription)?->toDateTimeString())->toBe('2026-08-15 12:00:00');
});
-test('recipe D charges immediately with promotion codes and no trial', function () {
- config([
- 'cashier.trial_days' => 0,
- 'cashier.allow_promotion_codes' => true,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
- $subscription = checkoutSubscription($this->account);
-
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
-
- expect(trialExpiresAt($subscription))->toBeNull()
- ->and($subscription->couponId)->toBeNull()
- ->and($subscription->allowPromotionCodes)->toBeTrue();
-});
-
-test('throws when a qualifying coupon would combine with allow promotion codes', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => true,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
- $subscription = checkoutSubscription($this->account);
-
- expect(fn () => ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan()))
- ->toThrow(RuntimeException::class, 'Cannot apply a first-month coupon while CASHIER_ALLOW_PROMOTION_CODES is enabled');
-
- expect($subscription->couponId)->toBeNull()
- ->and(trialExpiresAt($subscription))->toBeNull();
-});
-
-test('throws when coupon and promo are both set even if the account has several workspaces', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => true,
- ]);
- Workspace::factory()->count(2)->create(['account_id' => $this->account->id]);
-
- $subscription = checkoutSubscription($this->account);
-
- expect(fn () => ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan()))
- ->toThrow(RuntimeException::class, 'Cannot apply a first-month coupon while CASHIER_ALLOW_PROMOTION_CODES is enabled');
-});
-
-test('does not throw when coupon and promo are both set but a prior canceled subscription skips the coupon', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => true,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
+test('a former customer gets no first-subscription trial', function () {
+ claimOfferFor($this->account, Offer::factory()->trial(8)->firstSubscriptionOnly()->create());
givePriorSubscription($this->account);
- $subscription = checkoutSubscription($this->account);
-
- expect(fn () => ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan()))
- ->not->toThrow(RuntimeException::class);
-
- expect($subscription->couponId)->toBeNull()
- ->and($subscription->allowPromotionCodes)->toBeTrue()
- ->and(trialExpiresAt($subscription))->toBeNull();
+ expect(trialExpiresAt(configureCheckout($this->account)))->toBeNull();
});
-test('missing coupon with card required does not throw and still applies trial', function (?string $couponId) {
- config([
- 'cashier.first_month_coupon_ids.socials' => $couponId,
- 'cashier.allow_promotion_codes' => false,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
+test('a checkout that never became billable still counts as first-time', function (string $status) {
+ claimOfferFor($this->account, Offer::factory()->trial(8)->firstSubscriptionOnly()->create());
+ givePriorSubscription($this->account, $status);
- Carbon::setTestNow('2026-08-07 12:00:00');
+ expect(trialExpiresAt(configureCheckout($this->account)))->not->toBeNull();
+})->with(['incomplete', 'incomplete_expired']);
- $subscription = checkoutSubscription($this->account);
+test('a trial offer keeps the promotion code field, which Stripe accepts with a trial', function () {
+ claimOfferFor($this->account, Offer::factory()->trial(8)->allowingPromotionCodes()->create());
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
-
- expect($subscription->couponId)->toBeNull()
- ->and(trialExpiresAt($subscription)?->toDateTimeString())->toBe('2026-08-15 12:00:00');
-})->with([
- 'environment variable is unset' => null,
- 'environment variable is empty' => '',
-]);
-
-test('skips the coupon and allows promotion codes when a card is not required', function () {
- config([
- 'trypost.billing.require_card_for_trial' => false,
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => true,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
- $subscription = checkoutSubscription($this->account);
-
- expect(fn () => ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan()))
- ->not->toThrow(RuntimeException::class);
+ $subscription = configureCheckout($this->account);
expect($subscription->allowPromotionCodes)->toBeTrue()
- ->and($subscription->couponId)->toBeNull()
- ->and(trialExpiresAt($subscription))->toBeNull();
+ ->and(trialExpiresAt($subscription))->not->toBeNull();
});
-test('the first-month coupon applies to a first-time subscriber with several workspaces', function () {
- config(['cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD']);
- Workspace::factory()->count(2)->create(['account_id' => $this->account->id]);
+test('a coupon wins over the promotion code field, which Stripe rejects with it', function () {
+ claimOfferFor($this->account, Offer::factory()->allowingPromotionCodes()->create(['stripe_coupon_id' => 'BF26_50']));
- $subscription = checkoutSubscription($this->account);
+ $subscription = configureCheckout($this->account);
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
-
- expect($subscription->couponId)->toBe('SOCIALS_18USD')
- ->and(trialExpiresAt($subscription))->toBeNull();
-});
-
-test('skips coupon and trial when the account has a prior canceled subscription', function () {
- config(['cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD']);
- Workspace::factory()->create(['account_id' => $this->account->id]);
- givePriorSubscription($this->account);
-
- $subscription = checkoutSubscription($this->account);
-
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
-
- expect($subscription->couponId)->toBeNull()
- ->and(trialExpiresAt($subscription))->toBeNull()
- ->and($subscription->allowPromotionCodes)->toBeFalse();
-});
-
-test('still applies the coupon when the only prior subscription is incomplete_expired', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => false,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
- givePriorSubscription($this->account, 'incomplete_expired');
-
- $subscription = checkoutSubscription($this->account);
-
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
-
- expect($subscription->couponId)->toBe('SOCIALS_18USD')
+ expect($subscription->couponId)->toBe('BF26_50')
->and($subscription->allowPromotionCodes)->toBeFalse()
->and(trialExpiresAt($subscription))->toBeNull();
});
-test('still applies the coupon when the only prior subscription is incomplete', function () {
- config([
- 'cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD',
- 'cashier.allow_promotion_codes' => false,
- ]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
- givePriorSubscription($this->account, 'incomplete');
-
- $subscription = checkoutSubscription($this->account);
+test('an offer can carry a coupon and a trial together', function () {
+ claimOfferFor($this->account, Offer::factory()->create(['stripe_coupon_id' => 'BF26_50', 'trial_days' => 8]));
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
+ $subscription = configureCheckout($this->account);
- expect($subscription->couponId)->toBe('SOCIALS_18USD')
- ->and(trialExpiresAt($subscription))->toBeNull();
+ expect($subscription->couponId)->toBe('BF26_50')
+ ->and(trialExpiresAt($subscription))->not->toBeNull();
});
-test('clamps a one-day trial to Stripe Checkout minimum of two days', function () {
- config(['cashier.trial_days' => 1]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
-
+test('clamps a one-day trial to the Stripe Checkout minimum of two days', function () {
Carbon::setTestNow('2026-08-07 12:00:00');
+ claimOfferFor($this->account, Offer::factory()->trial(1)->create());
- $subscription = checkoutSubscription($this->account);
+ expect(trialExpiresAt(configureCheckout($this->account))?->toDateTimeString())->toBe('2026-08-09 12:00:00');
+});
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
+test('an offer applies to a former customer', function () {
+ givePriorSubscription($this->account);
+ claimOfferFor($this->account, Offer::factory()->create(['stripe_coupon_id' => 'BF26_50']));
- expect(trialExpiresAt($subscription)?->toDateTimeString())->toBe('2026-08-09 12:00:00');
+ expect(configureCheckout($this->account)->couponId)->toBe('BF26_50');
});
-test('skips trial days when trial_days is zero', function () {
- config(['cashier.trial_days' => 0]);
- Workspace::factory()->create(['account_id' => $this->account->id]);
+test('a first-subscription offer skips an account that was billed before', function () {
+ claimOfferFor($this->account, Offer::factory()->firstSubscriptionOnly()->create(['stripe_coupon_id' => 'FIRST_MONTH_1']));
- $subscription = checkoutSubscription($this->account);
+ expect(configureCheckout($this->account)->couponId)->toBe('FIRST_MONTH_1');
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
+ givePriorSubscription($this->account);
- expect(trialExpiresAt($subscription))->toBeNull()
- ->and($subscription->couponId)->toBeNull()
- ->and($subscription->allowPromotionCodes)->toBeFalse();
+ expect($this->account->currentOffer())->toBeNull();
});
-test('zero workspaces still get the first-month coupon when first-time', function () {
- config(['cashier.first_month_coupon_ids.socials' => 'SOCIALS_18USD']);
+test('does not apply an expired offer', function () {
+ claimOfferFor($this->account, Offer::factory()->expired()->create(['stripe_coupon_id' => 'BF26_50']));
- $subscription = checkoutSubscription($this->account);
+ expect(configureCheckout($this->account)->couponId)->toBeNull();
+});
- ConfigureSubscriptionCheckout::apply($subscription, $this->account, socialsPlan());
+test('an offer with zero trial days gives no trial', function () {
+ claimOfferFor($this->account, Offer::factory()->trial(0)->create());
- expect($subscription->couponId)->toBe('SOCIALS_18USD')
- ->and(trialExpiresAt($subscription))->toBeNull();
+ expect(trialExpiresAt(configureCheckout($this->account)))->toBeNull();
});
diff --git a/tests/fixtures/single-line-copy.php b/tests/fixtures/single-line-copy.php
index 4847b1e71..1690e833c 100644
--- a/tests/fixtures/single-line-copy.php
+++ b/tests/fixtures/single-line-copy.php
@@ -46,7 +46,24 @@ return [
'billing.plans.features.networks_all' => 39,
'billing.plans.features.repurpose' => 40,
'billing.plans.features.team' => 32,
- 'billing.plans.start_first_month' => 18,
+ 'welcome.plan_checkout_button' => 24,
+ 'billing.current_plan.subscribe' => 17,
+ 'offers.bf26.checkout_button' => 24,
+ 'offers.bf26.name' => 14,
+ 'offers.fm1.name' => 16,
+ 'offers.fm1.checkout_button' => 24,
+ 'offers.ft7d.checkout_button' => 22,
+ 'offers.ft7dnc.checkout_button' => 22,
+ 'billing.subscription.default' => 14,
+ 'billing.tabs.plan' => 5,
+ 'billing.tabs.invoices' => 10,
+ 'billing.current_plan.statuses.active' => 8,
+ 'billing.current_plan.statuses.trial' => 19,
+ 'billing.current_plan.statuses.cancelling' => 12,
+ 'billing.current_plan.statuses.past_due' => 13,
+ 'billing.invoices.columns.date' => 10,
+ 'billing.invoices.columns.amount' => 7,
+ 'billing.invoices.columns.status' => 9,
'calendar.title' => 10,
'channels.description' => 43,
'channels.goal_dialog.description' => 57,
@@ -194,7 +211,6 @@ return [
'welcome.mcp.connect_ai' => 20,
'welcome.mcp.connect_other' => 28,
'welcome.mcp.connect_with' => 16,
- 'welcome.plan_per_month' => 11,
'mcp.connect' => 13,
'mcp.copy' => 10,
'mcp.copied' => 11,