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 .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
release:
uses: saucebase-dev/saucebase/.github/workflows/semantic-release.yml@main
with:
version_file: 'module.json'
version_file: 'composer.json'
version_file_path: '.version'
prerelease: false
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
test:
uses: saucebase-dev/saucebase/.github/workflows/test-module.yml@main
with:
module: Billing
module: billing
dependencies: saucebase/auth
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ BILLING_LOG_CHANNEL=stack

```bash
php artisan test --testsuite=Modules --filter='^Modules\\Billing\\Tests' # PHPUnit
npx playwright test --project="@Billing*" # E2E
npx playwright test --project="@billing*" # E2E
```

## Debugging Billing Issues
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Saucebase
Copyright (c) 2026 Saucebase

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 8 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ tasks:

test:e2e:
desc: Run E2E tests for Billing module
cmd: npx playwright test --project="@Billing*" {{.CLI_ARGS}}
cmd: npx playwright test --project="@billing*" {{.CLI_ARGS}}
interactive: true

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

db:seed:
desc: Seed the Billing module database
cmd: php artisan modules:seed --module=billing

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

types:generate:
desc: Generate TypeScript types from PHP DTOs and enums
cmd: php artisan module:generate-types Billing
cmd: php artisan module:generate-types billing
17 changes: 0 additions & 17 deletions app/Providers/RouteServiceProvider.php

This file was deleted.

12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "saucebase/billing",
"description": "Payment gateway and subscription management module for Saucebase",
"type": "saucebase-module",
"version": "1.7.0",
"authors": [
{
"name": "Saucebase",
Expand All @@ -14,17 +15,22 @@
"stripe/stripe-php": "^19.2",
"spatie/laravel-typescript-transformer": "^2.5"
},
"license": "proprietary",
"minimum-stability": "stable",
Comment on lines +18 to +19
"extra": {
"laravel": {
"providers": [],
"providers": [
"Modules\\Billing\\Providers\\BillingServiceProvider"
],
"aliases": {}
}
},
"autoload": {
"psr-4": {
"Modules\\Billing\\": "app/",
"Modules\\Billing\\": "src/",
"Modules\\Billing\\Database\\Factories\\": "database/factories/",
"Modules\\Billing\\Database\\Seeders\\": "database/seeders/"
"Modules\\Billing\\Database\\Seeders\\": "database/seeders/",
"Modules\\Billing\\Tests\\Support\\": "tests/Support/"
}
},
"autoload-dev": {
Expand Down
13 changes: 13 additions & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Modules\Billing\Database\Seeders;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call(BillingDatabaseSeeder::class);
}
}
15 changes: 0 additions & 15 deletions module.json

This file was deleted.

25 changes: 1 addition & 24 deletions resources/js/app.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
import { registerIcon } from '@/lib/navigation';
import IconCreditCard from '~icons/lucide/credit-card';
import IconSparkles from '~icons/lucide/sparkles';

import '../css/style.css';

/**
* Billing module setup
* Called during app initialization before mounting
*/
export function setup() {
console.debug('Billing module loaded');

registerIcon('billing', IconCreditCard);
registerIcon('upgrade', IconSparkles);
}

/**
* Billing module after mount logic
* Called after the app has been mounted
*/
export function afterMount() {
console.debug('Billing module after mount logic executed');
}
export * from './vue/app';
24 changes: 24 additions & 0 deletions resources/js/vue/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { registerIcon } from '@/lib/navigation';
import IconCreditCard from '~icons/lucide/credit-card';
import IconSparkles from '~icons/lucide/sparkles';

import '@modules/billing/resources/css/style.css';

/**
* Billing module setup
* Called during app initialization before mounting
*/
export function setup() {
console.debug('Billing module loaded');

registerIcon('billing', IconCreditCard);
registerIcon('upgrade', IconSparkles);
}

/**
* Billing module after mount logic
* Called after the app has been mounted
*/
export function afterMount() {
console.debug('Billing module after mount logic executed');
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ function getToggleLabel(interval: string): string {
/>
</div>

<slot name="footer" />
<slot name="footer" />
</section>
</template>
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Support\Facades\Route;
use Modules\Billing\Http\Controllers\WebhookController;

// Webhook routes without CSRF protection
Route::post('/billing/webhooks/{provider}', WebhookController::class)
->name('billing.webhooks')
->withoutMiddleware([PreventRequestForgery::class]);
Route::middleware('api')->group(function (): void {
Route::post('/billing/webhooks/{provider}', WebhookController::class)
->name('billing.webhooks')
->withoutMiddleware([PreventRequestForgery::class]);
});
5 changes: 2 additions & 3 deletions routes/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Navigation::addWhen(
fn () => ! Auth::user()?->isSubscriber(),
'Upgrade',
route('billing.plans'),
fn () => route('billing.plans'),
function (Section $section) {
$section->attributes([
'group' => 'user',
Expand All @@ -45,8 +45,7 @@ function (Section $section) {
}
);

// Settings sidebar - Billing
Navigation::add('Billing', route('settings.billing'), function (Section $section) {
Navigation::add('Billing', fn () => route('settings.billing'), function (Section $section) {
$section->attributes([
'group' => 'settings',
'slug' => 'billing',
Expand Down
32 changes: 17 additions & 15 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@
use Modules\Billing\Http\Controllers\SubscriptionController;
use Modules\Billing\Http\Middleware\RedirectToRegister;

Route::get('/pricing', BillingPlansController::class)->name('billing.plans');
Route::middleware('web')->group(function (): void {
Route::get('/pricing', BillingPlansController::class)->name('billing.plans');

Route::post('/billing/checkout', [CheckoutController::class, 'create'])->middleware('throttle:10,1')->name('billing.checkout.create');
Route::post('/billing/checkout', [CheckoutController::class, 'create'])->middleware('throttle:10,1')->name('billing.checkout.create');

Route::middleware(RedirectToRegister::class)->group(function () {
Route::get('/billing/checkout/{checkout_session}', [CheckoutController::class, 'show'])
->name('billing.checkout')
->missing(fn () => auth()->guest() ? redirect()->route('register') : abort(404));
Route::post('/billing/checkout/{checkout_session}', [CheckoutController::class, 'store'])
->name('billing.checkout.store')
->missing(fn () => auth()->guest() ? redirect()->route('register') : abort(404));
});
Route::middleware(RedirectToRegister::class)->group(function (): void {
Route::get('/billing/checkout/{checkout_session}', [CheckoutController::class, 'show'])
->name('billing.checkout')
->missing(fn () => auth()->guest() ? redirect()->route('register') : abort(404));
Route::post('/billing/checkout/{checkout_session}', [CheckoutController::class, 'store'])
->name('billing.checkout.store')
->missing(fn () => auth()->guest() ? redirect()->route('register') : abort(404));
});

Route::middleware('auth')->group(function () {
Route::get('/billing/portal', BillingPortalController::class)->name('billing.portal');
Route::post('/billing/subscription/cancel', [SubscriptionController::class, 'cancel'])->name('billing.subscription.cancel');
Route::post('/billing/subscription/resume', [SubscriptionController::class, 'resume'])->name('billing.subscription.resume');
Route::middleware('auth')->group(function (): void {
Route::get('/billing/portal', BillingPortalController::class)->name('billing.portal');
Route::post('/billing/subscription/cancel', [SubscriptionController::class, 'cancel'])->name('billing.subscription.cancel');
Route::post('/billing/subscription/resume', [SubscriptionController::class, 'resume'])->name('billing.subscription.resume');

Route::get('/settings/billing', [SettingsBillingController::class, 'show'])->name('settings.billing');
Route::get('/settings/billing', [SettingsBillingController::class, 'show'])->name('settings.billing');
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function getId(): string
return 'billing';
}

public static function getNavigationGroupSort(): int
{
return 1;
}

public function boot(Panel $panel): void
{
$panel->navigationGroups([
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@

class BillingServiceProvider extends ModuleServiceProvider
{
protected string $name = 'Billing';

protected string $nameLower = 'billing';

protected array $providers = [
RouteServiceProvider::class,
];

protected array $commands = [
ExpireCheckoutSessionsCommand::class,
];
Expand All @@ -40,7 +32,7 @@ public function boot(): void
{
parent::boot();

$this->loadViewsFrom(module_path($this->name, 'resources/views'), $this->nameLower);
$this->loadViewsFrom(module_path('billing', 'resources/views'), 'billing');
}

/**
Expand All @@ -50,7 +42,7 @@ protected function registerConfig(): void
{
parent::registerConfig();

$this->mergeConfigFrom(module_path($this->name, 'config/services.php'), 'services');
$this->mergeConfigFrom(module_path('billing', 'config/services.php'), 'services');
}

protected function configureSchedules(Schedule $schedule): void
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions tests/Feature/DatabaseSeederTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Modules\Billing\Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Modules\Billing\Database\Seeders\DatabaseSeeder;
use Tests\TestCase;

class DatabaseSeederTest extends TestCase
{
use RefreshDatabase;

public function test_module_database_seeder_runs(): void
{
$this->seed(DatabaseSeeder::class);

$this->assertTrue(true);
}
Comment on lines +13 to +18
}
Loading