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

subscription not working in sandbox Options
harini
#1 Posted : Thursday, March 30, 2006 3:12:19 PM
Rank: Starting Member

Groups: Registered

Joined: 3/30/2006
Posts: 2
Location: ,
Hi, I am trying to integrate my application with paypal to create user subscriptions. I have enabled PDT and IPN and the PDT return url redirects to a struts action class. I need to get the subscription id, and subscription amount to display in the success page. But, when I try to get the 'tx' parameter from the request, it is null, so when I post the notification validation url to Paypal, I get FAIL as the response. Could someone please tell me what could be the issue? Below is the code of in the action class. public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(false); ActionErrors errors = new ActionErrors(); ActionForward forward = mapping.findForward("self_registration_success"); logger.info("In PDTNotification.execute() "); String txId = request.getParameter("tx"); String authToken = "yC4XUx5hm_8t0Ca3SoGysCg5D5lPi5-ACBS2_lh0OaNn8RWGcdtDKg0pfbm"; String str = "cmd=_notify-synch"; Enumeration en = request.getParameterNames(); while(en.hasMoreElements()){ String paramName = (String)en.nextElement(); String paramValue = request.getParameter(paramName); str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue); } str = str + "&at=" + authToken; try { 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("SUCCESS")) { logger.info("Paypal PDT Notification Response : "+res); activateNewUser(user, errors); } else if(res.equals("FAIL")) { logger.info("Paypal PDT Notification Response : "+res); errors.add("error.paypal.registration", new ActionError("error.paypal.registration")); saveErrors(request , errors); forward = mapping.findForward("self_registration_success"); return forward; } String line = null; String key = ""; String value = ""; while(( line = in.readLine()) != null) { logger.info(line); if(!res.equals("SUCCESS")) { StringTokenizer st = new StringTokenizer(line, "="); while(st.hasMoreTokens()) { key = st.nextToken(); value = st.nextToken(); } } } } catch(Exception e) { logger.error("Exception in execute() ", e); } return forward; } Thanks, Harini
Sponsor  
 
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.161 seconds.