Moodle 3.0 and Paypal Sandbox

Moodle 3.0 and Paypal Sandbox

by David Espindola -
Number of replies: 25

I'm testing the paypal plugin on Moodle 3.0 with a paypal sandbox, and following all the suggested steps from here: https://moodle.org/mod/forum/discuss.php?d=171745

I configured the IPN, set the language encoding to UTF-8, etc.  Everything seems to be fine on the paypal side, as it receives a HTTP response code of 200.

However, when it returns to Moodle the student is no enrolled, and the following message appears:

"Thank you for your payment! Unfortunately your payment has not yet been fully processed, and you are not yet registered to enter the course "Swift - Jogo de Baralho". Please try continuing to the course in a few seconds, but if you continue to have trouble then please alert the Teacher or the site administrator"

Can someone help me address this issue?

Thanks,

Average of ratings: -
In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by Patrick Donadio -

In fact, I would like to make a real payment. I think it is all right but obviously it does not.


In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by David Espindola -
I have not received any help on this issue.  Is this the right place for it?


How can I get help?

In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

It is a hard one for us to troubleshoot for you.  Moodle is seeing the payment - did you make the full payment?  I would double check your Paypal enrollment settings.  Do you have a role specified?  

In reply to Emma Richardson

Re: Moodle 3.0 and Paypal Sandbox

by David Espindola -

Hi Emma,

Thanks for responding.  

Yes, I made the payment corresponding to the full amount of the cost of the course.

I'm attaching a screenshot of the paypal enrollment settings - yes, I specified the student role.

I realize this may be difficult to troubleshoot.  It would be helpful if the following could be confirmed:

- the paypal plugin works with the latest version of Moodle (someone is actually using it and getting students enrolled)  I'm using Moodle 3.0.3+ (Build: 20160407)  

- it also works with the paypal sandbox (someone has actually tested it and can get students enrolled).

I have checked all the configurations in the documentation and followed all the hints that I could find in the forum. I also spoke with Paypal support and they confirmed that Paypal is doing everything it is supposed to do, which points back to an issue on the Moodle side. 

I don't know where to go next. Do you have any suggestions?



Attachment Paypal enrollment configuration.jpg
In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

The paypal sandbox is only accepting American dollars. It should work when you update the currency of your enrolment to American bucks.

In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by David Espindola -

Rennat,

Thanks for your note.  I changed it to US dollars, but still experiencing the same problem.

In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Sorry to hear that the currency is not the problem.  Did you also try to modify the enrol cost (690 instead of 695.00)?

I just checked in Moodle 3.1, and the sandbox functionality is still working flawlessly (even with irregular characters in course/role name [MDL-41531]} 

  • config.php: $CFG->usepaypalsandbox = 1;
  • enrol_paypal | paypalbusiness : merchant@..... (merchant account of Paypal sandbox)
  • currency of course is US Dollar
  • user who logs in has the email info-buyer@... (buyer account of Paypal sandbox)
In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by David Espindola -

I changed the cost to 20.00, but that did not resolve the problem.  I noticed that in your suggestion you removed the decimals.  I can remove the decimals in the default settings screen, but in the Paypal instance for the course the decimals are added automatically and I cannot remove them.

Originally I had config.php: $CFG->usepaypalsandbox = 'www.sandbox.paypal.com';  I have now changed it to your suggested configuration $CFG->usepaypalsandbox = 1; but that does not make any difference.

I even created new paypal sandbox accounts for both BUSINESS and PERSONAL and made sure the BUSINESS account email matches the paypal business email in moodle, and that the student has the same email address as the PERSONAL account in the paypal sandbox.

Also made sure both the paypal default settings and the course paypal instance have US dollars as the currency.

I still experience the same problem.  When paypal returns to moodle I get the same message:

Thank you for your payment! Unfortunately your payment has not yet been fully processed, and you are not yet registered to enter the course "Swift para Leigos (em Breve)". Please try continuing to the course in a few seconds, but if you continue to have trouble then please alert the Teacher or the site administrator

The payment never gets processed and the student never enrolls.

I'm not using Moodle 3.1. I am using 3.0.3.  Was there any change in 3.1 related to paypal that may have fixed this problem?  Is there any way to test it in 3.0.3?

Any other thoughts?

Average of ratings: Useful (1)
In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

It is time to enable debugging and start digging into the server logs. There you should find information when and why the error occurs.

When a payment is made, Paypal posts data on a Moodle form. Moodle is reading this data, does some extra checks (right amount, same currency, no returning transaction, ...), and when everything is OK, first a new record is inserted into the mdl_enrol_paypal table, and finally the user is enrolled in the course.

When an error occurs during the checks, an email is sent to the administrator.  You do not talk about receiving admin emails, so I presume something is going wrong when a new record is added to the mdl_enrol_paypal table.  The server error logs will show you why the new record was not inserted or why the user was not enrolled.

In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by David Espindola -

I have turned debugging on.  Can you tell me what log files I'm looking for and where I can find them?   I have moodle running on a Hostgator hosting account.

The mdl_enrol_paypal table has no rows in it.   I'm not receiving any admin emails with errors.

Thanks,

In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by David Espindola -

Ok, I was able to setup the php.ini file and can see the parameters that I set in phpinfo including the path for the error log.  I made sure the Error handling and logging section of the php.ini file has  display_errors = Ondisplay_startup_errors = On and log_errors = On and uncommented.  I saw php messages from another application in the error log so I know this is working.

In Site administration -> Development  -> Debugging  I have Debug messages set to DEVELOPER.

I then performed the paypal transaction, but did not see anything captured in the error log.

So I thought that maybe I still needed to include the ini_set parameters in config.php as per https://docs.moodle.org/dev/PHP_error_logs, so I set the following:

ini_set ('display_errors', 'on'); ini_set ('log_errors', 'on'); ini_set ('display_startup_errors', 'on'); ini_set ('error_reporting', E_ALL); $CFG->debug = DEBUG_ALL;

This messed up the user interface but I was still able to transact the paypal purchase.  I got a bunch of messages in the error log, but not related to the purchase:

[20-Apr-2016 15:54:00 America/Chicago] PHP Notice:  Use of undefined constant DEBUG_ALL - assumed 'DEBUG_ALL' in /home4/brainyus/public_html/bit/config.php on line 33

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 228

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 229

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 230

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 231

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 232

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 233

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 234

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 235

[20-Apr-2016 15:54:00 America/Chicago] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home4/brainyus/public_html/bit/config.php:33) in /home4/brainyus/public_html/bit/theme/image.php on line 236

So I removed the ini_set parameters from config.php.  

I'm not seeing any error messages relevant to the paypal transaction.

What am I missing?

In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by David Espindola -

Just to get closure on this, the problem seems to be with paypal sandbox.  When I do the transaction with a live paypal account it works fine.

In reply to David Espindola

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Please find first a way to download/browse your error logs. Cpanel/webmin/directadmin/... all provide ways to have access to more than the last 10 lines. The solution is hidden in these logs.

If the problem is Sandbox only, then there is something wrong with your sandbox setup: As far as I know, there are only 4 requirements, but there could be more:

  • paypalbusiness must be a Paypal sandbox merchant account (business-Pro account) with valid credentials
  • evt 1 REST API app enabled with accepting payments checked
  • buyer must be a Paypal sandbox client account (personal account) with valid credentials
  • currency must be USD

In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by Leopoldo Rodríguez Hernández -

Hello Every body

I configuring Moodle 3.1 for work with sandbox of paypal

I have the same problem, and I´m quite shure the problem is sandbox, it always return the status as Pending, no matter the currency (Mexican Pesos or American Dolalrs) or the amount, etc.

I just follow the ipn.php and extract the values that sandbox return:

Payment Status: Pending, User id: 17, Curse id: 3, Instance id: 16, Payment gross: 25.00, Payment Currency: USD, Time Updated: 1468342044

Payment Status: Pending, User id: 17, Curse id: 3, Instance id: 16, Payment gross: 500.00, Payment Currency: MXN, Time Updated: 1468342160

Payment Status: Pending, User id: 17, Curse id: 3, Instance id: 16, Payment gross: 500.00, Payment Currency: MXN, Time Updated: 1468342707

so anybody that could suggest how to configure sandbox to work?


thanks a lot of

In reply to Leopoldo Rodríguez Hernández

Re: Moodle 3.0 and Paypal Sandbox

by Henry Quinn -

Hello guys.

I have a test Moodle 3.2 installation.  I've done no code changes to it.  I added the PayPal module to a course. I did NOT use the Paypal Sandbox. However, I still got the error 

"Thank you for your payment! Unfortunately your payment has not yet been fully processed, and you are not yet registered to enter the course "Paypal test course". Please try continuing to the course in a few seconds, but if you continue to have trouble then please alert the Teacher or the site administrator."

My transaction amount was $1.00 USD.  When the PayPal site opened, I chose the option for PayPal to get money from my checking account. Ultimately, it should work either with this method or by using a credit card (as a guest). 

So we know for sure it has nothing to do with the PayPal sandbox.

Any ideas?  I'm new to Moodle. 

In reply to Henry Quinn

Re: Moodle 3.0 and Paypal Sandbox

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Have you gone through the documentation fully and followed the setup instructions on both sides (Moodle and Paypal?).  Does Paypal show the payment as having cleared?

In reply to Henry Quinn

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Possible causes:

  • the PayPal servers cannot send data to your test installation (check your firewall and/or make your test site accessible to the world)
  • timeouts in the communication between PayPal servers and your test server.
In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by Ajay Kumar -

 Hi Renaat Debleu, 

    I am using moodle 3.X. and using sandbox paypal gateway for paid courses.  I added a course fee of 2.00 USD.

   I am getting 1.63 USD in my account.    

   After successful payment I am getting this message and not able to enroll into course.

  "Thank you for your payment! Unfortunately your payment has not yet been fully processed, and you are not yet registered to enter   the course "Friction". Please try continuing to the course in a few seconds, but if you continue to have trouble then please alert the      Teacher or the site administrator".


  Please Reply ASAP.

In reply to Ajay Kumar

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Ajay,

I tried to reproduce the error on Moodle 3.3 and indeed I see the same message.  However, if I click on the continue button, I'm immediately enrolled into the course.  Perhaps this is a temporary Paypal problem (http://downdetector.com/status/paypal/news/133197-problems-at-paypal) so further tests will be needed tomorrow to see if this is only temporary and if it is also affecting the non sandbox environment.

The amount problem is more interesting. But, are you sure you received 1.63 USD on your account?  Although the price of a course in the sandbox environment has to be USD, your test shop can have a non USD currency. So I suspect you received 1.63 local currency.  I tried to sell a test course for 2 USD and the person had to pay 1.55 EUR  (1,00 EUR = 1,29364403 USD).

I cannot believe that Paypal asks for a commission in a sandbox environment, but maybe they also want to mimic real life with exorbitant prices wink  


R

In reply to Ajay Kumar

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

MDL-57430 (https://tracker.moodle.org/browse/MDL-57430) reports the same situation.

However, In an update Keanu says

Works flawlessly IF...

* Moodle webhost is configured for HTTPS (originally mine was not).
* IPN is set up per instructions.


Is moving into HTTPS a solution for you?

In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by Armin Ysl -

i have the same Problem.


What Keanu mean with:

IPN is set up per instructions.

My Moodle Platform use still now https

In reply to Armin Ysl

Re: Moodle 3.0 and Paypal Sandbox

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

For 3 weeks already, I regularly check enrolling a student using PayPal sandbox.

When someone only quickly performs the necessary clicks in Paypal for the enrolment, the user is enrolled but redirected to the error page. However when someone takes his/her time to read the information provided by PayPal and only clicks every 3-10 seconds, this user does not see the error page and is enrolled correctly.

This second scenario is probably more accurate as most people read the screen when real money is involved (at least I do smile). Moreover, I do not see any entries related to this error in the apache log files in non-sandbox environments.

So I can only conclude that the sandbox environment is working fine in Moodle 3.3, but that our test environments and/or the PayPal sandbox are not that fast as we would prefer.  

In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by Armin Ysl -

I have the same problem whether I,
Do it quickly or slowly.
Whether I use the sandbox or a live account

In reply to Renaat Debleu

Re: Moodle 3.0 and Paypal Sandbox

by Ajay Kumar -

Hi Renaat Debleu,


 Thanks for Reply.  Its working for me now . Actually after successful payment it is taking  fraction of seconds to redirect.