Restriction by Stripe payment

Availability restriction ::: availability_stripepayment
Maintained by Andrei Toma
Restricts access to Moodle activities or resources behind a Stripe payment. Students must complete a one-time Stripe Checkout payment before gaining access, while teachers and administrators automatically bypass the restriction.
Latest release:
5 sites
90 downloads
Current versions available: 1

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)

  1. Log in as admin

  2. Go to Site Administration → Plugins → Install plugins

  3. Upload the ZIP file

  4. Click Install plugin from the ZIP file

  5. Follow the on-screen prompts and click Upgrade Moodle database now

Option B — Manual installation

  1. Unzip the plugin

  2. Copy the stripepayment folder to [moodleroot]/availability/condition/stripepayment/

  3. Log in as admin

  4. Go to Site Administration → Notifications

  5. Click Upgrade Moodle database now


Configuration

1. Get your Stripe API keys

  1. Log in to the Stripe Dashboard

  2. Go to Developers → API keys

  3. 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

  1. In the Stripe Dashboard go to Developers → Webhooks

  2. Click Add endpoint

  3. Set the endpoint URL to:

https://yourmoodlesite.com/availability/condition/stripepayment/webhook.php

  1. Under Events to listen to, select:

    • checkout.session.completed

  2. Click Add endpoint

  3. Click Reveal next to Signing secret and copy it

3. Configure the plugin in Moodle

  1. Go to Site Administration → Plugins → Availability restrictions → Stripe Payment

  2. 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

  1. Go to your course and turn editing on

  2. Click Edit next to any activity → Edit settings

  3. Scroll down to Restrict access

  4. Click Add restrictionStripe payment

  5. Configure:

    • Amount

    • Currency

    • Item name

  6. 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:


Support & Donations

Developed and maintained by Andrei Toma.

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

Potential privacy issues

This plugin sends payment information to Stripe in order to process payments. No card data is stored on the Moodle server. Student email address and purchase information may be transmitted to Stripe for payment processing.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4
Screenshot #5
Screenshot #6
Screenshot #7

Contributors

Andrei Toma (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments

Show comments
Please login to post comments