1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Paypal IPN problem

Discussion in 'PHP & Perl' started by crazymonster, Nov 12, 2013.

  1. crazymonster

    crazymonster Junior Member

    Joined:
    Apr 8, 2011
    Messages:
    132
    Likes Received:
    20
    Home Page:
    Payment is fine. Paypal IPN History shows ?Sent?

    When payment is done and paypal back me to my success page, received firefox bug:

    Although this page is encrypted, the information you have entered is to be sent over an unencrypted connection and could easily be read by a third party.

    Are you sure you want to continue sending this information?

    When I click "continue", Paypal send request to ipn.php
    ipn.php doesn't create ipn_errors.log , maybe hosting doesnt allow ...

    But ipn.php doesn't work, because MySql doesn't update. It's posible $verified variable to be empty?

    I used for guide:
    https://github.com/Quixotix/PHP-PayPal-IPN
     
  2. hardc0der

    hardc0der BANNED BANNED

    Joined:
    Dec 13, 2013
    Messages:
    130
    Likes Received:
    27
    <?php


    mysql_connect("localhost", "user", "password") or die(mysql_error());
    mysql_select_db("PayPal") or die(mysql_error());


    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
    }
    // post back to PayPal system to validate
    $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";


    $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
    if (!$fp) {
    // HTTP ERROR
    } else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {


    // PAYMENT VALIDATED & VERIFIED!


    }


    else if (strcmp ($res, "INVALID") == 0) {


    // PAYMENT INVALID & INVESTIGATE MANUALY!


    }
    }
    fclose ($fp);
    }
    ?>


    maybe it helps you.