Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by Gerald Grow -
Number of replies: 7

I realize this is the wrong forum, but I have not received an answer after a month on the enrollment forum, so I don't know where else to ask.

Paypal has been emailing a notice saying their handling of payments is changing Oct. 7. Will Moodle 1.9 contiue to work with Paypal payments then? Here is part of the notice:

"Starting October 7, 2013, we will require all incoming requests to have a “Host” header which complies with HTTP 1.1 Specifications. This header was not required under HTTP 1.0. IPN and PDT scripts using HTTP 1.0 may start failing with “HTTP/1.0 400 Bad Request” errors after October 7, 2013, which will result in IPN messages not being validated successfully, or PDT scripts not being able to retrieve transaction information."

Anybody know? Some of us will still be using Moodle 1.9 with Paypal during this time.

It is my understanding that Moodle 2+ takes care of this situation. Anybody know if this is correct?

Thanks for any insight you have.

Average of ratings: -
In reply to Gerald Grow

Re: Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by Gerald Grow -

Today's email from Paypal says the IPN upgrade has been postponed. But it would still be good to know whether Moodle (1 and 2) will be affected.

In reply to Gerald Grow

Re: Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Gerald,
see the technical details in MDL-35456.
Shortly: Moodle 2.x STABLE is fine, 1.9.x no.

If you look at the fix, see e.g. https://github.com/moodle/moodle/commit/b7a9c85118be91c3dd1d0aa65c22b77de1fc5ef5, you could backport it to 1.9 by your own, kind of (untested):

diff --git a/enrol/paypal/ipn.php b/enrol/paypal/ipn.php
index 44a3cef..af83f8a 100644
--- a/enrol/paypal/ipn.php
+++ b/enrol/paypal/ipn.php
@@ -63,11 +63,12 @@

 /// Open a connection back to PayPal to validate the data

+    $paypaladdr = empty($CFG->usepaypalsandbox) ? 'www.paypal.com' : 'www.sandbox.paypal.com';
     $header = '';
-    $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
+    $header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
+    $header .= "Host: $paypaladdr\r\n";
     $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
-    $paypaladdr = empty($CFG->usepaypalsandbox) ? 'www.paypal.com' : 'www.sandbox.paypal.com';
     $fp = fsockopen ($paypaladdr, 80, $errno, $errstr, 30);

     if (!$fp) {  /// Could not open a socket to PayPal - FAIL

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

Re: Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by Gerald Grow -

Matteo, you are kind to respond with such detail. Unfortunately, I lack the technical expertise to make changes at this level safely.

Fortunately, Paypal recently announced that it is delaying the change in IPN.

If Paypal makes this change in the future, I have some concern for the many Moodle users whose server limitations require them to continue using v. 1.9+.

In reply to Gerald Grow

Re: Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Gerald,
to make the changes that Matteo suggests you just need a text editor and an FTP program. Download the following file from your Moodle site to your PC:

  • enrol/paypal/ipn.php

Open it with a text editor and remove the lines shown in RED in Matteo's post. Then add the lines shown in GREEN. Finally save the file and upload it back to your Moodle site. That's should do it.

best regards
Gordon

In reply to Gordon Bateson

Re: Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by Gerald Grow -

Thanks for the clarification, Gordon. I'm at home editing and FTPing files. GIT I have never used.

In reply to Matteo Scaramuccia

Re: Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by lionel oneill -

Hi Matteo,

Thank you for your code. I have modified ipn.php and the Paypal enrol is Ok with http 1.1

Good week

Best regards

Lionel

Average of ratings: Useful (1)
In reply to lionel oneill

Re: Will Paypal continue to work on Moodle 1.9 after October 7, 2013?

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

My pleasure, Lionel smile.

My post should, now, be quite clear for future reference but I've also decided to publish the backport of MDL-35456 using the git repo below, just in case of more help:

Pull from Repository: https://github.com/scara/moodle
Pull 1.9 branch: m19_PayPal_IPN_Discard_HTTP10_Require_HTTP11_And_Host
Pull 1.9 Diff Url: https://github.com/scara/moodle/commit/29ead4927eb905f445ee63bad0072448001eeba2

HTH,
Matteo

Average of ratings: Useful (1)