feat!: update module to be compatible with saucebase 2.0 - #23
Merged
Conversation
- Implemented SubscriptionCancelledNotification, SubscriptionCreatedNotification, SubscriptionResumedNotification, and SubscriptionUpdatedNotification for handling subscription-related email notifications. - Created SubscriptionPolicy to manage subscription update permissions. - Developed BillingServiceProvider to register billing services and commands. - Introduced BillingService to handle checkout processing, webhooks, and subscription management. - Added StripeGateway for Stripe payment processing, including customer creation and checkout session management. - Implemented PaymentGatewayManager to manage payment gateway drivers. - Created Billable trait for associating users with billing customers. - Added a test for the DatabaseSeeder to ensure it runs correctly.
Implement billing notifications, services, and database seeding
feat!: Refactor billing module and add checkout and plans components
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes the Billing module for Saucebase 2.0 by migrating module metadata/versioning to composer.json, adopting a src/-based structure, and expanding the module’s billing capabilities (Stripe gateway integration, checkout/subscription flows, and Filament admin UI).
Changes:
- Migrates module metadata/versioning from
module.jsontocomposer.json, updates autoloading tosrc/, and adjusts workflows/docs to the new module naming/version source. - Introduces a Stripe-backed billing domain (models, services, webhooks, events/listeners, notifications) plus checkout and settings UI pages.
- Adds database seeding support and module tasks, and removes the module
RouteServiceProviderin favor of direct route grouping.
Reviewed changes
Copilot reviewed 17 out of 108 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Feature/DatabaseSeederTest.php | Adds a feature test for module seeding. |
| Taskfile.yml | Normalizes module name casing; adds db:seed task. |
| src/Traits/Billable.php | Adds a Billable trait to relate a user to a billing customer. |
| src/Services/PaymentGatewayManager.php | Adds gateway manager for resolving payment drivers (Stripe). |
| src/Services/Gateways/StripeGateway.php | Implements Stripe gateway operations (customers, sessions, webhooks, subscriptions). |
| src/Services/BillingService.php | Core billing orchestration (checkout, webhooks, fulfillment, payments/subscriptions). |
| src/Providers/BillingServiceProvider.php | Updates module provider wiring and config/view loading. |
| src/Policies/SubscriptionPolicy.php | Adds authorization policy for subscription updates. |
| src/Notifications/SubscriptionUpdatedNotification.php | Adds email notification for cancellation pending / past-due states. |
| src/Notifications/SubscriptionResumedNotification.php | Adds email notification for resumed subscriptions. |
| src/Notifications/SubscriptionCreatedNotification.php | Adds welcome email for newly created subscriptions. |
| src/Notifications/SubscriptionCancelledNotification.php | Adds email notification for cancelled subscriptions. |
| src/Notifications/PaymentSucceededNotification.php | Adds payment success email (optionally links invoice). |
| src/Notifications/PaymentFailedNotification.php | Adds payment failure email. |
| src/Models/WebhookEvent.php | Adds model for webhook idempotency/auditing. |
| src/Models/Subscription.php | Adds subscription model + relations + casts. |
| src/Models/Product.php | Adds product catalog model with scopes and slugs. |
| src/Models/Price.php | Adds price model with currency/billing scheme support. |
| src/Models/PaymentProvider.php | Adds payment provider model. |
| src/Models/PaymentMethod.php | Adds payment method model and casts. |
| src/Models/Payment.php | Adds payment model and relations. |
| src/Models/Invoice.php | Adds invoice model and relations. |
| src/Models/Customer.php | Adds customer model and relations. |
| src/Models/CheckoutSession.php | Adds checkout session model (UUID route key, expiry, status). |
| src/Listeners/SyncSubscriberRole.php | Syncs subscriber role based on subscription state. |
| src/Listeners/SendSubscriptionUpdatedNotification.php | Sends “updated” notification for cancellation pending / past due. |
| src/Listeners/SendSubscriptionResumedNotification.php | Sends “resumed” notification. |
| src/Listeners/SendSubscriptionCreatedNotification.php | Sends “created” notification. |
| src/Listeners/SendSubscriptionCancelledNotification.php | Sends “cancelled” notification. |
| src/Listeners/SendPaymentSucceededNotification.php | Sends payment succeeded notification. |
| src/Listeners/SendPaymentFailedNotification.php | Sends payment failed notification. |
| src/Http/Requests/SubscribeRequest.php | Adds a request validator for subscription-related input. |
| src/Http/Middleware/RedirectToRegister.php | Adds middleware to preserve intended URL and redirect guests to register. |
| src/Http/Controllers/WebhookController.php | Adds webhook endpoint controller with error handling. |
| src/Http/Controllers/SubscriptionController.php | Adds cancel/resume subscription endpoints. |
| src/Http/Controllers/SettingsBillingController.php | Adds billing settings page controller (Inertia). |
| src/Http/Controllers/CheckoutController.php | Adds checkout session create/show/store flow. |
| src/Http/Controllers/BillingPortalController.php | Adds redirect to provider billing portal. |
| src/Http/Controllers/BillingPlansController.php | Adds public plans page controller. |
| src/Filament/Widgets/SubscriptionsChartWidget.php | Adds subscriptions chart widget. |
| src/Filament/Widgets/RevenueChartWidget.php | Adds revenue chart widget. |
| src/Filament/Widgets/ConversionChartWidget.php | Adds checkout conversion chart widget. |
| src/Filament/Widgets/BillingSaasStatsWidget.php | Adds SaaS stats overview widget (MRR, revenue, conversion). |
| src/Filament/Resources/Subscriptions/Tables/SubscriptionsTable.php | Adds Filament table configuration for subscriptions. |
| src/Filament/Resources/Subscriptions/SubscriptionResource.php | Adds Filament subscription resource definition. |
| src/Filament/Resources/Subscriptions/Schemas/SubscriptionInfolist.php | Adds Filament subscription infolist schema. |
| src/Filament/Resources/Subscriptions/Pages/ViewSubscription.php | Adds Filament “view subscription” page. |
| src/Filament/Resources/Subscriptions/Pages/ListSubscriptions.php | Adds Filament “list subscriptions” page. |
| src/Filament/Resources/Products/Tables/ProductsTable.php | Adds Filament table configuration for products. |
| src/Filament/Resources/Products/Schemas/ProductInfolist.php | Adds Filament product infolist schema. |
| src/Filament/Resources/Products/Schemas/ProductForm.php | Adds Filament product form schema. |
| src/Filament/Resources/Products/ProductResource.php | Adds Filament product resource definition. |
| src/Filament/Resources/Products/Pages/ViewProduct.php | Adds Filament “view product” page. |
| src/Filament/Resources/Products/Pages/ListProducts.php | Adds Filament “list products” page. |
| src/Filament/Resources/Products/Pages/EditProduct.php | Adds Filament “edit product” page. |
| src/Filament/Resources/Products/Pages/CreateProduct.php | Adds Filament “create product” page. |
| src/Filament/Resources/Customers/Tables/CustomersTable.php | Adds Filament table configuration for customers. |
| src/Filament/Resources/Customers/Schemas/CustomerInfolist.php | Adds Filament customer infolist schema. |
| src/Filament/Resources/Customers/Pages/ViewCustomer.php | Adds Filament “view customer” page. |
| src/Filament/Resources/Customers/Pages/ListCustomers.php | Adds Filament “list customers” page. |
| src/Filament/Resources/Customers/CustomerResource.php | Adds Filament customer resource definition. |
| src/Filament/Pages/BillingDashboard.php | Adds Filament billing dashboard page with date filtering. |
| src/Filament/BillingPlugin.php | Adds navigation group sorting for the plugin. |
| src/Events/SubscriptionUpdated.php | Adds subscription updated event. |
| src/Events/SubscriptionResumed.php | Adds subscription resumed event. |
| src/Events/SubscriptionCreated.php | Adds subscription created event. |
| src/Events/SubscriptionCancelled.php | Adds subscription cancelled event. |
| src/Events/PaymentSucceeded.php | Adds payment succeeded event. |
| src/Events/PaymentFailed.php | Adds payment failed event. |
| src/Events/InvoicePaid.php | Adds invoice paid event. |
| src/Events/CheckoutCompleted.php | Adds checkout completed event. |
| src/Enums/WebhookEventType.php | Adds normalized webhook event enum. |
| src/Enums/SubscriptionStatus.php | Adds subscription status enum with Filament display helpers. |
| src/Enums/PaymentStatus.php | Adds payment status enum with Filament display helpers. |
| src/Enums/PaymentMethodType.php | Adds payment method type enum + category mapping. |
| src/Enums/InvoiceStatus.php | Adds invoice status enum with Filament display helpers. |
| src/Enums/Currency.php | Adds currency enum with formatting and default-from-config. |
| src/Enums/CheckoutSessionStatus.php | Adds checkout session status enum. |
| src/Enums/BillingScheme.php | Adds billing scheme enum. |
| src/Data/WebhookData.php | Adds webhook DTO. |
| src/Data/PaymentMethodDetails.php | Adds payment method details DTO (TypeScript-transformable). |
| src/Data/PaymentMethodData.php | Adds payment method DTO (TypeScript-transformable). |
| src/Data/CustomerData.php | Adds customer DTO. |
| src/Data/CheckoutResultData.php | Adds checkout result DTO. |
| src/Data/CheckoutData.php | Adds checkout DTO. |
| src/Data/AddressData.php | Adds address DTO. |
| src/Contracts/PaymentGatewayInterface.php | Adds a gateway contract for billing providers. |
| src/Console/ExpireCheckoutSessionsCommand.php | Adds command to expire/abandon checkout sessions. |
| routes/web.php | Adjusts web routes grouping and checkout/settings endpoints. |
| routes/navigation.php | Updates navigation route generation to closure-based routes. |
| routes/api.php | Defines webhook API route and groups under api middleware. |
| resources/js/vue/utils/intervals.ts | Adds interval display/normalization helpers for UI. |
| resources/js/vue/pages/SettingsBilling.vue | Adds billing settings UI page (subscription, payment method, invoices). |
| resources/js/vue/pages/Plans.vue | Adds plans/pricing page UI. |
| resources/js/vue/pages/Checkout.vue | Adds checkout UI page. |
| resources/js/vue/layouts/CheckoutLayout.vue | Adds checkout page layout. |
| resources/js/vue/components/ProductSection.vue | Minor template slot formatting adjustment. |
| resources/js/vue/components/ProductCard.vue | Adds pricing card UI component. |
| resources/js/vue/app.ts | Moves billing module JS setup/after-mount logic into Vue subtree. |
| resources/js/app.ts | Re-exports from new Vue module entrypoint. |
| module.json | Removes legacy module metadata file. |
| LICENSE | Updates copyright year. |
| database/seeders/DatabaseSeeder.php | Adds module DatabaseSeeder entrypoint. |
| composer.json | Adds explicit version, updates autoload path to src/, and registers provider. |
| CLAUDE.md | Updates e2e command to match lowercase module name. |
| app/Providers/RouteServiceProvider.php | Removes module RouteServiceProvider. |
| .github/workflows/test.yml | Updates module input to lowercase billing. |
| .github/workflows/release.yml | Updates release workflow to read version from composer.json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+19
| "license": "proprietary", | ||
| "minimum-stability": "stable", |
Comment on lines
+13
to
+18
| public function test_module_database_seeder_runs(): void | ||
| { | ||
| $this->seed(DatabaseSeeder::class); | ||
|
|
||
| $this->assertTrue(true); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request includes several important changes to improve consistency, modernize structure, and streamline the Billing module. The most significant updates are the migration from
module.jsontocomposer.jsonfor versioning and metadata, restructuring of the codebase to use asrc/directory, and various naming and automation adjustments for improved developer experience.Module structure and configuration:
module.json(now deleted) tocomposer.json, including adding aversionfield and updating autoload paths to use thesrc/directory. Also registered theBillingServiceProviderin thecomposer.jsonextrasection. [1] [2] [3]composer.jsonfor versioning instead ofmodule.json.app/tosrc/incomposer.jsonfor better alignment with modern Laravel package conventions.Testing and automation:
billinginstead ofBillingacross workflow files, documentation, and theTaskfile.yml. [1] [2] [3]db:seedtask toTaskfile.ymland introduced aDatabaseSeederclass indatabase/seedersto support database seeding for the Billing module. [1] [2]Codebase cleanup and improvements:
RouteServiceProviderin favor of grouping routes directly inroutes/api.php. [1] [2]resources/js/app.tswith a re-export, and moved Billing module setup and icon registration toresources/js/vue/app.tsfor better organization. [1] [2]Other updates:
LICENSEfile.proprietaryand minimum stability tostableincomposer.json.