You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+63-55Lines changed: 63 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## What This Is
6
6
7
-
`host-uk/core-commerce`- A Laravel package providing orders, subscriptions, invoices, and payment processing. Namespace: `Core\Mod\Commerce`.
7
+
`lthn/php-commerce`— A Laravel package providing orders, subscriptions, invoices, and payment processing. This is a **package** (not a standalone app), tested with Orchestra Testbench.
8
8
9
9
## Commands
10
10
@@ -13,13 +13,21 @@ composer run lint # vendor/bin/pint
13
13
composer run test# vendor/bin/pest
14
14
vendor/bin/pint --dirty # Format changed files only
15
15
vendor/bin/pest --filter=CheckoutFlowTest # Run single test file
16
+
vendor/bin/pest --filter="checkout"# Run tests matching name
16
17
```
17
18
18
19
## Architecture
19
20
21
+
### Dual Namespace System
22
+
23
+
The package has two PSR-4 roots, serving different purposes:
24
+
25
+
-`Core\Mod\Commerce\` (root `./`) — The module: models, services, events, Livewire components, routes. `Boot.php` extends `ServiceProvider` with event-driven lazy-loading via `$listens`.
26
+
-`Core\Service\Commerce\` (root `./Service/`) — The service definition layer: implements `ServiceDefinition` for the platform's service registry (admin menus, entitlements, versioning).
27
+
20
28
### Boot & Event System
21
29
22
-
This is a **Laravel package** (not a standalone app). `Boot.php`extends `ServiceProvider` and uses the Core Framework's event-driven lazy-loading:
30
+
`Boot.php` uses the Core Framework's event-driven lazy-loading — handlers only fire when the relevant subsystem initialises:
23
31
24
32
```php
25
33
public static array $listens = [
@@ -30,83 +38,83 @@ public static array $listens = [
30
38
];
31
39
```
32
40
33
-
### Service Layer
41
+
Livewire components are registered inside `onAdminPanel()` and `onWebRoutes()`, not auto-discovered. All components use the `commerce.admin.*` or `commerce.web.*` naming prefix.
34
42
35
-
Business logic lives in `Services/`. All services are registered as singletons in `Boot::register()`:
Pluggable via `PaymentGatewayContract` in `Services/PaymentGateway/`:
46
+
-`BTCPayGateway` — Cryptocurrency (default when enabled)
47
+
-`StripeGateway` — Card payments (SaaS)
47
48
48
-
### Payment Gateways
49
+
The default gateway is resolved by checking `config('commerce.gateways.btcpay.enabled')` — BTCPay takes priority when enabled.
50
+
51
+
### Multi-Entity Hierarchy (Commerce Matrix)
49
52
50
-
Pluggable via `PaymentGatewayContract`:
51
-
-`StripeGateway` - Primary (SaaS)
52
-
-`BTCPayGateway` - Cryptocurrency
53
+
The system supports a three-tier entity model configured in `config.php` under `matrix` and `entities`:
54
+
-**M1 (Master Company)** — Owns the product catalogue, source of truth
55
+
-**M2 (Facade/Storefront)** — Selects from M1 catalogue, can override content
56
+
-**M3 (Dropshipper)** — Full catalogue inheritance, no management responsibility
57
+
58
+
`PermissionMatrixService` controls cross-entity access. It has a "training mode" (prompts for undefined permissions) and "strict mode" (undefined = denied).
-`View/Modal/Admin/` — Admin panel (managers for orders, coupons, products, etc.)
79
+
80
+
### Scheduled Commands
81
+
82
+
`Console/` has artisan commands registered in `onConsole()`: dunning processing, renewal reminders, exchange rate refresh, usage sync to Stripe, referral commission maturation, expired order cleanup, and tree planting for subscribers.
0 commit comments