Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 798455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:58:24+00:00 2026-05-14T22:58:24+00:00

I’m implementing PayPal IPN & PDT. After some headache & time at the sandbox,

  • 0

I’m implementing PayPal IPN & PDT. After some headache & time at the sandbox, IPN is working well and PDT returns the correct $_GET data. The implementation is as follows:

  • Pass user ID in form to PayPal
  • User buys product and triggers IPN which updates database for given user ID
  • PDT returns transaction ID when user returns to site
  • The return page says “please wait” and repeat-Ajax-checks for the transaction status
  • User is redirected to success/failure page

Everything works well, EXCEPT that when using the PayPal ready PHP code for PDT to do a return POST, the page hangs. The user never gets back to my site. I’m not getting a fail status, just nothing. The funny thing is that once the unknown error occurs, my test domain becomes unresponsive for a short period.

The code (PHP): https://www.paypal.com/us/cgi-bin/webscr?cmd=p/xcl/rec/pdt-code-outside

If I comment out the POST back, it all works fine. I’m able to pin down the problem to once the code enters the while{} loop. Unfortunately, I’m not experienced enough to write a replacement from scratch for the PayPal code, so would really appreciate any ideas on what might be wrong.

The POST back goes to ssl://www.sandbox.paypal.com, and I’m using button code and an authorisation token that have all been created via a sandbox test account.

Thanks in advance.

UPDATE:

I’ve narrowed the problem down to this line: $line = fgets($fp, 1024);

It simply hangs and I’m not sure why.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:58:25+00:00Added an answer on May 14, 2026 at 10:58 pm

    RESOLVED:

    Switching to cURL solves all problems. Here’s the code in case someone comes by this and is as desperate as I was:

    // Prepare data
    $req = 'cmd=_notify-synch';
    $tx_token = $_GET['tx'];
    $auth_token = '<-- your token (sandbox or live) -->';
    $req .= '&tx='.$tx_token.'&at='.$auth_token;
    // Post back to PayPal to validate
    $c = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); // SANDBOX
    curl_setopt($c, CURLOPT_POST, true);
    curl_setopt($c, CURLOPT_POSTFIELDS, $req);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    $contents = curl_exec($c);
    $response_code = curl_getinfo($c, CURLINFO_HTTP_CODE);
    curl_close($c);
    if(!$contents || $response_code != 200) {
       // HTTP error or bad response, do something
    } else {
       // Check PayPal verification (FAIL or SUCCESS)
       $status = substr($contents, 0, 4);
       if($status == 'FAIL') {
          // Do fail stuff
       } elseif($status == 'SUCC') {
          // Do success stuff
       }
    }
    

    Technically, the substr() is not checking for “SUCCESS” but “SUCC”. However, given that only “SUCCESS” or “FAIL” are possible values, it doesn’t matter.

    This same code works for IPN as well, with the obvious minor modifications.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.