Moodle core
Users, courses, roles, contexts, enrolments, completion, grades, files, messaging, privacy, and cron.
Developer platform
Extend catalogue, order, enrolment, subscription, and storefront workflows without operating a separate bridge. ModernCommerce follows Moodle's native component, capability, event, task, privacy, and external-function conventions.
Current source contract: ModernCommerce 2.1.6 · Moodle 5.2 · PHP 8.3+
<?php
$observers = [
[
'eventname' =>
'\local_moderncommerce\event\order_paid',
'callback' =>
'\local_yourplugin\observer::order_paid',
],
];
React to a domain event. Keep order and entitlement writes inside ModernCommerce services.
Audited directly from db/services.php, classes/event, db/tasks.php, db/access.php, and db/install.xml in release 2.1.6.
Choose a starting point
Each path leads to the detailed, source-audited documentation rather than duplicating contracts on a marketing page.
System boundary
ModernCommerce adds commercial state without duplicating Moodle's learning records or identity system.
Explore the data modelUsers, courses, roles, contexts, enrolments, completion, grades, files, messaging, privacy, and cron.
Products, prices, carts, orders, payments, invoices, entitlements, keys, subscriptions, storefront, and reporting.
Stripe, PayPal, Paystack, and Flutterwave receive payment data and return callbacks or signed webhooks.
A gateway success screen is not fulfilment. Verified payment state, order transition, entitlement creation, and Moodle enrolment must agree.
Extension contracts
Moodle recommends events for inter-plugin communication. ModernCommerce also exposes external functions, scheduled tasks, capability contracts, and optional add-on detection.
Observe order_paid, order_status_changed, and subscription lifecycle events. Treat the installed release's event class as the payload authority and regression-test every upgrade.
The 156 declarations in db/services.php power shipped AJAX applications. They define read/write intent, login policy, and capability requirements; they are not an unauthenticated, general-purpose public REST API.
An add-on should own its tables, configuration, services, tasks, privacy declarations, and business rules. Gate integrations when the component or required capability is absent.
Read the add-on contractRenewals, expiry, access synchronization, notifications, abandoned-cart recovery, and reports depend on Moodle cron. Production cron should run every minute.
Review scheduled workLocal workflow
Use a disposable Moodle environment and sandbox gateway accounts. Never seed or reset demonstration commerce data in production.
InstallMoodle 5.2, PHP 8.3+, HTTPS for live gateway work, and Composer dependencies.
InitializeRun Moodle upgrade, install safe defaults, and keep cron active.
ExerciseCreate a product, complete a sandbox purchase, and confirm order, payment, entitlement, enrolment, and invoice state.
ValidateRun project checks and test both the presence and absence of optional add-ons.
# Install the plugin dependencies
composer install --working-dir=local/moderncommerce
# Register the plugin and run background work
php admin/cli/upgrade.php --non-interactive
php admin/cli/cron.php
# Development or staging only
php local/moderncommerce/cli/demo_data.php --install-defaults
php local/moderncommerce/cli/demo_data.php --audit
# Source-quality checks
composer --working-dir=local/moderncommerce run mc:docs-check
composer --working-dir=local/moderncommerce run mc:string-audit
composer --working-dir=local/moderncommerce run mc:check-fast
Source map
Executable metadata outranks old README files or screenshots.
| Source | Authority |
|---|---|
version.php | Release, maturity, Moodle requirement, and supported Moodle branch. |
composer.json | PHP requirement, package dependencies, autoloading, and project checks. |
db/services.php | External-function classes, access intent, AJAX policy, and capabilities. |
db/access.php | Capability definitions and role archetype defaults. |
db/events.php | Internal event observers and their processing priority. |
db/tasks.php | Scheduled task classes and default schedules. |
db/install.xml | Install-time database schema, keys, indexes, and field types. |
lang/en/local_moderncommerce.php | User-facing terminology and configuration help text. |
Engineering guardrails
Platform references
Use ModernCommerce documentation for product-specific behavior and Moodle's versioned developer documentation for the underlying platform APIs.
Start with a working transaction
Complete a sandbox purchase before designing an integration so you can see the order, payment, enrolment, invoice, and event lifecycle together.