Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo '<pre>';
- //verified
- $raw_post_data="transaction_subject=&payment_date=21:31:49 Dec 28, 2017 PST&txn_type=web_accept&last_name=Panomporn&residence_country=TH&item_name=3 GigaByte Membership Upgrade&payment_gross=2.99&mc_currency=USD&business=ezako@gem-flash.com&payment_type=instant&protection_eligibility=Ineligible&verify_sign=A3vfKh1Q0f72l4jYfh5sj-PNozXJAxmTFkDx1s-Fjgl6rcgZVVcOvIN6&payer_status=unverified&payer_email=sathaporn1978@gmail.com&txn_id=9MP05434MM9782326&quantity=1&receiver_email=ezako@gem-flash.com&first_name=Sathaporn&payer_id=SEAJ6EW9RYZJ4&receiver_id=J9KM5NZ2FFD7J&item_number=&payment_status=Completed&payment_fee=0.42&mc_fee=0.42&mc_gross=2.99&custom=110843&charset=windows-1252¬ify_version=3.8&ipn_track_id=1b24f4516c1d";
- $raw_post_array = explode('&', $raw_post_data);
- $myPost = array();
- foreach ($raw_post_array as $keyval) {
- $keyval = explode ('=', $keyval);
- if (count($keyval) == 2)
- $myPost[$keyval[0]] = rawurldecode($keyval[1]);
- }
- print_r($myPost);
- $req = 'cmd=_notify-validate';
- if (function_exists('get_magic_quotes_gpc')) {
- $get_magic_quotes_exists = true;
- }
- foreach ($myPost as $key => $value) {
- if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
- $value = rawurlencode(stripslashes($value));
- } else {
- $value = rawurlencode($value);
- }
- $req .= "&$key=$value";
- }
- // Step 2: POST IPN data back to PayPal to validate
- $ch = curl_init('https://ipnpb.paypal.com/cgi-bin/webscr');
- curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
- // In wamp-like environments that do not come bundled with root authority certificates,
- // please download 'cacert.pem' from "https://curl.haxx.se/docs/caextract.html" and set
- // the directory path of the certificate as shown below:
- // curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
- if ( !($res = curl_exec($ch)) ) {
- // error_log("Got " . curl_error($ch) . " when processing IPN data");
- curl_close($ch);
- exit;
- }
- curl_close($ch);
- print_r($res);
- echo '</pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement