PayPal
tim
- php
Hallo
sitz zum glück in der ersten etage, sonst hätt ich mein rechner schon zum fenster raus geschmissen - lohnt sich aber noch nicht.
und zwar::: bin grad dabei folgendes zu realisieren:
schritt 1: klick auf "Jetzt kaufen" Schaltfläche von PayPal schritt 2: bezahldaten senden.
bis hier noch alles ok.
schritt 3: es soll ein kostenpflichtiges formular aufgerufen werden, dass jeweils nur einmal pro bezahlung geöffnet werden kann.
paypal liefert ja einen tollen token zurück, womit man das überprüfen kann - aber scheiße is!
in der theorie lässt sich das script testen. es liefert nach der bezahlung auch werte zurück. in der paypal umgebung bleibt die seite jedoch leer und ich kann das token nicht überprüfen!!! schöne scheiße!
hier die links:
paychecker.de/test/test.php (PHP Check) paychecker.de/test/paypal.php (kann unter http://www.belahost.com/pp/ getestet werden)
<?php #1 = Live on PayPal Network 2 = Testing with BelaHost.com $verifymode = "2"; # be sure to change value for testing/live!
$send_mail_to = "sandbox5@paychecker.de";
$sysname = "Paypal IPN Transaction";
$paypal_email = "sandbox5@paychecker.de";
$mailpath = "/usr/sbin/sendmail -t";
#the name you wish to see the messages from $from_name = "PAYCHECKER";
#the emails will be coming from $from_email = "info@paychecker.de";
if(phpversion() <= "4.0.6") { $_POST= ($HTTP_POST_VARS); }
if (!$_POST['txn_type']) {header("Status: 404 Not Found");exit; } else { header("Status: 200 OK"); }
$postvars = array();
foreach ($_POST as $ipnvars => $ipnvalue) $postvars[] = $ipnvars;
$postipn = 'cmd=_notify-validate'; # Now we ADD "cmd=_notify-validate" for Post back Validation $orgipn = '<b>Posted IPN variables in order received:</b><br><br>'; # Prepare for validation for ($x=0; $x < count($postvars); $x++) { $y=$x+1; $postkey = $postvars[$x]; $postval = $$postvars[$x]; $postipn.= "&" . $postkey . "=" . urlencode($postval); $orgipn.= "<b>#" . $y . "</b> Key: " . $postkey . " <b>=</b> " . $postval . "<br>"; }
if ($verifymode == 1) { $port = fsockopen ("sandbox.paypal.com", 80, $errno, $errstr, 30); $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"."Host: www.sandbox.paypal.com\r\n"."Content-Type: application/x-www-form-urlencoded\r\n"."Content-Length: " . strlen($postipn) . "\r\n\r\n"; }
elseif ($verifymode == 2) { $port = fsockopen ("www.belahost.com", 80, $errno, $errstr, 30); $header = "POST /pp/ HTTP/1.0\r\n"."Host: www.belahost.com\r\n"."Content-Type: application/x-www-form-urlencoded\r\n"."Content-Length: " . strlen($postipn) . "\r\n\r\n"; } else { $error=1; echo "CheckMode: " . $verifymode . " is invalid!"; exit; }
if (!$port && !$error) { echo "Problem: Error Number: " . $errno . " Error String: " . $errstr; send_mail("$send_mail_to", "$sysname", "\nYour Paypal System failed due to $errno and string $errstr \n"); exit; }
else { fputs ($port, $header . $postipn); while (!feof($port)) { $reply = fgets ($port, 1024); $reply = trim ($reply); }
$ipnreport = $orgipn . "<br><b>" . "IPN Reply: " . $reply . "</b>";
$business = $_POST['business']; $receiver_email = $_POST['receiver_email']; $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $quantity = $_POST['quantity']; #Advanced and Custom information $invoice = $_POST['invoice']; $custom = $_POST['custom']; $memo = $_POST['memo']; $tax = $_POST['tax']; $option_name1 = $_POST['option_name1']; $option_selection1 = $_POST['option_selection1']; $option_name2 = $_POST['option_name2']; $option_selection2 = $_POST['option_selection2'];
$num_cart_items = $_POST['num_cart_items'];
$payment_status = $_POST['payment_status']; $pending_reason = $_POST['pending_reason']; $reason_code = $_POST['reason_code']; $payment_date = $_POST['payment_date']; $txn_id = $_POST['txn_id']; $txn_type = $_POST['txn_type']; $payment_type = $_POST['payment_type'];
$mc_gross = $_POST['mc_gross']; $mc_fee = $_POST['mc_fee']; $mc_currency = $_POST['mc_currency']; $settle_amount = $_POST['settle_amount']; $settle_currency = $_POST['settle_currency']; $exchange_rate = $_POST['exchange_rate']; $payment_gross = $_POST['payment_gross']; $payment_fee = $_POST['payment_fee'];
$for_auction = $_POST['for_auction']; $auction_buyer_id = $_POST['auction_buyer_id']; $auction_closing_date = $_POST['auction_closing_date']; $auction_multi_item = $_POST['auction_multi_item'];
$first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $address_name = $_POST ['address_name']; $address_street = $_POST['address_street']; $address_city = $_POST['address_city']; $address_state = $_POST['address_state']; $address_zip = $_POST['address_zip']; $address_country = $_POST['address_country']; $address_status = $_POST['address_status']; $payer_email = $_POST['payer_email']; $payer_id = $_POST['payer_id']; $payer_status = $_POST['payer_status'];
$notify_version = $_POST['notify_version']; $verify_sign = $_POST['verify_sign']; $subscr_date = $_POST['subscr_date']; $subscr_effective = $_POST['subscr_effective']; $period1 = $_POST['period1']; $period2 = $_POST['period2']; $period3 = $_POST['period3']; $amount1 = $_POST['amount1']; $amount2 = $_POST['amount2']; $amount3 = $_POST['amount3']; $mc_amount1 = $_POST['mc_amount1']; $mc_amount2 = $_POST['mc_amount2']; $mc_amount3 = $_POST['mc_amount3']; $recurring = $_POST['recurring']; $reattempt = $_POST['reattempt']; $retry_at = $_POST['retry_at']; $recur_times = $_POST['recur_times']; $username = $_POST['username']; $password = $_POST['password']; $subscr_id = $_POST['subscr_id'];
if (!strcmp ($reply, "VERIFIED")) {
/* Now that IPN was VERIFIED below are a few things which you may want to do at this point.
echo $ipnreport; send_mail("$send_mail_to", "$sysname", "\n Verified IPN Transaction\n \n$ipnreport\n"); }
elseif (!strcmp ($reply, "INVALID")) {
/* Now that IPN was INVALID below are a few things which you may want to do at this point.
echo $ipnreport; send_mail("$send_mail_to", "$sysname", "\n IN Valid IPN Transaction\n \n$ipnreport\n"); }
else {
echo $ipnreport; send_mail("$send_mail_to", "$sysname", "\n FATAL ERROR No Reply at all\n \n$ipnreport\n"); }
fclose ($port); exit; }
/* ================================= Below are functions ================================= */
function send_mail($to, $subj, $body) { global $from_name, $from_email, $mailpath;
$announce_subject = "$subj"; $announce_from_email = "$from_email"; $announce_from_name = "$from_name"; $announce_to_email = "$to"; $MP = "$mailpath"; $spec_envelope = 1;
if(isset($spec_envelope)) { $MP .= " -f $announce_from_email"; } $fd = popen($MP,"w"); fputs($fd, "To: $announce_to_email\n"); fputs($fd, "From: $announce_from_name <$announce_from_email>\n"); fputs($fd, "Subject: $announce_subject\n"); fputs($fd, "X-Mailer: MyPayPal_Mailer\n"); fputs($fd, "Content-Type: text/html\n"); fputs($fd, $body); # $body will be sent when the function is used pclose($fd); } /******************************************************** * THIS SCRIPT IS FREEWARE AND IS NOT FOR RE-SALE * * If you would like to have a custom script written * * for you contact http://www.belahost.com/contact.php * ********************************************************/
?>