YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Getting INVALID from SandBox Options
mymaimi
#1 Posted : Saturday, April 22, 2006 6:18:08 PM
Rank: Starting Member

Groups: Registered

Joined: 4/22/2006
Posts: 1
Location: ,
I am working on a Java Servlet to receive IPN from PayPal and post back with cmd=_notify-validate. I basically copy the JSP code sample and motify to a servlet code. But everytime I received an INVALID code after I post the url back to PayPal. I did a print out and all the parameters and parameters values are extactly the same as received along with the added parameter cmd=_notify-validate. I am testing this in the SandBox envoirnment. Can someone help me? Anyone got the Java Servlet code working that received VERIFIED code from PayPal. I really don't know what is missing. The only thing I can think of is PayPal requries all values passed back the way it is and in the same order (read it in the IPN specs help page). But I am not sure if request.getParameterNames which returns the paramter names as an Enumeration objects returns the elements in the order it was posted. Any help would be appriciated. I copy and pasted my code here, it is really simple. Just don't know why it does not work. Enumeration lEn = request.getParameterNames(); String lstr = "cmd=_notify-validate"; //get the parameters and build the return url while (lEn.hasMoreElements()) { String lParaName = (String) lEn.nextElement(); String lParaValue = request.getParameter(lParaName); lstr = lstr + "&" + lParaName + "=" + URLEncoder.encode(lParaValue); } //post back to PayPal system to validate URL lurl = new URL("https://www.paypal.com/cgi-bin/webscr"); HttpURLConnection uc = (HttpURLConnection) lurl.openConnection(); uc.setDoOutput(true); uc.setRequestMethod("POST"); uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); PrintWriter pw = new PrintWriter(uc.getOutputStream()); pw.println(lstr); pw.close(); //PayPal responds to the postback with VERIFIED or INVALID BufferedReader in = new BufferedReader( new InputStreamReader(uc.getInputStream())); String lResult = in.readLine(); in.close(); //check notification validation if (lResult.equals("VERIFIED")) { //log for investigation } else if (lResult.equals("INVALID")) { //this should not occured, log for investigation } else { } saveData(request, lResult, lstr);
Sponsor  
 
shahzadsadiq
#2 Posted : Tuesday, May 27, 2008 12:28:39 PM
Rank: Starting Member

Groups: Registered

Joined: 5/27/2008
Posts: 3
Location: ,
I am also getting FAIL response every time. Please reply what could be the possible problems and what are their solutions. How could we know the token values. I am doing this in sandbox environment.

Shahzad Sadiq
Senior software Engineer
ooober
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.194 seconds.