11.02 php
the_undefined
Note
the_undefined did not leave a note
  1. <?php
  2.  
  3. require_once('S3.php');
  4. $options = array(
  5.     'from' => 'billing@debuggable.com'
  6. );
  7.  
  8. $req = 'cmd=_notify-validate';
  9. $req = $req.'&'.http_build_query($_POST);
  10.  
  11.  
  12. // post back to PayPal system to validate
  13. $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  14. $header .= "Host: www.paypal.com:443\r\n";
  15. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  16. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  17.  
  18. $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
  19.  
  20. // assign posted variables to local variables
  21. $item_name = $_POST['item_name'];
  22. $item_number = $_POST['item_number'];
  23. $payment_status = $_POST['payment_status'];
  24. $payment_amount = $_POST['mc_gross'];
  25. $payment_currency = $_POST['mc_currency'];
  26. $txn_id = $_POST['txn_id'];
  27. $receiver_email = $_POST['receiver_email'];
  28. $payer_email = $_POST['payer_email'];
  29. $payment_date = $_POST['payment_date'];
  30.  
  31. //set email variables
  32. $From_email = "From: billing@debuggable.com";
  33. $Subject_line = "Payment Receipt";
  34.  
  35. $s3 = new S3('secret', 'secret');
  36. $url = $s3->getAuthenticatedURL('git-vook', 'screencasts/1_resolving_merge_conflicts.mov.zip', strtotime('48 hours')-time());
  37.  
  38. $email_msg = sprintf("Thanks for purchasing the item \"%s\" for %s %s. I hope you will like it.", $item_name, $payment_amount, $payment_currency);
  39. $email_msg .= "\n\nIn order to download the screencast, please visit:";
  40. $email_msg .= "\n\n".$url;
  41. $email_msg .= "\n\nPurchase Information:";
  42. $email_msg .= "\n\n" . "Transaction ID: "$txn_id ;
  43. $email_msg .= "\n" . "Payment Date: " . $payment_date;
  44. $email_msg .= "\n\nThe download link will expire in 48 hours. If you lost your copy of a screencast, please visit git.debuggable.com for instructions.";
  45. $email_msg .= "\n\nDebuggable Limited";
  46. $email_msg .= "\nHibiskusweg 26c";
  47. $email_msg .= "\n13089 Berlin";
  48. $email_msg .= "\n\nVAT ID: 1129/266/00830";
  49. $email_msg .= "\nEntry in the commercial register: HRB 112594 B (at the local court of Charlottenburg Berlin)";
  50.  
  51. $emailHeaders = array('From: '.$options['from']);
  52. $emailHeaders = join("\n", $emailHeaders);
  53.  
  54. $dump = "Request Dump:\n\n".print_r($_POST, true);
  55. if (!$fp) {
  56.     mail('felix@debuggable.com', 'HTTP Error (PayPal IPN)', $dump, $emailHeaders);
  57.     exit;
  58. }
  59.  
  60. fputs($fp, $header.$req);
  61. $res = null;
  62. while(!feof($fp)) {
  63.     $res = $res.fgets($fp, 1024);
  64. }
  65.  
  66. if (!preg_match('/VERIFIED$/', $res)) {
  67.     mail('felix@debuggable.com', 'Unverified Transaction (PayPal IPN)', "Response: ".$res."\n\n"."Request:".$req."\n\n".$dump, $mail_From);
  68.     exit;
  69. }
  70. fclose($fp);
  71.  
  72. mail($payer_email, 'Download Link for: "'.$item_name.'"', $email_msg, $emailHeaders);
  73. mail('felix@debuggable.com', 'You made money with: "'.$item_name.'"', $email_msg, $emailHeaders);
  74.  
  75. $purchases = file_get_contents('purchases.txt');
  76. if (!$purchases) {
  77.     $purchases = null;
  78. }
  79. $purchases = $purchases.$payment_date."\t".$payer_email."\t".$payment_amount." ".$payment_currency."\n";
  80. file_put_contents('purchases.txt', $purchases);
  81.  
  82. ?>
Parsed in 0.218 seconds, using GeSHi 1.0.7.14

Modify this Paste