![]() |
![]() |
|
| Condividi questo contenuto nei Social Network: |
|
Tweet |
|
|
|
Ti stiamo aspettando: Registrati subito e gratis. Entra a far parte di una delle comunità più attive in Italia. Se hai dimenticato i tuoi dati li puoi recuperare subito. |
||||
|
|||||||||
|
|
LinkBack | Strumenti di discussione |
|
|
#1 (permalink) |
|
User Newbie
Data di registrazione: Dec 2011
Ubicazione: brescia
Messaggi: 6
|
notifica ipn paypal
non so se sono nel posto giusto.
è un po di tempo che cerco di risolvere un problema con la notifica di pagamento di paypal lo script è il seguente: $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Host: ww.sandbox.paypal_com:443\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://ww.sandbox.paypal_com, 443, $errno, $errstr, 30); $subject = "Problema IPN1"; $message = "Si è verificato un problema nella seguente transazione:\r\n\r\n"; $message .=$errno. $errstr ; mail(ADMIN_MAIL,$subject,$message,"From: noreply<$from>"); if (!$fp) { // HTTP ERROR // $errstr - $errno $this->sendReport(); return FALSE; } else { fputs ($fp, $header . $req); while (!feof($fp)) { //$this->sendReport(); $res = fgets ($fp, 1024); $subject = "Problema IPN2"; $message = "Si è verificato un problema nella seguente transazione:\r\n\r\n"; $message .=$res. $fp ; mail(ADMIN_MAIL,$subject,$message,"From: noreply<$from>"); if (strcmp($res, "VERIFIED") == 0) { fclose ($fp); return TRUE; } else if (strcmp ($res, "INVALID") == 0) { //se la procedura non è legittima invia un email all'amministratore $this->sendReport(); fclose ($fp); return FALSE; }}} mi arrivano 3 messaggi sia Problema IPN1 che Problema IPN2 quindi lo script entra dentro il while è fa il controllo della variabile $res solo che è come se fosse vuota o nulla. ecco cosa mi arriva come dati nelle email: - leggenda: a->$res b->$fp A->$errno B-> $errstr Problema IPN2 //e quindi siamo dentro il while a-> Date: Wed, 07 Dec 2011 13:53:23 GMT b-> Resource id #4 Problema IPN1 A ->0 B-> Problema IPN2 a-> HTTP/1.0 500 Server closed connection without sending any data back b-> Resource id #4 qualcuno sa dirmi cosa devo fare affinche mi arrivi sta benedetta risposta (VERIFIED o INVALID) da paypal? |
|
|
|
|
|
|
|
#2 (permalink) |
|
Non iscritto
|
Ciao, prova con questo:
$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 ('ssl://www . paypal.com', 443, $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) { // 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 } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> PS: ho staccato il link "www . paypal.com |
|
Ultima modifica di Web Designer : 08-12-11 00:29. |
|
|
|
|
|
|
#5 (permalink) |
|
User Newbie
Data di registrazione: Dec 2011
Ubicazione: brescia
Messaggi: 6
|
Ahhh ok.
Comunque non funziona lo stesso non ho capito se è un problema di sandbox o del mio host server. |
|
Ultima modifica di vnotarfrancesco : 10-12-11 08:09. Motivo: Maiuscole, punteggiatura e non usare lo stile sms. |
|
|
|
|
|
|
#7 (permalink) |
|
User Newbie
Data di registrazione: Dec 2011
Ubicazione: brescia
Messaggi: 6
|
Avevo pensato che fosse un problema loro ma non mi rispondono è un host gratuito quindi devi fare un po da solo.
Grazie comunque. |
|
Ultima modifica di vnotarfrancesco : 10-12-11 08:10. Motivo: Maiuscole, punteggiatura. |
|
|
|
|