Hello, I am attempting to do IPN for the first time and really could use some help.
With my code below, I can sucessfully take a payment. I want to be able to use IPN to take appropriate action on if the transaction is a success.
The transaction is successful yet the user is redirected to the page which should be the failure page.
Any help would be great!
Here is a sample of the code I use to send to paypal:
Dim amount As Decimal = 0.5
Dim orderId As String = 1002
Dim siteName As String = "nice"
Dim ReturnURL As String = "nice/store/Notify.aspx"
Dim CancelledURL As String = "nice/store/Cancelled.aspx
"
' Create the PayPal redirect location
Dim redirect As String = ""
redirect += "
https://www.paypal.com/xclick/business=Scott@nice.com"
redirect += "&item_name=" + siteName + " Order " + orderId
redirect += "&item_number=" + orderId
redirect += "&amount=" + [String].Format("{0:0.00} ", amount)
redirect += "¤cy=USD"
redirect += "&return=
http://" + ReturnURL
redirect += "&cancel_return=
http://" + CancelledURL
' Redirect to the payment page
Response.Redirect(redirect
)
The payment is successfull then we do the IPN set to the notify.aspx page. The following code is supposed to set a session with "OK" if the payment is varified and redirect to the thankyou.aspx. BUT even though the payment is good the user is direced to the cancelled.aspx
Here is the Notify.aspx code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'-- Capture posted form values from PayPal
Dim FormValues As String = Request.Form.ToString()
' Create the postback to PayPal to verify sent information
Dim PostBackRequest As HttpWebRequest
PostBackRequest = WebRequest.Create("
https://www.paypal.com/cgi-bin/webscr")
PostBackRequest.Method = "POST"
PostBackRequest.ContentTyp
e = "application/x-www-form-ur
lencoded"
Dim PostBackString As String = FormValues + "&cmd=_notify-validate"
PostBackRequest.ContentLen
gth = PostBackString.Length
' Send the postback reply to PayPal
Dim PostBackWriter As StreamWriter
PostBackWriter = New StreamWriter(PostBackReque
st.GetRequ
estStream(
), Encoding.ASCII)
PostBackWriter.Write(PostB
ackString)
PostBackWriter.Close()
' Receive final verification from PayPal
Dim ResponseReader As StreamReader
ResponseReader = New StreamReader(PostBackReque
st.GetResp
onse().Get
ResponseSt
ream())
Dim ResponseString As String = ResponseReader.ReadToEnd()
ResponseReader.Close()
If ResponseString = "VERIFIED" Then
'Set a flag and transfer to sales success page
Session("Verified") = "OK"
Response.Redirect("ThankYo
u.aspx")
Else
'Set flag and transfer to sales failure page
Session("Verified") = ""
Response.Redirect("Cancell
ed.aspx")
End If
End Sub
How can I debug this? What should I or what can i do to fix this?
Start Free Trial