Moodle Plugins directory: Restriction by Stripe payment | Moodle.org
Restriction by Stripe payment
Stripe Payment Availability Condition for Moodle
Restrict access to any Moodle activity or resource behind a Stripe payment. Students pay once and gain immediate access. Teachers and admins always bypass the restriction.
Features
-
Restrict any activity (assignment, quiz, file, page, etc.) behind a one-time payment
-
Supports all major currencies including zero-decimal currencies (JPY, KRW, etc.)
-
Stripe Checkout hosted page — no card data touches your server
-
Webhook-driven access grant — access is unlocked the moment payment completes
-
Payment button rendered inline on the course page — no JavaScript DOM injection
-
Branded HTML email notifications sent to your accounts team and site admins
-
Admin dashboard with transaction history, per-currency revenue summary, and direct Stripe links
-
Per-activity payment report for teachers — no site-admin access required
-
Duplicate session prevention — a second click within 2 minutes is blocked server-side
-
Stale pending payments automatically cleaned up daily by a scheduled task
-
CSV export of all transactions
-
Teachers and admins always bypass the payment restriction
Requirements
-
Moodle 4.5 or later
-
PHP 8.1 or later
-
A Stripe account (free to create)
-
HTTPS on your Moodle site (required by Stripe)
Installation
1. Download the plugin
Download the latest release ZIP from the Moodle plugins directory or from the GitHub releases page.
The ZIP already includes the Stripe PHP SDK bundled inside
vendor/. No Composer required on your server.
2. Install in Moodle
Option A — Via the Moodle admin interface (recommended)
-
Log in as admin
-
Go to Site Administration → Plugins → Install plugins
-
Upload the ZIP file
-
Click Install plugin from the ZIP file
-
Follow the on-screen prompts and click Upgrade Moodle database now
Option B — Manual installation
-
Unzip the plugin
-
Copy the
stripepaymentfolder to[moodleroot]/availability/condition/stripepayment/ -
Log in as admin
-
Go to Site Administration → Notifications
-
Click Upgrade Moodle database now
Configuration
1. Get your Stripe API keys
-
Log in to the Stripe Dashboard
-
Go to Developers → API keys
-
Copy your Publishable key and Secret key
-
Use test mode keys while testing, switch to live keys when ready
-
2. Set up a Stripe Webhook
-
In the Stripe Dashboard go to Developers → Webhooks
-
Click Add endpoint
-
Set the endpoint URL to:
https://yourmoodlesite.com/availability/condition/stripepayment/webhook.php
-
Under Events to listen to, select:
-
checkout.session.completed
-
-
Click Add endpoint
-
Click Reveal next to Signing secret and copy it
3. Configure the plugin in Moodle
-
Go to Site Administration → Plugins → Availability restrictions → Stripe Payment
-
Fill in the required Stripe configuration fields:
-
Enable Stripe payments
-
Stripe publishable key
-
Stripe secret key
-
Webhook endpoint secret
-
Accounts email
-
Adding a Payment Restriction to an Activity
-
Go to your course and turn editing on
-
Click Edit next to any activity → Edit settings
-
Scroll down to Restrict access
-
Click Add restriction → Stripe payment
-
Configure:
-
Amount
-
Currency
-
Item name
-
-
Save the activity
Students who have not paid will see a payment button inline on the course page. After paying they are redirected back and access is granted automatically.
Transaction Reports
Site-wide report (admins)
Go to:
Site Administration → Reports → Stripe Payment Transactions
Features include:
-
Transaction history
-
Revenue summaries
-
Stripe dashboard links
-
Course/status filtering
-
CSV export
Per-activity report (teachers)
Teachers can access payment reports directly from the course page or Reports navigation menu.
The report includes:
-
Completed payments
-
Pending payments
-
Revenue totals
-
Student payment records
Testing
Use Stripe's test card numbers while the plugin is in test mode:
| Card number | Result |
|---|---|
4242 4242 4242 4242 |
Payment succeeds |
4000 0000 0000 0002 |
Card declined |
4000 0025 0000 3155 |
Requires 3D Secure |
Use any future expiry date, any 3-digit CVC, and any postcode.
Troubleshooting
Access not granted after payment
-
Verify your webhook URL
-
Verify the webhook secret
-
Check PHP error logs
-
Ensure the Moodle site is publicly accessible
Stripe is not configured
-
Ensure the Stripe secret key is saved in plugin settings
Live payments not working
-
Replace test keys with live keys
-
Configure a live webhook endpoint in Stripe
Third-party libraries
This plugin bundles the Stripe PHP SDK:
-
Library: Stripe PHP SDK
-
Version: 13.18.0
-
License: MIT License
Support & Donations
Developed and maintained by Andrei Toma.
-
GitHub repository: tandreigaabriel/moodle-availability_stripepayment
-
Bug reports & feature requests: open an issue on GitHub
If this plugin saves you time or helps your organisation, please consider supporting its ongoing development and maintenance through a donation:
https://www.tandreig.com/plugins
License
This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
Copyright © 2026 Andrei Toma
Changelog
1.4.0
-
Added translations for Italian (
it), Spanish (es), Romanian (ro), Greek (el), Swedish (sv), and Finnish (fi) -
Added Moodle 5.0 support to the GitHub Actions CI matrix
-
Added compatibility testing for PHP 8.2 and 8.3
-
Fixed Mustache lint CI path validation issues
1.3.3
-
Improved payment notification reliability
-
Added branded HTML email templates
-
Added AMD ES6 module support
-
Added GitHub Actions CI pipeline
-
Fixed multiple Moodle Plugin CI and PHPCS issues
-
Improved reporting and CSV export handling
1.3.2
-
Fixed Moodle plugin review issues
-
Implemented Privacy API provider
-
Improved CSS namespacing
1.3.1
-
Fixed zero-decimal currency formatting
-
Fixed currency code normalisation
1.3.0
-
Added additional Stripe-supported currencies
-
Added Stripe test/live dashboard detection
1.2.0
-
Added revenue summaries grouped by currency
-
Added teacher payment reports
-
Added Bootstrap 5 styling
1.1.0
-
Added duplicate session prevention
-
Added scheduled cleanup task
-
Added Mustache-based payment button rendering
1.0.0
-
Initial release
-
Stripe Checkout integration
-
Webhook payment verification
-
Admin transaction dashboard
-
Multi-currency support
Comments