<p><?php print_string("paymentrequired") ?></p>
<p><b><?php echo get_string("cost").": $CFG->enrol_currency $cost"; ?></b></p>
<p><?php print_string("paymentinstant") ?></p>
-
-<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
+<?php
+ $paypalurl = empty($CFG->usepaypalsandbox) ? 'https://www.paypal.com/cgi-bin/webscr' : 'https://www.sandbox.paypal.com/cgi-bin/webscr';
+?>
+<form action="<?php echo $paypalurl ?>" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php p($CFG->enrol_paypalbusiness)?>">
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
- $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
+ $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
echo "<p>Error: could not access paypal.com</p>";