PHP interesse |
|
Voor paypal heb ik na veel werk eindelijk het betaal systeem af. Nu wil ik alleen nog dat na een betaling een verificatie wordt gemaakt en bij een succesvolle betaling een update in mijn database plaats vindt.
Het probleem is echter dat ik dit gedeelte niet volledig werkende krijg.
Wellicht iemand enig idee hoe ik na een succesvolle betaling de volgende update werkende krijg?
mysql_query("UPDATE `users` SET `callcredits`=`callcredits`+'30' WHERE `login`='$data->login'");
mysql_query("UPDATE `users` SET `callcredits`=`callcredits`+'30' WHERE `login`='$data->login'");
Script:
<?php
/*
Simple IPN processing script
based on code from the "PHP Toolkit" provided by PayPal
mysql_query("UPDATE `users` SET `callcredits`=`callcredits`+'30' WHERE `login`='$data->login'");
*/
include("../settings.php");
if(!(@mysql_connect("$host","$user","$pass") && @mysql_select_db("$tablename"))) {echo"Geen verbinding gevonden";}
include("../../language/dutch.php");
$url = 'https://www.paypal.com/cgi-bin/webscr';
$postdata = '';
foreach($_POST as $i => $v) {
$postdata .= $i.'='.urlencode($v).'&';
}
$postdata .= 'cmd=_notify-validate';
$web = parse_url($url);
if ($web['scheme'] == 'https') {
$web['port'] = 443;
$ssl = 'ssl://';
} else {
$web['port'] = 80;
$ssl = '';
}
$fp = @fsockopen($ssl.$web['host'], $web['port'], $errnum, $errstr, 30);
if (!$fp) {
echo $errnum.': '.$errstr;
} else {
fputs($fp, "POST ".$web['path']." HTTP/1.1\r\n");
fputs($fp, "Host: ".$web['host']."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($postdata)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $postdata . "\r\n\r\n");
while(!feof($fp)) {
$info[] = @fgets($fp, 1024);
}
fclose($fp);
$info = implode(',', $info);
if (eregi('VERIFIED', $info)) {
// yes valid, f.e. change payment status
} else {
// invalid, log error or something
}
}
?>
<?php /* Simple IPN processing script based on code from the "PHP Toolkit" provided by PayPal mysql_query("UPDATE `users` SET `callcredits`=`callcredits`+'30' WHERE `login`='$data->login'"); */ include("../settings.php"); include("../../language/dutch.php"); $url = 'https://www.paypal.com/cgi-bin/webscr'; $postdata = ''; foreach($_POST as $i => $v) { } $postdata .= 'cmd=_notify-validate'; if ($web['scheme'] == 'https') { $web['port'] = 443; $ssl = 'ssl://'; } else { $web['port'] = 80; $ssl = ''; } $fp = @fsockopen($ssl.$web['host'], $web['port'], $errnum, $errstr, 30); if (!$fp) { echo $errnum.': '.$errstr; } else { fputs($fp, "POST ".$web['path']." HTTP/1.1\r\n"); fputs($fp, "Host: ".$web['host']."\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ".strlen($postdata)."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $postdata . "\r\n\r\n"); $info[] = @fgets($fp, 1024); } if (eregi('VERIFIED', $info)) { // yes valid, f.e. change payment status } else { // invalid, log error or something } } ?>
|