dualcube / moodle-enrol_stripepayment

Moodle Stripe Payment Collector
16 stars 26 forks source link

No course enrolment after payment #81

Closed leinton closed 3 years ago

leinton commented 3 years ago

We've recently received a successful payment that did not trigger a course enrollment. This has not happened before - to date all payments/enrollments have worked fine.

Are there any logs I can inspect/provide to find out what may have happened? Moodle 3.10.6 (Build: 20210729) Stripe: 3.3.0 (Build: 2021080601)

Cheers, Lein

moumitahalder commented 3 years ago

Hi Lein, please make sure you have added the token in your stripe settings. I am sharing the updated document to guide you further : https://dualcube.com/docs/stripe-payment-with-sca-and-coupon/#3-toc-title

leinton commented 3 years ago

Thanks for checking in on this. The token is in the settings. The payments usually succeed.

Looking through the http logs, I can see how when a learner does a successful payment, they are redirected to the Stripe site first and then Stripe normally redirects the learner to enrol/index.php:

[09/Aug/2021:11:00:19 +0800] "GET /enrol/index.php?id=2 HTTP/1.1" 200 171007 "https://learn.domain.org.nz/enrol/index.php?id=2"

[09/Aug/2021:11:00:21 +0800] "POST /lib/ajax/service.php?sesskey=vAPrKCvfwp&info=local_edwiserreports_get_plugin_config HTTP/1.1" 200 91 "https://learn.domain.org.nz/enrol/index.php?id=2"

[09/Aug/2021:11:00:24 +0800] "POST /lib/ajax/service.php?sesskey=vAPrKCvfwp&info=moodle_stripepayment_stripe_js_settings HTTP/1.1" 200 104 "https://learn.domain.org.nz/enrol/index.php?id=2"

[09/Aug/2021:11:00:42 +0800] "GET /course/view.php?id=2 HTTP/1.1" 303 1522 "https://checkout.stripe.com/"

[09/Aug/2021:11:00:42 +0800] "GET /enrol/index.php?id=2 HTTP/1.1" 200 171007 "https://checkout.stripe.com/"

So that worked.. In case of the failed enrolment however, I'm getting no entries for 2 minutes or so and then a http request the the root:

[12/Aug/2021:17:37:25 +0800] "POST /lib/ajax/service.php?sesskey=XCQjJvu1Pw&info=moodle_stripepayment_couponsettings HTTP/1.1" 200 44 "https://learn.domain.org.nz/enrol/index.php?id=2"

[12/Aug/2021:17:37:26 +0800] "POST /enrol/index.php?id=2 HTTP/1.1" 200 171030 "https://learn.domain.org.nz/enrol/index.php?id=2"

[12/Aug/2021:17:37:27 +0800] "POST /lib/ajax/service.php?sesskey=XCQjJvu1Pw&info=local_edwiserreports_get_plugin_config HTTP/1.1" 200 91 "https://learn.domain.org.nz/enrol/index.php?id=2"

[12/Aug/2021:17:37:34 +0800] "POST /lib/ajax/service.php?sesskey=XCQjJvu1Pw&info=moodle_stripepayment_stripe_js_settings HTTP/1.1" 200 104 "https://learn.domain.org.nz/enrol/index.php?id=2"

[no entry for a GET to enrol/index.php]

[12/Aug/2021:17:39:32 +0800] "GET / HTTP/1.1" 200 148617 "https://learn.domain.org.nz/"

Checking the actual payment on Stripe, the timings match, but the learner seems to have entered a wrong CVC, then corrected it (attached)

thumbnail_Screen Shot 2021-08-13 at 4 51 25 PM

We've asked the learner to share their experience - it is possible that they e.g. closed the payment window or their browser misbehaved. I'll update this thread if we hear back from them.

cool-raju commented 3 years ago

Hi, @leinton In case of failed payment, you might have an issue related to your card details. Your URLs are right. Please clear your logs and try with a fresh payment. Thanks

leinton commented 3 years ago

Thanks @cool-raju, @moumitahalder

I’ll clarify..

We’ve had 80 or so successful payments and only one issue.

The payment that went wrong looks like the learner entered an incorrect cvc initially but corrected it. Their payment was then made successfully.

However, the learner was not enrolled in a course automatically.

Does that make sense?

leinton commented 3 years ago

Looks like the configuration for web services (turning them on, configuring a token) was missing in our setup.

While investigating I noticed that the hand-off to Stripe also makes a POSTs to an endpoint that starts with "cslive". The JSON payload contains a success_url.

When I pasted the success_url into my browser - before making the payment - I was enrolled in a course.

Would you be able to replicate that - could just be a quirk?