2011-12-15 11 views
5

Dopo molte ore di incasinare e tentare di impostare quale dovrebbe essere il processo relativamente semplice di inviare un pagamento a www.sandbox.paypal.com e di essere reindirizzati a una pagina del mio sito con una transazione id in the querystring, l'ho finalmente raggiunto.Paypal errore PDT 4003

Ora ricevo un messaggio di errore "FAIL Error 4003".

Ecco il codice che sto usando. E 'praticamente la stessa come l'esempio PayPal (tutto ciò che ho fatto è eco le risposte):

<?php 
// read the post from PayPal system and add 'cmd' 
$req = 'cmd=_notify-synch'; 

$tx_token = $_GET['tx']; 

$auth_token = "ZdoN6q4GLiRniR2BbOzEEF22GJOWHpVOXRtP7fAhBpvwwm5GyWcTzO_sSSO"; 
$req .= "&tx=$tx_token&at=$auth_token"; 

// 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); 
// If possible, securely post back to paypal using HTTPS 
// Your PHP server will need to be SSL enabled 
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); 

if (!$fp) 
{ 
    // HTTP ERROR 
    echo "HTTP Error"; 
} 
else 
{ 
    fputs ($fp, $header . $req); 
    // 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; 
      echo $line; 
     } 
    } 

     // parse the data 
     $lines = explode("\n", $res); 
     $keyarray = array(); 
     if (strcmp ($lines[0], "SUCCESS") == 0) 
     { 
      for ($i=1; $i<count($lines);$i++) 
      { 
       list($key,$val) = explode("=", $lines[$i]); 
       $keyarray[urldecode($key)] = urldecode($val); 
      } 
      // 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 
      $firstname = $keyarray['first_name']; 
      $lastname = $keyarray['last_name']; 
      $itemname = $keyarray['item_name']; 
      $amount = $keyarray['payment_gross']; 

      echo ("<p><h3>Thank you for your purchase!</h3></p>"); 
      echo ("<b>Payment Details</b><br>\n"); 
      echo ("<li>Name: $firstname $lastname</li>\n"); 
      echo ("<li>Item: $itemname</li>\n"); 
      echo ("<li>Amount: $amount</li>\n"); 
      echo (""); 
     } 
     else if (strcmp ($lines[0], "FAIL") == 0) { 
      echo "Failure: " . $lines[0]; 
      // log for manual investigation 
     } 

} 

fclose ($fp); 

?> 
<br /> 
Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you. You may log into your account at <a href="http://www.sandbox.paypal.com/ie">www.sandbox.paypal.com/ie</a> to view details of this transaction. 

ho fatto in modo di confermare gli indirizzi email per entrambi i miei conti commerciante e acquirente sandbox e attivato PDT.

Il cliente viene reindirizzato correttamente di nuovo al mio 'grazie' pagina con il seguente paramaters querystring - ?tx=4FU63684496248523&st=Pending&amt=29.90&cc=EUR&cm=&item_number=

Qualcun altro ha incontrato questo messaggio di errore? Se sì, quali sono le solite cause?

+0

realtà ho chiamato paypal su tale errore e mi hanno dato una risposta criptica, dicendo che l'errore viene da alcuni errori di configurazione nel mio carrello (sto usando ubercart). Non molto utile a tutti ... – Jukebox

+1

Ecco un'altra FAQ da inserire nel mix: https://ppmts.custhelp.com/app/answers/detail/a_id/13 – Jukebox

+1

Sto usando un semplice modulo per inviare la richiesta di pagamento a paypal e sto effettivamente usando il proprio codice per elaborare la risposta. Ho sviluppato siti web e applicazioni per un tempo abbastanza lungo ma sono riuscito a stare alla larga da paypal per la maggior parte del tempo. Sono sbalordito di quanto sia pessima la loro documentazione, la configurazione dei test e il servizio generale. – TGuimond

risposta

6

Il problema era che stavo inviando la mia richiesta http di test a paypal.com piuttosto che a sandbox.paypal.com. La risposta era nelle FAQ lasciate da Jukebox.

Controllare il test dei dati del pagamento Trasferimento script.When (PDT) nella Sandbox, assicurarsi che i PDT POST di script schiena informazioni per www.sandbox.paypal.com. Se esegui il test sul sito di PayPal attivo, assicurati che i dati di POST degli script siano ripristinati su www.paypal.com con lo . Attualmente, tutti i codici di esempio nei siti Live e Sandbox "puntano" al sito di PayPal attivo .

Spero che aiuti qualcun altro a stare più veloce di me. Sono ora sul mio prossimo problema che è il token restituito come vuoto piuttosto che un errore .. sigh ..

3

Assicurarsi che l'ID della transazione non sia scaduto. Il codice di errore 4003 PDT arriva anche quando l'ID della transazione è scaduto.

+0

Hai altre informazioni su quando scade un ID transazione? Semplice rip su questa domanda pure se hai: http://stackoverflow.com/questions/23862124/paypal-pdt-transaction-id-expiration-period –

+0

come sei sicuro? AFAIK, l'ID della transazione PayPal non scade mai. – Vimalnath

1

Ecco cosa risolto per me ...

Nel pulsante Acquista ora, ho avuto un indirizzo di posta elettronica aziendale associato al mio account LIVE PayPal che, ho bisogno di utilizzare l'indirizzo di posta elettronica aziendale associato al mio conto PayPal SANDBOX come in:

<input type="hidden" name="business" value="[email protected]"> 

l'attributo value necessario per riflettere l'indirizzo di posta elettronica aziendale associato al mio account sandbox.

A proposito, ecco una versione alternativa PHP cURL dello script di cui sopra, che fa anche il trucco di suscitare una risposta da sandbox di PayPal:

if (isset($_GET['tx'])) { 

$tx = $_GET['tx']; 
$identity_token = "INSERT_YOUR_IDENTITY_TOKEN_HERE"; 

//echo $tx; 

$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; 

$nvpString="cmd=_notify-synch". 
      "&tx=$tx". 
      "&at=$identity_token"; 

//echo $nvpString; 

//define where the data is going to 
$curl = curl_init($url); 
//tell cURL to fail if an error occurs 
curl_setopt($curl, CURLOPT_FAILONERROR, 1); 
//allow for redirects 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
//assign the returned data to a variable 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
//set the timeout 
curl_setopt($curl, CURLOPT_TIMEOUT, 60); 
//use POST 
curl_setopt($curl, CURLOPT_POST, 1); 
//set the POST data 
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvpString); 
//execute the transaction 
$response = curl_exec($curl); 
//show errors 
curl_error($curl); 
//close the connection 
curl_close($curl); 

echo '<pre>'; 
print_r($response); 
echo '</pre>'; 

}//end if (isset($_GET['tx'])) 
0

L'identità provvisoria del mio account di prova venditore cambiato senza preavviso. L'utilizzo del nuovo (corretto) Identity token ha risolto il problema.

0
$tx=$_REQUEST['tx']; 

$paypal_url='https://www.paypal.com/cgi-bin/webscr?cmd=_notify-synch&tx='.$tx.'&at=token here'; 

$curl = curl_init($paypal_url); 

$data = array(

"cmd" => "_notify-synch", 

"tx" => $tx, 

"at" => "token here" 


);                  

$data_string = json_encode($data); 

curl_setopt ($curl, CURLOPT_HEADER, 0); 

curl_setopt ($curl, CURLOPT_POST, 1); 

curl_setopt ($curl, CURLOPT_POSTFIELDS, $data_string); 

curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); 

curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); 

curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 1); 

$headers = array (

'Content-Type: application/x-www-form-urlencoded', 

'Host: www.paypal.com', 

'Connection: close' 

); 

curl_setopt ($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 

curl_setopt ($curl, CURLOPT_HTTPHEADER, $headers); 

$response = curl_exec($curl); 

$lines = explode("\n", $response); 

$keyarray = array(); 

if (strcmp ($lines[0], "SUCCESS") == 0) { 

for ($i=1; $i<count($lines);$i++){ 

list($key,$val) = explode("=", $lines[$i]); 

$keyarray[urldecode($key)] = urldecode($val); 

} 


$first_name=$keyarray['first_name']; 

$last_name=$keyarray['last_name']; 

$payment_status=$keyarray['payment_status']; 

$business=$keyarray['business']; 

$payer_email=$keyarray['payer_email']; 

$payment_gross=$keyarray['payment_gross']; 

$mc_currency=$keyarray['mc_currency']; 

} 
Problemi correlati