Paypal in Moodle 1.9.7 Not Enrolling User + Not updating db

Paypal in Moodle 1.9.7 Not Enrolling User + Not updating db

by Jason C -
Number of replies: 3

ipn.php,v 1.22.2.1

Moodle version 1.9.7+

I'm having a fairly serious issue with the Paypal module in 1.9.7, it appears to be correctly setup to operate in the Paypal sandbox (complete with changes in ipn.php to use port 443 and ssl://). I am getting no errors and paypal ipn history is showing a 200 response code. However, the payment is not logged in mdl_enrol_paypal, and the user is not added to the course. 

This is likely the same problem encountered in http://tracker.moodle.org/browse/MDL-22016

Has anyone found a fix to this, or is the best recourse an upgrade?

Average of ratings: -
In reply to Jason C

Re: Paypal in Moodle 1.9.7 Not Enrolling User + Not updating db

by Ian L -

I think this one is the one that helped me. http://moodle.org/mod/forum/discuss.php?d=137336

I pasted that code that he put there into the ipn.php and that solved the "Thank you for your payment blah blah..."

In reply to Ian L

Re: Paypal in Moodle 1.9.7 Not Enrolling User + Not updating db

by Jason C -

I've used the error reporting code, but annoyingly, it isn't reporting an error. 

Example (these are all sandbox, so nothing secret here):

cmd=_notify-validate&mc_gross=25.00&protection_eligibility=Ineligible&payer_id=4KJKAWFKT4XPA&tax=0.00&payment_date=07%3A28%3A51+Aug+13%2C+2012+PDT&payment_status=Completed&charset=UTF-8&first_name=Jason&option_selection1=Test+User&mc_fee=1.03&notify_version=3.6&custom=134-27&payer_status=verified&business=robert_1344856885_biz%40gmail.com&quantity=1&verify_sign=A-F6Geof.8HOwAIwRPNkFR1IG5mHAQ5ZVQxxk4wdDiJNC2Gon8ZAxWPy&payer_email=jrcrit_1344550843_per%40gmail.com&option_name1=User&txn_id=5VX95512AM364103G&payment_type=instant&last_name=C&receiver_email=robert_1344856885_biz%40gmail.com&payment_fee=1.03&receiver_id=T6EWUAXCB8HK6&txn_type=web_accept&item_name=Home+Care+Providers+-+Staff&mc_currency=USD&item_number=CF203&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=134-27&payment_gross=25.00&shipping=0.00&ipn_track_id=b43b8efcd64c7\ n

It's logging a completed verification, but not adding it to the database, and not enrolling the user. It's incredibly strange. 

In reply to Jason C

Re: Paypal in Moodle 1.9.7 Not Enrolling User + Not updating db

by Jason C -

I have discovered the problem here.

strcmp was not correctly returning 0 after reading through Paypals verification response.

changing from strcmp to strpos has fixed the problem. 

ex. 

if ((strpos($result, "VERIFIED")) !== false) {