1. Me he creado una cuenta de vendedor en el sitio de prueba y una de comprador.
2. A la de comprador le puse un balance de 200.
3. En las pruebas echas me dio que el IPN habia sido verficado correctamente.
Mi preocupacion es que ya gaste los fondos ficticios de la cuenta de comprador, y asi y todo me sigue dando que el ipn esta verificado correctamente, pero lo más extraño aun es que el balance de la cuenta de comprador sigue siendo 0.00, pero la de vendedor si se esta incrementando segun el valor puesto al supuesto producto.
Mi pregunta es ese comportmiento del sitio de prueba es correcto, o mi código esta mal? Pues nada ustedes ya me dirán, aqui les dejo mi codigo.
Este es el formulario que envia los datos
Código HTML:
<!-- Creamos el formulario para enviar a Paypal --> <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" name="f1" id="f1" method="post"> <fieldset> <legend class="prod"></legend> <input type="hidden" name="shipping" value="0"> <input type="hidden" name="cbt" value="Regresar"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="bn" value="Shopping"> <input type="hidden" name="business" value="[email protected]"> <input type="hidden" name="item_name" value="Televisor Sony"> <input type="hidden" name="item_number" value="Comprador"> <input type="hidden" name="amount" value="20"> <input type="hidden" name="custom" value="30"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="image_url" value=""> <input type="hidden" name="return" value="http://mi_server/paypal/desarrollo%20web/ipn_success.php"> <input type="hidden" name="cancel_return" value="http://mi_server/ipn_error.php"> <input type="hidden" name="no_shipping" value="0"> <input type="hidden" name="no_note" value="0"> <!-- Mostramos el detalle de la compra --> <input type="submit" name="Submit" value="Enviar"> </fieldset> </form>
Código PHP:
<?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.sandbox.paypal.com', 80, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
// echo the response
echo "The response from IPN was: <b>" .$res ."</b><br><br>";
//loop through the $_POST array and print all vars to the screen.
foreach($_POST as $key => $value){
echo $key." = ". $value."<br>";
}
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
// echo the response
echo "The response from IPN was: <b>" .$res ."</b>";
}
}
fclose ($fp);
}
?>