Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Run `npm run build` afterwards.
## Demo data

```bash
php artisan modules:seed --module=billing --demo
php artisan modules:seed --module=billing --state=showcase
```

Adds sample plans (pushed to Stripe when your keys are set), sample customers, and a staff account (`billing@saucebase.dev`) that only sees billing in the admin. All use the `DEMO_PASSWORD` from `.env`.
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ tasks:

# ── Database ──────────────────────────────────────────────────

db:seed:demo:
db:seed:showcase:
desc: Seed the Billing module with sample customers, subscriptions and payments
cmd: '{{.APP}} php artisan modules:seed --module=billing --demo'
cmd: '{{.APP}} php artisan modules:seed --module=billing --state=showcase'

# ── Code Generation ────────────────────────────────────────────

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"saucebase/core": "^2.12.0",
"saucebase/core": "^3.0",
"stripe/stripe-php": "^22.0"
},
"license": "MIT",
Expand All @@ -27,6 +27,9 @@
"vue",
"react"
]
},
"branch-alias": {
"dev-dev": "3.5.x-dev"
}
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
use Spatie\Permission\Models\Role;

/**
* Sample billing content for the demo site, run by `modules:seed --demo`.
* Sample billing content for the demo site, run by `modules:seed --state=showcase`.
*
* None of it is install data: a real app defines its own plans. The plans are
* created locally and pushed to the provider when its keys are present, which
* is what makes the demo site's checkout work.
*/
class DemoBillingDatabaseSeeder extends Seeder
class ShowcaseBillingDatabaseSeeder extends Seeder
{
public function run(): void
{
Expand All @@ -29,9 +29,9 @@
$staff->syncRoles('billing admin');

$this->call([
DemoProductSeeder::class,
DemoCustomerSeeder::class,
DemoSubscriptionSeeder::class,
ShowcaseProductSeeder::class,
ShowcaseCustomerSeeder::class,
ShowcaseSubscriptionSeeder::class,
]);

$this->pushToProvider();
Expand All @@ -58,7 +58,7 @@
// A test run must never reach the provider, and a developer's real keys
// are in the same `.env` the suite boots with.
if (app()->runningUnitTests() || ! $gateways->isConfigured($gateways->getDefaultDriver())) {
$this->command->outputComponents()->warn('Billing: no provider keys, demo plans stay local and cannot be bought.');

Check warning on line 61 in database/seeders/ShowcaseBillingDatabaseSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 127 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtr0ECbJLo-4cG6&open=AaHgkUtr0ECbJLo-4cG6&pullRequest=42

return;
}
Expand All @@ -70,17 +70,17 @@
$prices = 0;

try {
foreach (Product::whereIn('slug', DemoProductSeeder::SLUGS)->get() as $product) {
foreach (Product::whereIn('slug', ShowcaseProductSeeder::SLUGS)->get() as $product) {
$report = $push->run($product);
$products += $report->products;
$prices += $report->prices;
}
} catch (\Throwable $e) {
$this->command->outputComponents()->warn("Billing: push failed ({$e->getMessage()}); run billing:push-catalog when the provider is reachable.");

Check warning on line 79 in database/seeders/ShowcaseBillingDatabaseSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 156 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtr0ECbJLo-4cG7&open=AaHgkUtr0ECbJLo-4cG7&pullRequest=42

return;
}

$this->command->outputComponents()->info("Billing: pushed {$products} products and {$prices} prices to the provider.");

Check warning on line 84 in database/seeders/ShowcaseBillingDatabaseSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 127 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtr0ECbJLo-4cG8&open=AaHgkUtr0ECbJLo-4cG8&pullRequest=42
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*
* Signup dates run back over the last year on a rising curve, which is what gives
* the revenue and subscription charts a shape worth looking at. They are laid out
* here, in one place, because DemoSubscriptionSeeder bills from them.
* here, in one place, because ShowcaseSubscriptionSeeder bills from them.
*/
class DemoCustomerSeeder extends Seeder
class ShowcaseCustomerSeeder extends Seeder
{
/**
* How many customers signed up each month, oldest month first. Twelve entries,
Expand Down Expand Up @@ -59,7 +59,7 @@
}
}

private function createCustomer(int $index, string $name, CarbonInterface $signedUpAt, Generator $faker, string $password): void

Check warning on line 62 in database/seeders/ShowcaseCustomerSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 132 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtt0ECbJLo-4cG9&open=AaHgkUtt0ECbJLo-4cG9&pullRequest=42
{
$reference = str_pad((string) $index, 3, '0', STR_PAD_LEFT);
$email = "demo-customer-{$reference}@example.com";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*
* They carry no provider IDs: claiming an ID we do not own would make the push
* skip them and checkout fail against a price Stripe has never heard of.
* `DemoBillingDatabaseSeeder` pushes them once every seeder has run.
* `ShowcaseBillingDatabaseSeeder` pushes them once every seeder has run.
*
* A real app defines its own products, which is why these are demo content
* rather than install data.
*/
class DemoProductSeeder extends Seeder
class ShowcaseProductSeeder extends Seeder
{
/** The plans this seeder owns, and the only ones the demo may push. */
public const SLUGS = ['free', 'pro', 'team', 'lifetime', 'enterprise'];
Expand All @@ -35,6 +35,11 @@
public function run(): void
{
foreach ($this->plans() as $order => $plan) {
// An app has one free plan. One it already has (a template's own) stays.
if ($plan['kind'] === PlanKind::Free && Product::where('kind', PlanKind::Free)->where('slug', '!=', $plan['slug'])->exists()) {

Check warning on line 39 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 139 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cG-&open=AaHgkUtu0ECbJLo-4cG-&pullRequest=42
continue;
}

$product = Product::updateOrCreate(
['slug' => $plan['slug']],
[
Expand Down Expand Up @@ -73,7 +78,7 @@
}

/**
* @return list<array{slug: string, name: string, kind: PlanKind, trial_days?: int, entitlements: array<string, mixed>, trial_entitlements?: array<string, mixed>, replaces?: string, description: string, features: list<string>, metadata: array<string, string>, prices: list<array{interval: ?string, amount: int, metadata?: array<string, string>}>}>

Check warning on line 81 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 351 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cG_&open=AaHgkUtu0ECbJLo-4cG_&pullRequest=42
*/
private function plans(): array
{
Expand Down Expand Up @@ -101,16 +106,16 @@
'kind' => PlanKind::Subscription,
'trial_days' => 14,
'entitlements' => self::PRO_ENTITLEMENTS,
'trial_entitlements' => ['features' => ['custom_domains' => false], 'limits' => ['api_requests' => 10000]],

Check warning on line 109 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 123 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cHA&open=AaHgkUtu0ECbJLo-4cHA&pullRequest=42
'description' => 'No limits on projects, and the tools to run them in production.',
'features' => ['Unlimited projects', '1M API requests / month', 'Custom domains', 'Webhooks', 'Priority email support'],

Check warning on line 111 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 136 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cHB&open=AaHgkUtu0ECbJLo-4cHB&pullRequest=42
'metadata' => [
'tagline' => 'For solo developers',
'after_cta' => 'Cancel anytime',
],
'prices' => [
['interval' => 'month', 'amount' => 2900],
['interval' => 'year', 'amount' => 29000, 'metadata' => ['badge' => 'Save 17%', 'original_price' => '34800']],

Check warning on line 118 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 130 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cHC&open=AaHgkUtu0ECbJLo-4cHC&pullRequest=42
],
],
[
Expand All @@ -118,18 +123,18 @@
'name' => 'Team',
'kind' => PlanKind::Subscription,
'entitlements' => [
'features' => [...self::PRO_ENTITLEMENTS['features'], 'roles' => true, 'audit_logs' => true, 'sso' => true],

Check warning on line 126 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 128 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cHD&open=AaHgkUtu0ECbJLo-4cHD&pullRequest=42
'limits' => [...self::PRO_ENTITLEMENTS['limits'], 'members' => 25],
],
'description' => 'Work together on every project, up to 25 members.',
'features' => ['Everything in Pro', 'Up to 25 members', 'Roles & permissions', 'Audit logs', 'SSO (SAML)'],

Check warning on line 130 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 123 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cHE&open=AaHgkUtu0ECbJLo-4cHE&pullRequest=42
'metadata' => [
'tagline' => 'For growing teams',
'after_cta' => 'Cancel anytime',
],
'prices' => [
['interval' => 'month', 'amount' => 7900],
['interval' => 'year', 'amount' => 79000, 'metadata' => ['badge' => 'Save 17%', 'original_price' => '94800']],

Check warning on line 137 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 130 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cHF&open=AaHgkUtu0ECbJLo-4cHF&pullRequest=42
],
],
[
Expand All @@ -154,7 +159,7 @@
'name' => 'Enterprise',
'kind' => PlanKind::Subscription,
'entitlements' => [
'features' => ['custom_domains' => true, 'webhooks' => true, 'roles' => true, 'audit_logs' => true, 'sso' => true],

Check warning on line 162 in database/seeders/ShowcaseProductSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 135 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtu0ECbJLo-4cHG&open=AaHgkUtu0ECbJLo-4cHG&pullRequest=42
'limits' => ['projects' => null, 'api_requests' => null, 'members' => null],
],
'description' => 'Custom limits, contracts and support for large organisations.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
* enough abandoned checkouts to keep the conversion rate short of a suspicious
* 100%.
*
* Runs after DemoCustomerSeeder and DemoProductSeeder, and does nothing without
* Runs after ShowcaseCustomerSeeder and ShowcaseProductSeeder, and does nothing without
* them.
*/
class DemoSubscriptionSeeder extends Seeder
class ShowcaseSubscriptionSeeder extends Seeder
{
/** Every seventeenth of those behind on payment ran out of time entirely. */
private const SUSPENDED_EVERY = 17;
Expand Down Expand Up @@ -68,7 +68,7 @@

/**
* The paid plans, cheapest first. Looked up by plan and interval rather than by
* Stripe price ID, so the demo account's IDs live only in DemoProductSeeder.
* Stripe price ID, so the demo account's IDs live only in ShowcaseProductSeeder.
*
* @return list<Price>
*/
Expand All @@ -89,7 +89,7 @@
->all();
}

private function seedAbandonedCheckouts(int $index, Customer $customer, Price $price, CarbonInterface $startedAt): void

Check warning on line 92 in database/seeders/ShowcaseSubscriptionSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 123 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtq0ECbJLo-4cG0&open=AaHgkUtq0ECbJLo-4cG0&pullRequest=42
{
if ($index % self::ABANDONS_EVERY !== 0) {
return;
Expand All @@ -112,7 +112,7 @@
);
}

private function completedCheckout(int $index, Customer $customer, Price $price, CarbonInterface $startedAt): CheckoutSession

Check warning on line 115 in database/seeders/ShowcaseSubscriptionSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 129 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtq0ECbJLo-4cG1&open=AaHgkUtq0ECbJLo-4cG1&pullRequest=42
{
return CheckoutSession::updateOrCreate(
['provider' => 'stripe', 'provider_session_id' => "cs_demo_won_{$index}"],
Expand All @@ -127,7 +127,7 @@
);
}

private function subscription(int $index, Customer $customer, Price $price, CarbonInterface $startedAt): Subscription

Check warning on line 130 in database/seeders/ShowcaseSubscriptionSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 121 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtq0ECbJLo-4cG2&open=AaHgkUtq0ECbJLo-4cG2&pullRequest=42
{
$cancelled = $index % self::CANCELS_EVERY === 0 && $index > 0;
$behind = ! $cancelled && $index % self::FALLS_BEHIND_EVERY === 0 && $index > 0;
Expand Down Expand Up @@ -168,18 +168,18 @@
* One payment and invoice per billing period between signup and today. A
* cancelled subscription stops billing; a past-due one fails its last charge.
*/
private function billingHistory(int $index, Customer $customer, Subscription $subscription, Price $price, CarbonInterface $startedAt): void

Check warning on line 171 in database/seeders/ShowcaseSubscriptionSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 143 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtq0ECbJLo-4cG3&open=AaHgkUtq0ECbJLo-4cG3&pullRequest=42
{
$chargedAt = $startedAt->copy();
$period = 0;

while ($chargedAt->lessThanOrEqualTo(now())) {
if ($subscription->status === SubscriptionStatus::Cancelled && $chargedAt->greaterThan($subscription->cancelled_at)) {

Check warning on line 177 in database/seeders/ShowcaseSubscriptionSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 130 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtq0ECbJLo-4cG4&open=AaHgkUtq0ECbJLo-4cG4&pullRequest=42
break;
}

$isLast = $this->nextPeriod($price, $chargedAt)->greaterThan(now());
$failed = $isLast && in_array($subscription->status, [SubscriptionStatus::PastDue, SubscriptionStatus::Suspended], true);

Check warning on line 182 in database/seeders/ShowcaseSubscriptionSeeder.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 133 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaHgkUtq0ECbJLo-4cG5&open=AaHgkUtq0ECbJLo-4cG5&pullRequest=42

$payment = Payment::updateOrCreate(
['provider' => 'stripe', 'provider_payment_id' => "pi_demo_{$index}_{$period}"],
Expand Down
18 changes: 9 additions & 9 deletions resources/boost/skills/saucebase-billing-development/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ A new account takes the buyer's name and email; after that its details change on

`PurchaseEligibility::assertCanBuy()` throws the refusal's message; `CheckoutController::create()` calls it before a session exists and `StartCheckout` again for the guest who signed in part-way (the session-reuse return runs first, so a checkout already paid at the provider still completes). It runs before payment, so two checkouts opened at once can both be paid; Stripe's *Limit customers to one subscription* closes that, listed in the README as optional.

**Pricing buttons come from the server.** `PlanActions::for()` sends `priceActions` (per displayed price) and `productActions` (per plan shown without a price). `buy` appears only where eligibility allows; the rest label a refusal — `change`, `later`, `included`, `current`, `unavailable` — plus `contact` for a `cta_url` and, for the Free plan, `signup` (guest), `current` (nothing paid) or `included` (paid plan). The cards only render what they are sent.
**Pricing buttons come from the server.** `PlanActions::for()` sends `priceActions` (per displayed price) and `productActions` (per plan shown without a price). `buy` appears only where eligibility allows (`buy_again` for a one-off the owner already paid for, refunds aside: another call, renewed package updates); the rest label a refusal — `change`, `later`, `included`, `current`, `unavailable` — plus `contact` for a `cta_url` and, for the Free plan, `signup` (guest), `current` (nothing paid) or `included` (paid plan). The cards only render what they are sent.

**Lifetime replacing a subscription.** After a Lifetime checkout commits, `endSubscriptionReplacedByLifetime()` cancels the current subscription at period end — only if its plan is the one the Lifetime replaces. It runs on every delivery, since a failed provider call is retried and the retry finds the session already completed. Until the provider accepts the cancellation the subscription shows as renewing; once `cancelled_at` is set the panel says it ends, replaced by lifetime. The app freezes it: `billing.plan.change` 404s and resume is refused (`PurchaseEligibility::isReplacedByLifetime()`). That is app policy — the provider stays the source of truth, and a customer who resumes it in the provider's portal keeps an ordinary subscription.

Expand Down Expand Up @@ -181,21 +181,21 @@ Everything else the merchant decides — provider, currency, checkout redirect,

The install seeder, `DatabaseSeeder`, only creates the `manage billing` permission (granted to nobody), which every billing admin page and resource checks in `canAccess()` (Customers, Products, Subscriptions, the Billing dashboard and Billing settings) and every billing widget in `canView()`, since the stats widget also sits on the main dashboard. `access admin panel` alone only opens the panel; `admin` passes every check. Plans are not seeded: a real install defines its own in the admin panel.

Everything else the module seeds is demo content, run by `modules:seed --demo` through `DemoBillingDatabaseSeeder`, which calls one `Demo*Seeder` per kind of content, in dependency order:
Everything else the module seeds is demo content, run by `modules:seed --state=showcase` through `ShowcaseBillingDatabaseSeeder`, which calls one `Showcase*Seeder` per kind of content, in dependency order:

| Seeder | What it makes |
| --- | --- |
| `DemoProductSeeder` | Five plans for a made-up developer tool, each with a kind and entitlements — Free, Pro (highlighted), Team, Lifetime (replaces Pro) and Enterprise (no price, `cta_url` to sales) — chosen so the pricing page shows every option it reads. No provider IDs. A real install defines its own. |
| `DemoCustomerSeeder` | 48 users, customers and cards, signing up on a rising curve over the last twelve months. |
| `DemoSubscriptionSeeder` | A subscription per customer, one payment and invoice per billing period since signup, plus abandoned checkouts. |
| `ShowcaseProductSeeder` | Five plans for a made-up developer tool, each with a kind and entitlements — Free, Pro (highlighted), Team, Lifetime (replaces Pro) and Enterprise (no price, `cta_url` to sales) — chosen so the pricing page shows every option it reads. No provider IDs. A real install defines its own. |
| `ShowcaseCustomerSeeder` | 48 users, customers and cards, signing up on a rising curve over the last twelve months. |
| `ShowcaseSubscriptionSeeder` | A subscription per customer, one payment and invoice per billing period since signup, plus abandoned checkouts. |

Keep the `Demo` prefix on each: it is what marks the data as the demo site's rather than an install's.
Keep the `Showcase` prefix on each: it marks the data as the showcase state's rather than an install's.

`DemoBillingDatabaseSeeder` runs `CatalogPush` after the three, and it is the only step that leaves the database. The seeded plans have no provider IDs, and a plan the provider does not know is not `purchasable()` — so without this every paid plan on the demo's pricing page says *Not available*. It is skipped under `runningUnitTests()` (the suite boots with the developer's own `.env`) and when the provider has no keys, and a provider that is unreachable warns rather than failing the seed. Put it here rather than inside `DemoProductSeeder`: the runner draws a task line around each seeder and swallows its output.
`ShowcaseBillingDatabaseSeeder` runs `CatalogPush` after the three, and it is the only step that leaves the database. The seeded plans have no provider IDs, and a plan the provider does not know is not `purchasable()` — so without this every paid plan on the demo's pricing page says *Not available*. It is skipped under `runningUnitTests()` (the suite boots with the developer's own `.env`) and when the provider has no keys, and a provider that is unreachable warns rather than failing the seed. Put it here rather than inside `ShowcaseProductSeeder`: the runner draws a task line around each seeder and swallows its output.

Two properties hold the demo data together, and a new seeder should keep both. It is **deterministic** — the customer names come from a fixed faker seed, and everything else from the customer's index — and it is **idempotent**, keyed on slugs, users and `*_demo_*` IDs, so reseeding updates rather than duplicates. Customers carry no provider ID: checkout creates a real one the first time a demo account buys. `DemoSeederTest` covers the second.
Two properties hold the demo data together, and a new seeder should keep both. It is **deterministic** — the customer names come from a fixed faker seed, and everything else from the customer's index — and it is **idempotent**, keyed on slugs, users and `*_demo_*` IDs, so reseeding updates rather than duplicates. Customers carry no provider ID: checkout creates a real one the first time a demo account buys. `ShowcaseSeederTest` covers the second.

Signup dates drive the whole dashboard: `DemoCustomerSeeder::SIGNUPS_PER_MONTH` is the growth curve the revenue and subscription charts draw, and `DemoSubscriptionSeeder` bills forward from each signup date to today.
Signup dates drive the whole dashboard: `ShowcaseCustomerSeeder::SIGNUPS_PER_MONTH` is the growth curve the revenue and subscription charts draw, and `ShowcaseSubscriptionSeeder` bills forward from each signup date to today.

Nothing in the test suites depends on the demo plans. `BillingTestHelper::createSubscriberFixtures()` creates the "Pro" product and its price itself, which is what the e2e specs assert against.

Expand Down
14 changes: 9 additions & 5 deletions resources/js/react/components/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default function ProductCard({
? 'bg-primary hover:bg-primary/90 focus-visible:outline-primary text-white'
: 'text-foreground ring-border hover:bg-foreground/10 ring-1 ring-inset';

const startsCheckout = action === 'buy' || action === 'trial';
const startsCheckout =
action === 'buy' || action === 'buy_again' || action === 'trial';
const enabled =
startsCheckout || action === 'signup' || action === 'owner_only';

Expand All @@ -72,10 +73,12 @@ export default function ProductCard({
}

if (startsCheckout && price) {
const auth = page.props.auth as {
user?: unknown;
modal_enabled?: boolean;
} | undefined;
const auth = page.props.auth as
| {
user?: unknown;
modal_enabled?: boolean;
}
| undefined;

if (!auth?.user && auth?.modal_enabled) {
setIsStartingCheckout(true);
Expand Down Expand Up @@ -110,6 +113,7 @@ export default function ProductCard({
later: t('Available when your current plan ends'),
unavailable: t('Not available'),
owner_only: t('Ask an owner'),
buy_again: t('Buy again'),
trial: t('Start :days-day free trial', {
days: String(product.trial_days ?? 0),
}),
Expand Down
4 changes: 2 additions & 2 deletions resources/js/react/pages/Plans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default function Plans({
>
<div className="mx-auto max-w-4xl text-center">
<h2 className="text-foreground mt-2 text-4xl font-semibold tracking-tight sm:text-5xl">
{t('Pricing that ships with your app')}
{t('Choose your plan')}
</h2>
<p className="text-foreground/70 mx-auto mt-6 max-w-2xl text-lg">
{t(
"Every plan here runs on the Billing module against Stripe's sandbox. Try the checkout: you won't be charged.",
'Start free and upgrade when you need more. Cancel anytime.',
)}
</p>
</div>
Expand Down
Loading
Loading