diff --git a/README.md b/README.md
index 2fc326c..28baccb 100644
--- a/README.md
+++ b/README.md
@@ -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`.
diff --git a/Taskfile.yml b/Taskfile.yml
index c0d9532..f34f43e 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -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 ────────────────────────────────────────────
diff --git a/composer.json b/composer.json
index 57261dd..b830dcd 100644
--- a/composer.json
+++ b/composer.json
@@ -10,7 +10,7 @@
}
],
"require": {
- "saucebase/core": "^2.12.0",
+ "saucebase/core": "^3.0",
"stripe/stripe-php": "^22.0"
},
"license": "MIT",
@@ -27,6 +27,9 @@
"vue",
"react"
]
+ },
+ "branch-alias": {
+ "dev-dev": "3.5.x-dev"
}
},
"autoload": {
diff --git a/database/seeders/DemoBillingDatabaseSeeder.php b/database/seeders/ShowcaseBillingDatabaseSeeder.php
similarity index 90%
rename from database/seeders/DemoBillingDatabaseSeeder.php
rename to database/seeders/ShowcaseBillingDatabaseSeeder.php
index 742f1ef..f96a56f 100644
--- a/database/seeders/DemoBillingDatabaseSeeder.php
+++ b/database/seeders/ShowcaseBillingDatabaseSeeder.php
@@ -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
{
@@ -29,9 +29,9 @@ public function run(): void
$staff->syncRoles('billing admin');
$this->call([
- DemoProductSeeder::class,
- DemoCustomerSeeder::class,
- DemoSubscriptionSeeder::class,
+ ShowcaseProductSeeder::class,
+ ShowcaseCustomerSeeder::class,
+ ShowcaseSubscriptionSeeder::class,
]);
$this->pushToProvider();
@@ -70,7 +70,7 @@ private function pushToProvider(): void
$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;
diff --git a/database/seeders/DemoCustomerSeeder.php b/database/seeders/ShowcaseCustomerSeeder.php
similarity index 97%
rename from database/seeders/DemoCustomerSeeder.php
rename to database/seeders/ShowcaseCustomerSeeder.php
index 5ebeb1d..ce9b690 100644
--- a/database/seeders/DemoCustomerSeeder.php
+++ b/database/seeders/ShowcaseCustomerSeeder.php
@@ -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,
diff --git a/database/seeders/DemoProductSeeder.php b/database/seeders/ShowcaseProductSeeder.php
similarity index 95%
rename from database/seeders/DemoProductSeeder.php
rename to database/seeders/ShowcaseProductSeeder.php
index 3440cdf..25a8a22 100644
--- a/database/seeders/DemoProductSeeder.php
+++ b/database/seeders/ShowcaseProductSeeder.php
@@ -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'];
@@ -35,6 +35,11 @@ class DemoProductSeeder extends Seeder
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()) {
+ continue;
+ }
+
$product = Product::updateOrCreate(
['slug' => $plan['slug']],
[
diff --git a/database/seeders/DemoSubscriptionSeeder.php b/database/seeders/ShowcaseSubscriptionSeeder.php
similarity index 97%
rename from database/seeders/DemoSubscriptionSeeder.php
rename to database/seeders/ShowcaseSubscriptionSeeder.php
index 4c2e83a..80c8e85 100644
--- a/database/seeders/DemoSubscriptionSeeder.php
+++ b/database/seeders/ShowcaseSubscriptionSeeder.php
@@ -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;
@@ -68,7 +68,7 @@ public function run(): void
/**
* 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
{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.',
)}
{!subscription && lifetimePlans.length
? t('Your plan and payments')
- : t('Manage your subscription, payment method, and invoices')}
+ : t(
+ 'Manage your subscription, payment method, and invoices',
+ )}
- {t('Pricing that ships with your app')}
+ {t('Choose your plan')}
{t('Paid once')} @@ -235,7 +241,7 @@ export default function SettingsBilling({
{plan.paid_at && ( - <> + {t('Bought on :date', { date: formatDate( plan.paid_at, @@ -244,7 +250,7 @@ export default function SettingsBilling({ ), })}{' '} ·{' '} - > + )} {t('Yours for good, no renewals.')}
@@ -254,11 +260,15 @@ export default function SettingsBilling({ {subscription ? ({subscription.interval @@ -275,7 +285,8 @@ export default function SettingsBilling({ data-testid="plan-name" className="text-foreground text-lg font-semibold" > - {subscription.plan_name ?? t('Unknown Plan')} + {subscription.plan_name ?? + t('Unknown Plan')}
{{ $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.', ) }}
diff --git a/resources/js/vue/pages/SettingsBilling.vue b/resources/js/vue/pages/SettingsBilling.vue index 8b2efe9..b261423 100644 --- a/resources/js/vue/pages/SettingsBilling.vue +++ b/resources/js/vue/pages/SettingsBilling.vue @@ -194,14 +194,14 @@ function resumeSubscription() {- + {{ $t('Bought on :date', { date: formatDate(plan.paid_at, language, longDate), }) }} · - + {{ $t('Yours for good, no renewals.') }}
@@ -214,6 +214,7 @@ function resumeSubscription() {
{{
@@ -592,7 +593,10 @@ function resumeSubscription() {
-
@@ -646,6 +650,11 @@ function resumeSubscription() {
>
{{ $t('Date') }}
+ {{ $t('Cancellation') }}
+ {{ $t('Item') }}
+
@@ -670,6 +679,9 @@ function resumeSubscription() {
formatDate(payment.paid_at, language, longDate)
}}