[insert_php] // Timestamp $ts = '['.date('m/d/Y g:i A').'] - '; $ipn_log_file = '/var/www/wp-admin/paypal_logs/confirm.log'; //test mode $alive = true; if ($alive) { $req = 'cmd=_notify-synch'; $tx_token = $_GET['tx']; $auth_token = "dWS5kDX4E7Jcv9TiYZROD9AurbLfClZPiIuzduiJnG6e57BiVrmFtw8Tohy"; $req .= "&tx=$tx_token&at=$auth_token"; 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.1\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Host: www.paypal.com\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n"; $header .= "Connection: close\r\n\r\n"; // If possible, securely post back to paypal using HTTPS // Your PHP server will need to be SSL enabled $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR echo ("

HTTP error

"); } else { fputs ($fp, $header . $req); // read the body data $res = ''; $headerdone = false; while (!feof($fp)) { $line = fgets ($fp, 1024); if (strcmp($line, "\r\n") == 0) { // read the header $headerdone = true; } else if ($headerdone) { // header has been read. now read the contents $res .= $line; } } $res = trim($res); // parse the data // echo ("

res= " . $res . "

"); $lines = explode("\n", $res); $keyarray = array(); // echo ("

Line1: " . $lines[1] . "

"); if (strcmp ($lines[0], "SUCCESS") == 0) { for ($i=1; $iThank you for your purchase.'); echo ("

Your transaction has been completed successfully and a receipt for your purchase and instructions how to register your license has been emailed to " . $payeremail .".

"); echo ("

If you have not received this email (please also check the spam folder) or experience any system issues, please contact us at licensing@uplinx.com.

"); echo ("

"); echo ("

"); } elseif (strcmp ($payment_status, "Pending") == 0) { // Payment pending echo('

Transaction succeeded but Paypal needs to verify the payment.

'); echo('

'); echo ("

You should receive an update by email within 12 hours."); } else { // catch all other failures echo('

Transaction not successful.

'); echo('

'); echo ("

Please contact us at licensing@uplinx.com including more details about the transaction."); $txt = "Transaction not successful."; // Write to log (must be inline) $fp=fopen($ipn_log_file,'a'); fwrite($fp, $ts . $txt . "\n\n"); fclose($fp); // close file mail($strError,"Transaction not successful.","Check Paypal",$headers); } } else if (strcmp ($lines[0], "FAIL") == 0) { // FAIL log for manual investigation echo('

Transaction failed.

'); echo('

'); echo ("

Please contact us at licensing@uplinx.com including more details about the transaction."); } else { // catch all other failures echo('

Transaction not successful!

'); echo('

'); echo ("

Please contact us at licensing@uplinx.com including more details about the transaction."); } } } else { // testmode true print('

==========test=========

'); // test mode $firstname = 'first'; $lastname= 'last'; $itemname= 'itemname'; $payeremail = 'payeremail@bla.com'; $payment_amount = '590'; echo('

Thank you for your purchase!

'); echo ("

Your transaction has been completed successfully and a receipt for your purchase and instructions how to register your license has been emailed to " . $payeremail .".

"); echo ("

If you have not received this email or experience any system issues, please contact us at licensing@uplinx.com.

"); echo ("

"); echo ("

"); echo ("

Payment Details

"); echo ("
  • Name: $firstname $lastname
  • "); echo ("
  • Item: $itemname
  • "); echo ("
  • Amount: $payment_currency $payment_amount
  • "); } [/insert_php]