Tema: paypal y php
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/12/2006, 09:29
tico74
 
Fecha de Ingreso: diciembre-2002
Mensajes: 473
Antigüedad: 21 años, 4 meses
Puntos: 0
Re: paypal y php

Gracias por responder GatorV.En realidad, es que probe varios codigos.Todo se da bien hasta que recibo (con auto reenvio ) a mi pagina.
Otro tema que me confunde es el codigo de token. No recuerdo bien cuando pero en la interfaz 'real' de paypal se me genero al hacer algun cambio. Pero ahora no se como generarlo, y en sandbox veo que no se puede crear.
-------------------------------------------------
El ultimo codigo que probe es este:
//no se bien de donde sacar $auth_token, probe con el anterior que usaba en forma real pero en sandbox no se cual ira

// Getting the authorization of PDT

$auth_token = "xxxxxxx";


// read the post from PayPal system and add 'cmd'
$PDTPost = 'cmd=_notify-synch';

// appending the 'tx' variable that was returned by paypal
$tx_token = $_GET['tx'];
$PDTPost .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header = '';
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($PDTPost) . "\r\n\r\n";

// fetching the PDT post URL
$PDTPostURL = 'www.sandbox.paypal.com';

// sending the data to the paypal
$fp = fsockopen ($PDTPostURL, 80, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
echo("error");
}
else {
echo("ok");
fputs ($fp, $header . $PDTPost);

// read the body data
$res = '';
$headerdone = false;

while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone){
// header has been read. now read the contents
$res .= $line;
}
}
// parse the data in array form
$lines = explode("\n", $res);
$tokensArray = array();

// If PDT is successful then only proceesd to success page
if (strcmp ($lines[0], "SUCCESS") == 0) {

//actuo con base de datos
echo("actuo con base de datos<br>");
echo($res."<br>");
}else{
//actuo con base de datos
echo("No actuo con base de datos<br>");
echo($res."<br>");
}
}//cierro gran if

-------------------------------------------------
Y me aparece:
ERROR
The requested URL could not be retrieved

--------------------------------------------------------------------------------

While trying to retrieve the URL: http://64.202.165.201/cgi-bin/webscr

The following error was encountered:

Connection Failed
The system returned:

(111) Connection refusedThe remote host or network may be down. Please try the request again.

Your cache administrator is webmaster.



--------------------------------------------------------------------------------

Generated Tue, 19 Dec 2006 16:21:28 GMT by wc04.inet.mesa1.secureserver.net (squid/2.5.STABLE12) Puede haber algo mal?

Última edición por tico74; 19/12/2006 a las 10:24