How smartguycodes/smart-billing works
Smart Billing is a Laravel billing package for plan subscriptions and payments, centered on M-Pesa. Its main flow is a billable customer initiating a charge or subscription through the API or Billable trait; payment services dispatch to a driver, persist transaction state, and process gateway callbacks. Separate admin, invoice, renewal, reminder, and dunning capabilities are also represented. Source excerpts establish the payment and subscription call paths; other subsystem links are included only where README or indexed references support them.
Main entry points: PaymentService.php Payment service · BillingSubscription.php Subscriptions · SubscriptionService.php Subscription service · api.php REST routes
Components 30
Billing entry points
- REST routes
routes/api.php - Webhook handler
src/Http/Controllers/Api/WebhookController.php - Billable trait
src/Concerns/Billable.php - Subscription API
src/Http/Controllers/Api/SubscriptionController.php - Plan API
src/Http/Controllers/Api/PlanController.php - Payment API
src/Http/Controllers/Api/PaymentController.php
Billing domain
- Subscription service
src/Services/SubscriptionService.php - Billing plans
src/Models/BillingPlan.php - Subscriptions
src/Models/BillingSubscription.php - Invoices
src/Models/BillingInvoice.php - Transactions
src/Models/BillingTransaction.php - Payment service
src/Services/PaymentService.php - Reference generator
src/Support/ReferenceGenerator.php - Payment result
src/Support/PaymentResult.php
Payment gateway
- Driver manager
src/Services/BillingManager.php - Driver contract
src/Contracts/PaymentDriver.php - M-Pesa driver
src/Drivers/MpesaDriver.php
Billing operations
- Renewal command
src/Console/Commands/ProcessRenewalsCommand.php - Dunning service
src/Services/DunningService.php - Reminder command
src/Console/Commands/SendRemindersCommand.php - Renewal notification
src/Notifications/RenewalReminderNotification.php
Admin experience
- Admin routes
routes/web.php - Transaction admin
src/Http/Controllers/Admin/TransactionController.php - Plan admin
src/Http/Controllers/Admin/PlanController.php - Subscription admin
src/Http/Controllers/Admin/SubscriptionController.php - Invoice admin
src/Http/Controllers/Admin/InvoiceController.php - Admin dashboard
src/Http/Controllers/Admin/DashboardController.php - Admin views
resources/views/admin
Other components
- Billable customer
- Daraja gateway
Connections 42
- Billable customer → REST routes: calls API
README.md - REST routes → Payment API: routes payment
routes/api.php - REST routes → Subscription API: routes subscription
routes/api.php - REST routes → Plan API: routes plans
routes/api.php - REST routes → Webhook handler: routes callbacks
routes/api.php - Billable customer → Billable trait: uses trait
README.md - Billable trait → Payment service: initiates charge
src/Concerns/Billable.php - Billable trait → Subscription service: requests subscription
src/Concerns/Billable.php - Payment API → Payment service: initiates payment
src/Http/Controllers/Api/PaymentController.php - Subscription API → Subscription service: manages subscription
src/Http/Controllers/Api/SubscriptionController.php - Plan API → Billing plans: reads plans
src/Http/Controllers/Api/PlanController.php - Plan API → Subscription service: subscribes customer
src/Http/Controllers/Api/PlanController.php - Subscription service → Billing plans: resolves plan
src/Services/SubscriptionService.php - Subscription service → Subscriptions: creates subscription
src/Services/SubscriptionService.php - Payment service → Driver manager: selects driver
src/Services/PaymentService.php - Payment service → Reference generator: generates references
src/Services/PaymentService.php - Payment service → Transactions: records payment
src/Services/PaymentService.php - Payment service → Payment result: returns result
src/Services/PaymentService.php - Driver manager → M-Pesa driver: creates driver
src/Services/BillingManager.php - M-Pesa driver → Driver contract: implements
src/Services/BillingManager.php - M-Pesa driver → Daraja gateway: calls Daraja
README.md - Webhook handler → Payment service: handles callback
src/Http/Controllers/Api/WebhookController.php - Payment service → Invoices: marks paid
src/Services/PaymentService.php - Payment service → Subscriptions: renews linked
src/Services/PaymentService.php - Renewal command → Payment service: charges due
src/Console/Commands/ProcessRenewalsCommand.php - Renewal command → Subscriptions: loads due
src/Console/Commands/ProcessRenewalsCommand.php - Dunning service → Payment service: retries payments
src/Services/DunningService.php - Dunning service → Subscriptions: updates status
src/Services/DunningService.php - Reminder command → Subscriptions: selects expiring
src/Console/Commands/SendRemindersCommand.php - Reminder command → Renewal notification: sends notification
src/Console/Commands/SendRemindersCommand.php - Admin routes → Transaction admin: routes admin
routes/web.php - Transaction admin → Transactions: queries transactions
src/Http/Controllers/Admin/TransactionController.php - Transaction admin → Payment service: verifies or refunds
src/Http/Controllers/Admin/TransactionController.php - Plan admin → Billing plans: manages plans
src/Http/Controllers/Admin/PlanController.php - Subscription admin → Subscriptions: reads subscriptions
src/Http/Controllers/Admin/SubscriptionController.php - Subscription admin → Subscription service: changes subscription
src/Http/Controllers/Admin/SubscriptionController.php - Invoice admin → Invoices: manages invoices
src/Http/Controllers/Admin/InvoiceController.php - Admin dashboard → Transactions: summarizes billing
src/Http/Controllers/Admin/DashboardController.php - Admin dashboard → Subscriptions: summarizes billing
src/Http/Controllers/Admin/DashboardController.php - Admin dashboard → Billing plans: summarizes billing
src/Http/Controllers/Admin/DashboardController.php - Admin dashboard → Invoices: summarizes billing
src/Http/Controllers/Admin/DashboardController.php - Transaction admin → Admin views: renders views