Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/04/2012, 07:02
IEKK
 
Fecha de Ingreso: agosto-2010
Ubicación: Tenerife
Mensajes: 893
Antigüedad: 13 años, 9 meses
Puntos: 202
problema con las IPN

Llevo ya un rato sin entender que pasa. El problema es que consigo realizar el pago, se le restan las cantidades a quien compra y aumenta quien vende, sin embargo con las IPN no hay forma (momentáneamente lo hago mediante sandbox con el típico Test Accounts)

ya lo he hecho otras veces con otros ecommerce pero aquí me estoy quedando

Además en el sandbox aparece perfectamente:
IPN successfully sent. al poner la url del listener.

El script es el propio que proporciona paypal en la documentación tecnica.
¿Puede deberse a tenerlo alojado por ahora en un server gratuito y que este impida el fsockopen? ¿o es problema del script?
Si fuera que no entra simplemente en la función mail... pero he cambiado eso por escribir en un archivo y tampoco.

Cualquier ayuda/consejo es bienvenido
¿Alguien acostumbrado a los ecommerce?

Dejo el script por si acaso haya algo que se me escapase

Código PHP:
<?php 
        
    error_reporting
(E_ALL E_NOTICE); 
    
$email $_GET['ipn_email']; 
    
$header ""$emailtext "";
    
    
// Read the post from PayPal and add 'cmd'
    
$req 'cmd=_notify-validate';
    if(
function_exists('get_magic_quotes_gpc')) {  $get_magic_quotes_exists true; } 

    
// Handle escape characters, which depends on setting of magic quotes
    
foreach ($_POST as $key => $value)
    {
        if(
$get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1)
        {
            
$value urlencode(stripslashes($value));
        } 
        else
        {     
            
$value urlencode($value); 
        }
        
$req .= "&$key=$value";
    } 
    
    
// Post back to PayPal 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);
    
    
$fp fsockopen ('ssl://www.sandbox.paypal.com'443$errno$errstr30);
    
// Process validation from PayPal // TODO: This sample does not test the HTTP response code. All 
    // HTTP response codes must be handled or you should use an HTTP 
    // library, such as cUrl 
    
if (!$fp)
    { 
        
// HTTP ERROR
        //escribimos en un archivo
        
if( $fp fopen('comments.dat','w') ){
            
fwrite($fp'fallo q t pego'.PHP_EOL);
            
fclose($fp);
        }        
    } 
    else
    { 
            
// NO HTTP ERROR 
        
fputs ($fp$header $req);
            
        while (!
feof($fp)) { 
            
$res fgets ($fp1024);
            if (
strcmp ($res"VERIFIED") == 0)
            {     
                
// TODO:     
                // 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
                // If 'VERIFIED', send an email of IPN variables and values to the     
                // specified email address
                    
                
foreach ($_POST as $key => $value){
                    
$emailtext .= $key " = " .$value ."\n\n";
                }
                    
                
//mail($email, "Live-VERIFIED IPN", $emailtext . "\n\n" . $req);
                
mail('[email protected]'"Live-VERIFIED IPN"$emailtext "\n\n" $req);    
            }
            else if (
strcmp ($res"INVALID") == 0)
            {     
                
// If 'INVALID', send an email. TODO: Log for manual investigation.     
                
foreach ($_POST as $key => $value){
                    
$emailtext .= $key " = " .$value ."\n\n";
                }     
                
//mail($email, "Live-INVALID IPN", $emailtext . "\n\n" . $req);
                
mail('[email protected]'"Live-INVALID IPN"$emailtext "\n\n" $req);
             }
        }
    } 
    
fclose ($fp);
?>
__________________
Pensaba que internet era una gran biblioteca de sabiduría, hasta que comprendí que un libro no puede tener mil páginas llenas de faltas de ortografía... :(