Closed ajasnz closed 3 years ago
Hi xelast148, Unfortunately, this should really be implemented by the payment gateways themselves because that's where the logic should take place (a 0 payment can still be a payment nonetheless and on top of that: the "payable" is where the discount is calculated). I could form a solution where actual payment is circumvented when entering a 100% discount code; but the question then becomes if this is not prone to brute force attacks (if trying discount codes is not limited) or even whether or not people should actually be given a "free pass" and enrolment should be instant (so, bypassing the payment gateway altogether).
What payment gateway did you use by the way? If the gateway used is not in our active development it might be tricky to actually facilitate your FR. On the other hand, I can imagine introducing a few settings that allow you to manipulate the behavior for your FR. If I'd implement two settings for this; they'd be to disallow 100% discounts alltogether. The other setting would allow you to bypass payment alltogether and provide "free passing rights" to anyone entering a 100% discount code. Please do note: I will still have to process a "payment record", which will indicate a zero payment because of the fact I have to be able to link a payment to the enrolment if the enrolment would be set to "gwpayments".
If a payment record is not processed; technically I shouldn't enrol the user using gwpayments; but manual (in any case: every gwpayments enrolment should be linked/linkable to a payment record).
Hi Rogiervandongen, Thanks for your comment. I am using the stripe payment gateway. I do understand your concerns around the brute-forcing of enrolment attempts if the gateway is bypassed, is it possible it could be added as an option that users could enable? Either that or if you are willing, could you provide me with some guidance and I am happy to make the changes locally on my instance so it isn't reflected in your primary production branch?
Personally my use case is that I have some people that approach me with multiple people wanting to be enrolled as part of a group, and for those people I would like to be able to pay via bank transfer and then provide them with a coupon for a set number of uses while still having the ability for individuals to pay. (I have not yet found an alternative plugin that allows to generate an enrolment code that can only be used a certain number of times)
Thank you, @xelast418, for your extensive explanation. It makes things a little more clear. I think the best choice here will be to allow for these settings and allowing to bypass the payment gateways altogether (we have no control over the Stripe gateway as it's not under our source control). You can expect this feature very soon because your case makes sense this way (on top of that I was working on a few other fixes that need to be rolled out).
Also a heads up: a contributing.md will be added here soon because, much like Moodle itself, github is not where central development takes place. Github is only a mirror for a number of our repositories, so we're still working out a decent way to allow contributions (very likely through the issue tracker on github where patches can be provided). In any case, under no circumstance will PR's on the main branch be merged/accepted in any way (for the simple reason it messes up the rollout/CI infra).
Thanks again, keep in touch and don't be shy to file issues here, whether those are feature requests or bug reports. Cheers! Rogier
Thanks, that's great!
@xelast418 Please be aware of the neccessry change: you must enable the option "enablebypassinggateway", which is the very last option in the global enrol_gwpayments settings. We've explicitly chosen to only support enabling this on a global level (instance level would only complicate things further and I don't really think the use cases would be that many to implement instance level settings for this feature).
Cheers & thanks for reporting
Thank you for this!
If a coupon for a 100% discount is used can it please go straight to enrolling the user. Currently it tries to process the payment and it fails as the payment gateway can't handle a 0 payment. It would be preferable to have it enroll a user with a 100% discount than have it just reject the coupon or fail.