Advertisement
Guest User

Untitled

a guest
Jan 9th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. FROM THE PAYPAL WEBSITE YOU STILL NEED TO LRN2PHP TO ADD YOR OWN PART TO MAKE IT WORK KTHX
  2.  
  3. // PHP 4.1
  4.  
  5. // read the post from PayPal system and add 'cmd'
  6. $req = 'cmd=_notify-validate';
  7.  
  8. foreach ($_POST as $key => $value) {
  9. $value = urlencode(stripslashes($value));
  10. $req .= "&$key=$value";
  11. }
  12.  
  13. // post back to PayPal system to validate
  14. $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  15. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  16. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  17. $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
  18.  
  19. // assign posted variables to local variables
  20. $item_name = $_POST['item_name'];
  21. $item_number = $_POST['item_number'];
  22. $payment_status = $_POST['payment_status'];
  23. $payment_amount = $_POST['mc_gross'];
  24. $payment_currency = $_POST['mc_currency'];
  25. $txn_id = $_POST['txn_id'];
  26. $receiver_email = $_POST['receiver_email'];
  27. $payer_email = $_POST['payer_email'];
  28.  
  29. if (!$fp) {
  30. // HTTP ERROR
  31. } else {
  32. fputs ($fp, $header . $req);
  33. while (!feof($fp)) {
  34. $res = fgets ($fp, 1024);
  35. if (strcmp ($res, "VERIFIED") == 0) {
  36. // check the payment_status is Completed
  37. // check that txn_id has not been previously processed
  38. // check that receiver_email is your Primary PayPal email
  39. // check that payment_amount/payment_currency are correct
  40. // process payment
  41. }
  42. else if (strcmp ($res, "INVALID") == 0) {
  43. // log for manual investigation
  44. }
  45. }
  46. fclose ($fp);
  47. }
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement