Anmelden

Imports System.Collections.Specialized

 

Public Class SB_IPN
Inherits System.Web.UI.Page


#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
< System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub


Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

'Read in IPN POST
Dim strFormValues As String = Encoding.ASCII.GetString(Request.BinaryRead(Request.ContentLength))


Dim strNewValue


' Create the request back
Dim req As HttpWebRequest = CType(WebRequest.Create("https://www.sandbox.paypal.com/cgi-bin/webscr"), _
HttpWebRequest)


' Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
strNewValue = strFormValues + "&cmd=_notify-validate"
req.ContentLength = strNewValue.Length

' Write the request back IPN strings
Dim stOut As StreamWriter = New StreamWriter(req.GetRequestStream(), _
Encoding.ASCII)
stOut.Write(strNewValue)
stOut.Close()


'send the request, read the response

Dim strResponse As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
Dim IPNResponseStream As Stream = strResponse.GetResponseStream
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
Dim readStream As New StreamReader(IPNResponseStream, encode)


Dim read(256) As [Char]
' Reads 256 characters at a time.

Dim count As Integer = readStream.Read(read, 0, 256)

While count > 0
' Dumps the 256 characters to a string and displays the string to the console.
Dim IPNResponse As New [String](read, 0, count)
count = readStream.Read(read, 0, 256)

' if IPN response was VERIFIED..perform VERIFIED handling
'for this example - send email of raw IPN string

If IPNResponse = "VERIFIED" Then


Dim myEmail As MailMessage = New MailMessage()
myEmail.To = "poneal@ebay.com"
myEmail.From = "webmaster@oma-ets-04.corp.ebay.com"
myEmail.Body = strNewValue
myEmail.Subject = IPNResponse & " IPN"
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(myEmail)

Else

' if IPN is INVALID
'log and manually investigate

Dim myEmail As MailMessage = New MailMessage()
myEmail.To = "poneal@ebay.com"
myEmail.From = "webmaster@oma-ets-04.corp.ebay.com"
myEmail.Body = strNewValue
myEmail.Subject = IPNResponse & " IPN"
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(myEmail)
End If
End While

'tidy up, close streams
readStream.Close()
strResponse.Close()


'for debug
'Response.Write("Script ran, check your email")
End Sub
End Class


?>

 

   
Top

Wir arbeiten mit Software von http://www.campus21.de.

Verantwortlich für angezeigte Daten ist der Webdomain-Eigentümer laut Impressum.

Suche