Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo '<pre>';
- //invalid
- $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¬ify_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";
- $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