[PAYPAL] Messaggio di Errore anche a Pagamento Avvenuto
-
ciao a tutti!
sto cercando di venir fuori da un problema che mi assilla ormai da una settimana...questo è il codice di esempio che lo stesso paypal fornisce:
<? // 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 ('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 mail('[email protected]','Pagamento OK','Pagamento Avvenuto con Successo'); } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation mail('[email protected]','Pagamento FAIL','Pagamento Non Avvenuto'); } } fclose ($fp); } ?>ebbene, nonostante il pagamento venga effettuato senza problemi, mi vengono inviate sempre due mail: la prima di pagamento effettuato e la seconda di errore nel pagamento.
ho provato a stampare tutte le variabili ma viene restituito effettivamente il valore SUCCESS quindi non capisco come faccia ad entrare nella condizione di INVALID.
qualcuno ha già avuto a che fare con questo codice o simile per l'integrazione di paypal nel suo sito?
grazie!
-
allora... aggiungo che ho fatto un nuovo copia ed incolla di tutto il codice indicato da paypal. il risultato è che ora va sempre in errore. questi i valori stampati:
HTTP/1.1 200 OK
Date: Fri, 12 Sep 2008 18:54:44 GMT
Server: Apache
Content-Length: 7
Set-Cookie: cookie_check=yes; expires=Mon, 10-Sep-2018 18:54:44 GMT; domain=.paypal.com; path=/
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/
Set-Cookie: navlns=0; expires=Thu, 07-Sep-2028 18:54:44 GMT; domain=.paypal.com; path=/
Set-Cookie: Apache=10.190.8.11.1221245684214133; path=/; expires=Thu, 31-Jul-02 12:26:28 GMT
Keep-Alive: timeout=5, max=100Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
INVALID
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi