ich habe mir aus den released homepages die DamnedRev3_Shadow HP runtergeladen. Dort ist ein fertiges Paypal-Script bereits integriert.
Das Paypal-Button-Script (Buy-Now-Button) habe ich natürlich angepasst.
Es funktioniert insofern, dass ich die Zahlung auf meinem Paypal-Konto erhalte. Aber es wird kein Datenbankeintrag erstellt.
Nach der Zahlung soll ja eine IPN an meine homepage geschickt werden (an die payed.php). Diese php datei soll dann die daten von paypal überprüfen und in die mssql datenbank die donatepoints eintragen.
Also entweder ist mein paypalbutton falsch konfiguriert, oder das script ist falsch, oder das was paypal als bestätigung des kaufs schickt wird blockiert (ports..).
Habe die ports 80, 443 tcp freigegeben auf meinem Root.
payed.php:
Code:
<?php
include('inc/config.inc.php');
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$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";
//If testing on Sandbox use:
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
//$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed DONE
// check that txn_id has not been previously processed DONE
// check that receiver_email is your Primary PayPal email DONE
// check that payment_amount/payment_currency are correct DONE
// process payment DONE
//$checktxn = mysql_query('SELECT COUNT(*) as count FROM `'.TABLE_PREFIX.'donationlogs` WHERE `txn_id`=\''.mysql_real_escape_string($_POST['txn_id']).'\'');
odbc_exec($mssql, 'USE [WEBSITE_REV3]');
$result = odbc_exec($mssql, 'SELECT * FROM [rev3_pplogs] WHERE txn_id=\''.mysql_real_escape_string($_POST['txn_id']).'\'');
$total_rows = odbc_num_rows($result);
if($_POST['payment_status'] == 'Completed') {
$status = true;
} else {
$status = false;
}
if($total_rows == 0) {
$txn = true;
} else {
$txn = false;
}
if($_POST['receiver_email'] == $_CONFIG['ppemail']) {
$receiver = true;
} else {
$receiver = false;
}
if($_POST['mc_currency'] == 'EUR') {
$eur = true;
} else {
$eur = false;
}
$dp = $_POST['option_selection1'];
switch($dp) {
case '1200': if($_POST['mc_gross'] == '10.00') { $amount = true; }; break;
case '2500': if($_POST['mc_gross'] == '20.00') { $amount = true; }; break;
case '6500': if($_POST['mc_gross'] == '50.00') { $amount = true; }; break;
case '13000': if($_POST['mc_gross'] == '100.00') { $amount = true; }; break;
/* NORMAL
case '1000': if($_POST['mc_gross'] == '10.00') { $amount = true; }; break;
case '2000': if($_POST['mc_gross'] == '20.00') { $amount = true; }; break;
case '5250': if($_POST['mc_gross'] == '50.00') { $amount = true; }; break;
case '11000': if($_POST['mc_gross'] == '100.00') { $amount = true; }; break;
*/
default: $amount = false; break;
}
if(($status == true) && ($txn == true) && ($receiver == true) && ($eur == true) && ($amount == true)) {
$worth = $_POST['mc_gross'];
$worth = str_replace('.', ',', $_POST['mc_gross']);
odbc_exec($mssql, 'USE [WEBSITE_REV3]');
odbc_exec($mssql, 'INSERT INTO [rev3_pplogs] (txn_id, account, worth, email, datetime) VALUES(\''.mssql_escape_string($_POST['txn_id']).'\', \''.mssql_escape_string($_POST['option_selection2']).'\', \''.mssql_escape_string($worth).'\', \''.mssql_escape_string($_POST['payer_email']).'\', \''.date('d.m.Y H:i:s').'\')');
odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET cash=cash+\''.mssql_escape_string($dp).'\' WHERE account=\''.mssql_escape_string($_POST['option_selection2']).'\'');
}
// echo the response
echo "The response from IPN was: <b>" .$res ."</b><br><br>";
//loop through the $_POST array and print all vars to the screen.
foreach($_POST as $key => $value){
echo $key." = ". $value."<br>";
}
} else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigationk
// echo the response
echo "The response from IPN was: <b>" .$res ."</b>";
}
}
fclose ($fp);
}
?>
Hier ist noch ein anderes Paypal Script, welches einfach nur die Daten, die paypal sendet, ausgeben soll. Dies hat auch nicht ganz funktioniert.
Code:
<?php
$pp_hostname = "www.paypal.com"; // Change to [url]www.sandbox.paypal.com[/url] to test against sandbox
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "uz14k8H0gpDXY_Xhjc2j_b_c8pwNajYmbWc4pcRDrBrb31kezIz-YpNUdi";
$req .= "&tx=$tx_token&at=$auth_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
//set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
//if your server does not bundled with default verisign certificates.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
$res = curl_exec($ch);
curl_close($ch);
if(!$res){
//HTTP ERROR
}else{
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
echo ("<p><h3>Thank you for your purchase!</h3></p>");
echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}
}
?>
Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br> You may log into your account at <a href='https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br>






