What the different: PayPal Sandbox & PayPal Live? IPN

Discussion in 'PHP' started by wnetwork, Oct 17, 2009.

  1. #1
    The question said it.

    The IPN works great when I use the Sandbox to test my *automatic* online digital (download-able) store system or more like marketplace. No error. No problem.
    $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
    PHP:
    https://www.sandbox.paypal.com/cgi-bin/webscr
    Code (markup):

    So then it should works LIVE, right? NOPE!
    When buyers reach the final page, they get an error.
    Yes I did switch sandbox to LIVE:
    $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
    PHP:
    https://www.paypal.com/cgi-bin/webscr
    Code (markup):
    So what is the problem? Why can't PayPal LIVE works IF the PayPal Sandbox works?
    I spent hours, days searching for the answer but can't seem to find one.
     
    wnetwork, Oct 17, 2009 IP
  2. wnetwork

    wnetwork Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    Using the IPN Check i found on the net:

     
    wnetwork, Oct 17, 2009 IP
  3. kingsoflegend

    kingsoflegend Well-Known Member

    Messages:
    202
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #3
    I'd say the post parameters aren't passed correctly to your script.

    It would help if you'd tell us what the error is...
     
    kingsoflegend, Oct 18, 2009 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think it might be an fsockopen issue. I saw something similar on here not so long ago, and it was because they were using fsockopen instead of cURL
     
    JAY6390, Oct 18, 2009 IP
  5. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    sounds like the story of my life - maybe you need a fresh pair of eyes to look over your script, it's always something you did wrong that you just skim over because you expect it to be correct, which is the problem.

    if not, try using stream_socket_client instead of fsockopen.

    btw, are you running the sandbox and the live versions of your script(s) on the same host?
     
    szalinski, Oct 18, 2009 IP
  6. wnetwork

    wnetwork Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Well- not sure exactly what the 'error' is.. when a buyer come back to the website page after paying thru PayPal, they get the invalid transaction error.
    So they hit the 'INVALID' part of the IPN script.

    else if (strcmp ($res, "INVALID") == 0) {
    // log for manual investigation
    $subject = "Transaction failed! *PayPal*";
    $msg = "Transaction failed *PayPal*  Wrong paypal payee information or someone try to make fake payment.";
    mail($adminmail, $subject, $msg, $adminmail);
    include("invalid.php");
    PHP:
    The IPN code is from PayPal:
    https://cms.paypal.com/cms_content/US/en_US/files/developer/IPN_PHP_41.txt
     
    wnetwork, Oct 18, 2009 IP
  7. wnetwork

    wnetwork Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    Yeah I heard from PayPalDeveloper.com, cURL is recommended but I can use fsockopen with no problem when using sandbox.
    I might try using cURL.
     
    wnetwork, Oct 18, 2009 IP
  8. wnetwork

    wnetwork Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #8
    I use WinMerge to compare two files (one for sandbox & one for live) so that I don't miss something or overwrite codes.

    Yes I am running both sandbox and live files on my host/domain.
     
    wnetwork, Oct 18, 2009 IP
  9. swiftnomad

    swiftnomad Active Member

    Messages:
    185
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    50
    #9
    :) Well, I'm not sure if you're doing this or not but make sure you're logged into the developers area when testing.
     
    swiftnomad, Oct 18, 2009 IP
  10. wnetwork

    wnetwork Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #10
    #1- I finally able to code the cURL php file. At first, when I made test purchases through Sandbox, orders were not going through, no emails, etc. I went to Google to search and found a website that talked about IPN problem and it mentioned about PayPal required values. See #2.

    #2- PayPal MUST have required values (for IPN) to pass *back and forth* to my final/IPN page. I noticed there were 1 or 2 required values missing so I added those missing fields/values. Now it seem to be working in TESTING mode (Sandbox). See here-> http://www.web-development-blog.com/archives/easy-payments-using-paypal-ipn/

    I haven't tried it LIVE yet. Will do it tomorrow.
     
    wnetwork, Oct 18, 2009 IP