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

Paypal Sandbox IPN returns INVALID response Options
Zeeshan
#1 Posted : Monday, September 28, 2009 5:17:32 AM
Rank: Starting Member

Groups: Registered

Joined: 9/28/2009
Posts: 2
Location: India
Hi,
I am trying ipn callback, using servlet. I have used the java/jsp code provided by paypal for verifying the ipn data. But every time i getting a INVALID response.

The code i am using is as follows.
Enumeration en = req.getParameterNames();
String str = "cmd=_notify-validate";

while (en.hasMoreElements()) {

String paramName = (String) en.nextElement();
String paramValue = req.getParameter(paramName);

//str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue,"UTF-8"); // for UTF-8 i set the encode format in my account as UTF-8
//str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue,"ISO-8859-1");// for ISO-8859-1 i set the encode format in my account as ISO-8859-1
str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue); //default as provided by paypal

}
URL u = new URL("http://www.sandbox.paypal.com/cgi-bin/webscr");
URLConnection uc = u.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
PrintWriter pw = new PrintWriter(uc.getOutputStream());
pw.println(str);
pw.close();

BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String res = in.readLine();
in.close();

if (res.equals("VERIFIED") || !res.equals("VERIFIED")) {
//Update database...
} else if (res.equals("INVALID")) {

//INVALID
}

I have checked all three possibilities as follow:
1) Missing Parameters-As i am send all the parameters no issue of missing parameters
2) Invalid URL. - i am using sandbox so url is : http://www.sandbox.paypal.com/cgi-bin/webscr
3) Character encoding. - Tried with character encoding same as paypal account setting parameter encoding.

the request i am sending back to sandbox.paypal using following parameters:

cmd=_notify-validate&last_name=User&test_ipn=1&address_name=Test+User&txn_type=web_accept&receiver_email=sellr1_1252495907_biz%40gmail.com&residence_country=US&address_city=San+Jose&payment_gross=&payment_date=01%3A55%3A04+Sep+26%2C+2009+PDT&address_zip=95131&payment_status=Completed&address_street=1+Main+St&first_name=Test&payer_email=buyer1_1252495751_per%40gmail.com&protection_eligibility=Eligible&payer_id=BXBKS22JQCUWL&verify_sign=AOMkeg7ofCL7FJfioyWA19uCxD4XAgZirsjiGh8cUy1fd2YAqBwOkkst&payment_type=instant&business=sellr1_1252495907_biz%40gmail.com&address_country_code=US&mc_fee=0.64&address_status=confirmed&transaction_subject=True+Up&quantity=1&notify_version=2.8&mc_currency=EUR&custom=&address_state=CA&payment_fee=&handling_amount=0.00&payer_status=verified&shipping=0.00&item_name=True+Up&tax=0.00&username=hannonj&charset=windows-1252&item_number=567&mc_gross=10.00&txn_id=7F456350BS7942738&receiver_id=MASSU6BSR9SC2&address_country=United+States


Please , can any one direct me to proper direction?
Regards,
Sponsor  
 
Zeeshan
#2 Posted : Monday, September 28, 2009 6:14:16 AM
Rank: Starting Member

Groups: Registered

Joined: 9/28/2009
Posts: 2
Location: India
Hi,
I have solved the problem.

Actually i appended a parameter (username) to notify url itself while creating paypal button. And while retrieving list of parameter and values it was also appending the username parameter, which was not send by paypal.

Now i removed the parameter while sending to paypal and now its giving response as VERIFIED.


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 1.9.3 | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.144 seconds.