Stripe Payment with SCA and Coupon

Enrolment ::: enrol_stripepayment
Maintained by DualCube Team
Now avail the much-awaited coupon functionality while enrolling students in Moodle courses using a Stripe payment gateway for paid courses with Strong customer authentication (SCA). Stripe Receipt sent to customers for any successful transaction. This plugin will help the admins and webmasters to offer their students a percent-off or amount-off discount for the paid courses. This plugin helps admins and webmasters use Stripe as the payment gateway.
Latest release:
1226 sites
57 fans
Current versions available: 2

Stripe Payment: 

Introducing the newest offering from Team Dualcube: Stripe Payment!

Now avail the much-awaited coupon functionality while enrolling students in Moodle courses using Stripe payment gateway for paid courses with Strong customer authentication (SCA).

This plugin will help the admins and webmasters to offer their students a percent-off or amount-off discount for the paid courses.

Stripe Payment:

1. Registered users can login to the Moodle site and happily apply the promo codes for a discount before payment. On successful payment, they can access the course.

2. Admins and Webmasters, now, can create, manage and keep track of all promotional codes directly in their Stripe dashboard.

3. Strong customer authentication (SCA) implemented with 4 layers of complex security to comply with EU Revised Directive on Payment Services (PSD2) on payment service providers within the European Economic Area.

4. The first of it's kind to use Payment intent method for Stripe-coupon. 

5. Works with all stable versions of Moodle till v 3.8.1

6. Latest Stripe SDK

Stripe Payment Documentation:

This plugin has all the settings for development as well as for production usage. Its easy to install, set up and effective.

Creating Merchant Account :

1) Create account at

2) Complete your merchant profile details from

3) Now set up secret key and publishers key at

4) For test mode use test api keys and for live mode use live api keys.

Now you are done with merchant account set up.

Installation Guidance : 

Login to your moodle site as an “admin user” and follow the steps.

1) Upload the zip package from Site administration > Plugins > Install plugins. Choose Plugin type 'Enrolment method (enrol)'. Upload the ZIP package, check the acknowledgement and install.

2) Go to Enrolments > Manage enrol plugins > Enable 'Stripe' from list

3) Click 'Settings' which will lead to the settings page of the plugin

4) Provide merchant credentials for Stripe. Note that, you will get all the details from your merchant account. Now select the checkbox as per requirement. Save the settings.

5) Select any course from course listing page.

6) Go to Course administration > Users > Enrolment methods > Add method 'Stripe' from the dropdown. Set 'Custom instance name', 'Enrol cost' etc and add the method.

Adding coupons:

Go to your Stripe Dashboard >  Product > Coupons > Create a coupon.

Type in the coupon’s name: it can be anything and for your reference only.
Type in the Coupon’s ID : This is the Coupon code which your students will need to enter if they want to avail the discount.

Choose Coupon Type: 
1. Percentage discount : offers % off on the course price 
2. Fixed amount discount : Offers a fixed amount off on the course price.

Duration: For duration, when using the value repeating, also specify duration in months as the number of months for which the coupon should repeatedly apply. Otherwise the coupon can be set to apply only to a single invoice or to them all.

Redemption : The max_redemptions and redeem_by values apply to the coupon across every customer you have. For example, you can restrict a coupon to the first 50 customers that use it, or you can make a coupon expire by a certain date. If you do the latter, this only impacts when the coupon can be applied to a customer. If you set a coupon to last forever when used by a customer, but have it expire on January 1st, any customer given that coupon will have that coupon’s discount forever, but no new customers can apply the coupon after January 1st.

If a coupon has a max_redemptions value of 50, it can only be applied among all your customers a total of 50 times, although there’s nothing preventing a single customer from using it multiple times. (You can always use logic on your end to prevent that from occurring.)


This completes all the steps from the administrator end. Now registered users can login to the Moodle site and view the course after a successful payment of the discounted price. 


Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4


DualCube Team (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Thu, Mar 3, 2022, 6:48 AM
    Hello, I'm running into the same issue that others are reporting. Everything works fine with test keys, but after switching to live keys, although the credit card charge goes through, customers get the jason parse syntax error instead of getting enrolled in the course. Would love to get this working. Using Moodle 3.11.4.
    – Robert
  • Thu, Mar 3, 2022, 6:58 AM
    This has been discussed before (in the previous version of this plugin). I assume nothing has changed in this area. If you go to your stripe account and look at the log messages that will give you an idea if it is the same problem. Once this plugin does a transaction with a test key, it saves the generated customer key into the moodle database. Once you switch to production keys, if you try a transaction with the same user it will fail because it says the customer id is associated with the test keys. You either have to try it with a user that you havent used with test keys or you have to manually delete the entries in the enrol_stripepayment for the problem user(s).
  • Wed, Mar 23, 2022, 2:01 AM
    Hi DualCube Team,
    Thanks for making this plugin, it's perfect for our needs. I have it installed and the test payment worked as expected. I can't seem to get the Coupon working. It seems to be set up correctly in Stripe but when I enter the code when enrolling, the Apply Code button does nothing. Moodle 3.9.13 (Build: 20220314)
    Any ideas?

  • Wed, Mar 23, 2022, 5:37 PM
    just to update the above comment. I'm getting the following error:

    Failed to load resource: the server responded with a status of 404 (Not Found)
  • Thu, Mar 24, 2022, 2:11 AM
    Karl, if you go to your stripe account and look at the log messages that will tell you why it failed. Not sure which version of this stripe plugin you are using. The previous version was not good at catching all the exceptions and would thus just do nothing, for example if the coupon was expired or used up.
  • Thu, Mar 24, 2022, 3:56 PM
    Hi Karl, we checked this on our end. As you can see it is working fine

    Can you please check the coupon configuration from your stripe account.
  • Fri, Mar 25, 2022, 1:44 AM
    Thanks Jim. From what I can see it's not getting as far as stripe. Seems to be failing in the Moodle side somewhere.
    Thanks for the screen recording DualCube Team. It's good to know how it should work. I raised a ticket with our Moodle host. Apparently there's a new version of your Plugin available. They are going to update to it and I'll test again. As it is at the moment there is no response from the button. The page doesn't refresh and the amount stays the same.
    Thanks for the help
  • Mon, Mar 28, 2022, 5:15 AM
    Hello - also having the same issue as @Karl O'Keeffe above. Uploaded the latest version of the plugin today (3/27/2022) and you can enter the coupon code, but the "Enrol" button won't work for a 100% discount. Page refresh also does nothing. Any ETA on a fix?
  • Tue, Mar 29, 2022, 12:00 AM
    Got the updated plugin installed today. Although the coupon still isn't working I can see it going through to stripe, the plugin is also accepting it and telling me Invalid Coupon Code. I've obviously set it up wrong.
    I've another problem now however. I put a test payment through and was brought to a blank page with the following error:

    {"exception":"moodle_exception","errorcode":"invalidtoken","message":"Invalid token - token not found"}

    The money was taken but the account wasn't enrolled.
  • Tue, Mar 29, 2022, 12:19 AM
    apologies. I jumped the gun there without reading other posts in this thread. I added the token as outlined in these instructions and it worked as expected. I'm still having an issue with the coupon. Stripe doesn't seem to be recognising the promotion codes and keeps coming back with "resource_missing - coupon". I'm sure I'm missing something obvious. New to Stripe. If anybody has an idea I'd love to hear it.
  • Tue, Mar 29, 2022, 12:25 AM
    This plugin doesnt use the stripe promotion codes. Instead you have to set the ID of the coupon to the name you want to use.
  • Tue, Mar 29, 2022, 12:55 AM
    Thank you Jim! That's working.
  • Wed, Mar 30, 2022, 12:51 AM
    The plugin is working great now. Thanks for your help Jim and DualCube Team. One final question. Every time a payment goes through users get the message "Thank you for your payment! Unfortunately your payment has not been fully processed..." Is there any way to change the wording of this? It just seems to me that using the word "Unfortunately" gives people the impression that something has gone wrong, when in fact it just takes a minute to process. I don't think I can change this text (please correct me if I'm wrong about that). So maybe something to consider for the next update. Thanks again for the plugin.
  • Sun, Apr 3, 2022, 4:25 PM

    For your information, when I try to update to version 3.3.2 (on Moodle 3.11) I get the following error message:

    Downloading enrol_stripepayment ... OK
    Validating enrol_stripepayment ... Error
    [Error] Extracted file not found [{"file":"stripepayment\/.git\/refs\/tags\/"}]
    Installation aborted due to validation failure
  • Mon, Apr 4, 2022, 10:50 PM
    Sorry to hear that you have faced this issue, We will release an update tomorrow with the fix.
Please login to post comments