IPN problem [website payments]

Discussion in 'Payment Processing' started by cosminx2003, Jul 24, 2008.

  1. #1
    Hi, i searched on forums for similar problems, i found some threads but there isn't any good answer.
    I tried to include paypal payments on my website, and i have problems with IPN file, i tried to buy something and paypal redirected me on my IPN page but it's blank.
    I tried to enter on my IPN file without paypal checkout and it's blank.

    Here is my IPN code :

    <?php
    // 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 ('www.paypal.com', 80, $errno, $errstr, 30);

    // assign posted variables to local variables
    $item_name = $_POST['item_name'];
    $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    $receiver_email = $_POST['receiver_email'];
    $payer_email = $_POST['payer_email'];

    if (!$fp) {
    echo 'http error';
    } else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {
    if (eregi($payment_status ,"Completed")) {
    echo "valid payment....";
    }
    }
    else if(strcmp ($res, "INVALID") == 0) {
    echo "invalid payment......";
    }
    }
    }
    fclose ($fp);
    }
    ?>
     
    cosminx2003, Jul 24, 2008 IP