Advertisement
ezako

test55.php

Dec 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.44 KB | None | 0 0
  1. <?php
  2.  
  3. echo '<pre>';
  4.  
  5. //invalid
  6. $raw_post_data="mc_gross=2.99&protection_eligibility=Ineligible&payer_id=49TRUPBDPZRBW&payment_date=12:45:00 Dec 28, 2017 PST&payment_status=Completed&charset=windows-1252&first_name=Tzipora&mc_fee=0.42&notify_version=3.8&custom=52999&payer_status=verified&business=ezako@gem-flash.com&quantity=1&verify_sign=AcVwQ1MBEG9u3-oDIfA2oMh3nWliAXTifSNfOZFI1u4LhOtfL3EFaA2g&payer_email=tzippy15@gmail.com&txn_id=118279623E0251219&payment_type=instant&payer_business_name=SK&C&last_name=Miller&receiver_email=ezako@gem-flash.com&payment_fee=0.42&shipping_discount=0.00&receiver_id=J9KM5NZ2FFD7J&insurance_amount=0.00&txn_type=web_accept&item_name=3 GigaByte Membership Upgrade&discount=0.00&mc_currency=USD&item_number=&residence_country=US&shipping_method=Default&transaction_subject=&payment_gross=2.99&ipn_track_id=c63291fc8e2c5";
  7.  
  8. $raw_post_array = explode('&', $raw_post_data);
  9. $myPost = array();
  10. foreach ($raw_post_array as $keyval) {
  11.   $keyval = explode ('=', $keyval);
  12.   if (count($keyval) == 2)
  13.     $myPost[$keyval[0]] = rawurldecode($keyval[1]);
  14. }
  15.  
  16. print_r($myPost);
  17.  
  18. $req = 'cmd=_notify-validate';
  19. if (function_exists('get_magic_quotes_gpc')) {
  20.   $get_magic_quotes_exists = true;
  21. }
  22. foreach ($myPost as $key => $value) {
  23.   if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
  24.     $value = rawurlencode(stripslashes($value));
  25.   } else {
  26.     $value = rawurlencode($value);
  27.   }
  28.   $req .= "&$key=$value";
  29. }
  30.  
  31. // Step 2: POST IPN data back to PayPal to validate
  32. $ch = curl_init('https://ipnpb.paypal.com/cgi-bin/webscr');
  33. curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  34. curl_setopt($ch, CURLOPT_POST, 1);
  35. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  36. curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
  37. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  38. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  39. curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
  40. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
  41. // In wamp-like environments that do not come bundled with root authority certificates,
  42. // please download 'cacert.pem' from "https://curl.haxx.se/docs/caextract.html" and set
  43. // the directory path of the certificate as shown below:
  44. // curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
  45. if ( !($res = curl_exec($ch)) ) {
  46.   // error_log("Got " . curl_error($ch) . " when processing IPN data");
  47.   curl_close($ch);
  48.   exit;
  49. }
  50. curl_close($ch);
  51.  
  52. print_r($res);
  53.  
  54.  
  55. echo '</pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement