How do you get Moodle 2.0+ to point a PayPal transaction to the PayPal Sandbox? I tried what I found in the 1.9 docs to add a $CFG line to Moodle config.php file but that did not work. Any thoughts?
THANKS
Jim
Hi Jim,
I don't have a direct answer for your question but maybe this will help. I messed with the Paypal sandbox when I was originally setting up my Moodle site to use the enrollment. Before I found out about the automatic enrollment feature, I had tried using the PayPal buttons (which is a different approach). In order to route users to the sandbox from a Paypal button I had to create the button from the PayPal Sandbox after having to create a Buyer and Seller accounts from within the Sandbox. This worked and routed the buyer user to the Sandbox once I clicked the button and could perform the transaction, but Moodle ends up failing when Paypal tries to route them back. One of my thoughts was because if you look at the email you receive it dumps the various variables back and one has a bad status for the purchase which I think is because its coming from the Sandbox. If you want to continue working with the sandbox you might want to look at the code generated for the button to help you with routing URLs.
However I found out how to utilize the Moodle automatic enrollment which was a different approach and I didn't have to mess with the Sandbox anymore.
Good luck.
Shawn
Thanks for the post Shawn.
I can see the following line in the enrol.html file -
<?php
$paypalurl = empty($CFG->usepaypalsandbox) ? 'https://www.paypal.com/cgi-bin/webscr' : 'https://www.sandbox.paypal.com/cgi-bin/webscr';
?>
It appears to send the request to either the Sandbox or the live site. What I can't firgure out is what forces the change. It appears that when something is empty it goes to the sandbox, when it is not empty it goes to the live site. What is that SOMETHING?? Or can I just hack the line to for my requests to go to the sandbox (I could probably do that)? But I would really like to fugure out what this trigger is.
Jim
To speed things up I experimented with the $paypalurl line and removed the option to go to the sandbox or not and forced it to go to the sandbox.
$paypalurl = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
At least getting to th Sandbox is not a problem now. Seeing if the rest of the transaction works now.
Although I got the connection TO PayPal (sandbox) working I was getting the dreaded "Thank you for your payment! Unfortunately your payment has not yet been fully processed..." and pressing the Continue button (even after waiting a 10-15 seconds) made no difference. I was NOT enrolled in the course.
It appeared what he had here was "A failure to communicate" (Cool Hand Luke). In reviewing some other Moodle posts I learned that a PayPal transaction goes back and forth in a verification process. Being the Moodle noobie that I am, and not a PHP programmer, I began looking at the code to see where else the sandbox/livesite variable was listed (there seems to be something wrong in the code with selecting one or the other). I found another variable selection line pointing to either the sandbox or the live site in the ipn.php file. The line begins with $paypaladdr =. Once I removed the variable and directed the line to just the sandbox all began to work fine. (I still have not figured out what triggers that variable. So there are TWO places one needs to change this variable. At least if you are beginning your Moodle/PayPal project in the PayPal Sandbox. Here (as above) and in the enrol.php (the $paypalurl=).
Thank you Jim, you help me so much!
Sorry for my english.
I hope you have set the configuration in Site administration->plugins-> Enrolments->Manage enrol plugins->paypal->settings correctly
also if you assign $CFG->usepaypalsandbox in moodle/config.php what results you get ?
Did anyone ever get a clear answer for this issue?
I would like to use sandbox but I'm confused by this thread.
yeah, me too.
DUDES! Really! don't go posting all this "change this" "edit that" without posting HOW TO DO IT!
So, somebody says change "$paypaladdr ="
Does anybody know if this is the proper syntax?
$paypaladdr = 'www.sandbox.paypal.com';
Somebody says change config.php, it this the proper syntax?
$CFG->usepaypalsandbox = 'www.sandbox.paypal.com';
and does it go under the
$CFG->wwwroot =
$CFG->dataroot =
$CFG->admin =
And has anybody got it working?
Okay, I found out how to get the Moodle PayPal plugin to work with the PayPal Sandbox site for testing. Here we go:
Hope this helps.
For Step 6, shouldn't it be http://<yourmoodlesite.com>/online/enrol/paypal/ipn.php?
Insert Step 7a (while still in Paypal Sandbox /Profile)
+ click Language settings - choose your language and under "more Options" specify "UTF-8" as encoding and "yes" for the returning information in the same format. UTF-8 is required for final enrolment of the student into the course.
--
By the way: Notification URL as set in Step 6 (http://<yourmoodlesite.com>/enrol/paypal/ipn.php) is correct.
My url is not redirecting to http://www.sandbox.paypal.com even after i have updated my config.php. What can be the reason for this ?
Please help.. thanx in advance...
Okay, I'm stumped. I've changed my config.php to go to the sandbox, and the sandbox URL shows up in the address bar.
Logged in to PayPal with the address where the money goes. I've changed the Instant Payment Notification (IPN) URL to http://xxx.com/moodle/enrol/paypal/ipn.php, which is the full path to that file on my site (Moodle is installed in the directory /moodle at the root). I've changed the encoding to UTF-8, and use the same encoding for data sent from PayPal.
In Moodle, I click onto the PayPal button, sign into there with the fake user account that I created. That all seems flawless, but when I am taken back to my site, it still gives me the message that my payment is not fully processed.
Any other suggestions on what to look for?
Moodle 2.6
Thanks,Bill
The plot thickens.....
I worked on this for a couple more hours, with no luck. Decided to try it 'live', transferring real money ($0.01). I got the same error message that my payment wasn't processed, but if I wait for a few seconds and hit the "continue" button, it shows that I am enrolled. What's up with that? Is it normal?
Thanks,
Bill
The paypal sandbox configurations probably has been changed since Brannon Carter's post. As of now, step 1 and 2 are enough. You do not have to set up the IPN on your paypal sandbox. As a matter of fact, there are no IPN setting options anymore. There is an IPN simulator option but perhaps that is for something else as the name suggests. You do have to use your paypal developer business email address when setting up Paypal in Moodle (I am using Moodle 2.9)
Nope, It isn't work for me.
Changed all the instances but display's the error!
Please can anyone help me.
Thanks in advance.