Buongiorno, sto tentando da 10 giorni ad impostare le notifiche di pagamento nel mio sito. (IPN)
La situazione � questa.
pagine aspx create:
paypal.aspx (contiene il tasto paga adesso creato dal sito paypal)
codice:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ZXWM2289W3WYG">
<input type="image" src="https://www.sandbox.paypal.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal � il metodo rapido e sicuro per pagare e farsi pagare online.">
<img alt="" border="0" src="https://www.sandbox.paypal.com/it_IT/i/scr/pixel.gif" width="1" height="1">
</form>
paypal_ok.aspx (contiene solo testo di conferma pagamento ricevuto)
paypal_ko.aspx (contiene solo testo di mancato pagamento o annullato)
paypal_IPN.aspx (contiene il codice di esempio postato da paypal)
codice:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Post back to either sandbox or live
Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
Dim strLive As String = "https://www.paypal.com/cgi-bin/webscr"
Dim req As HttpWebRequest = CType(WebRequest.Create(strSandbox), HttpWebRequest)
'Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Dim strRequest As String = Encoding.ASCII.GetString(Param)
strRequest = strRequest + "&cmd=_notify-validate"
req.ContentLength = strRequest.Length
'for proxy
'Dim proxy As New WebProxy(New System.Uri("http://url:port#"))
'req.Proxy = proxy
'Send the request to PayPal and get the response
Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
streamOut.Write(strRequest)
streamOut.Close()
Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
Dim strResponse As String = streamIn.ReadToEnd()
streamIn.Close()
If strResponse = "VERIFIED" Then
'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
SCRIVO SUL DB LA NOTIFICA
ElseIf strResponse = "INVALID" Then
'log for manual investigation
SCRIVO SUL DB LA NOTIFICA
Else
'Response wasn't VERIFIED or INVALID, log for manual investigation
SCRIVO SUL DB LA NOTIFICA
End If
End Sub
impostazioni su Paypal
ho seguito le istruzioni per il conto business su "sandbox" impostando le pagine di ritorno e il richiamo dello script.
Dopo una transazione, nella pagina di notifica , leggo questo:
Codice risposta HTTP
500
Stato recapito
Non riuscito
Numero di tentativi
8
ovviamente ho ricontrollato tutti link del caso e sono corretti.
qualcuno sa aiutarmi? sto impazzendo da giorni, grazie