dualcube / moodle-enrol_stripepayment

Moodle Stripe Payment Collector
16 stars 27 forks source link

Purchases with coupon getting redeemed twice #139

Closed jimcrammond closed 5 months ago

jimcrammond commented 6 months ago

Reproduced with version 3.4.4.

Define a coupon with a 90% discount and a limited number of redemptions.

Apply the coupon and then purchase the course. The result in Stripe is that the coupon has been redeemed twice. The second redemption occurs in success_stripe_url (the callback after a successful payment). I think the first redemption is happening in the session checkout (POST /v1/payment_pages/...). Not sure if this is a change in the underlying Stripe library.

A side effect of this is that if there is only 1 redemption left before the purchase, the purchase will succeed but the test for a valid coupon in success_stripe_url will fail and thus the user is redirected back to the enrol page without completing the enrollment. If the solution to the double redemption is to remove the second redemption from success_stripe_url() then this test will also need to be considered.

moumitahalder commented 6 months ago

Jim, we are able to re-create this issue : https://www.loom.com/share/1f8fca0f76c64130bbddbf233147de49 Our team is looking into this. Kindly provide them some time.