Chris, I was curious about this so I got a free PayPal developer account on http://developer.paypal.com. They have a seemingly Java complete API (they call it version 2.0 and the site is https://api.paypal.com/2.0 (cheesy, huh?). So, it looks like you have a complete option to talk to PayPal without requiring uses to perform HTTPS Posts and/or leave your web site. The java client example includes tests for refunds, searching transactions, billing users, something calld "mass pay," and status requests. The files are under the developer's login, tab "help center", top right area "Code Samples" right below ".NET Code Samples" as the title "Java / AXIS Code Samples."
DISCLAIMER - This was just a curious person's FYI, I do NOT work for PAYPAL nor have I used it in months/years. :) Regards, David -----Original Message----- From: mail [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 15, 2004 5:30 PM To: Struts Users Mailing List Subject: Re: Create and submit POST form from Action David, Thanks big time for your efforts. I did manage to implement an approach solving all my problems, it is just not near as clean as I was hoping ... I use HttpClient to communicate with the payment processing system (paypal in this case) and route the response to the users browser session (that's the real dirty part I don't like at all) After processing the transaction verification request, I return the user to a page within my application. Thanks, Chris David G. Friedman wrote: >Chris, > >I ran across this note which might help you. My comment is below. I found >it when reading an article on http/https switching a moment ago (based upon >a recent post about that topic with a link): > >---------- BEGIN NOTE -- >The second mechanism, the sendRedirect() method in the HttpServletResponse >interface, provides the power to route to any URL with any protocol, as >shown here: > >aResponse.sendRedirect("http://some.otherdomain.com/aPage.jsp"); >// OR an encoded URL with parameters. >aResponse.sendRedirect(aResponse.encodeRedirectURL(redirectString)); > >The only caveat here is that a response can only issue a redirect before it >has committed. If a response attempts a redirect after committing, the >sendRedirect() method will throw an IllegalStateException. With this >limitation in mind, we select the sendRedirect() mechanism for use in our >SSL implementation solution because of its greater flexibility in URL >specification. > >---------- END NOTE -- > >If I recall, you can make your action return a null so nothing else is >displayed, other than the redirect. Or you could try making it show a page >after the send redirect that explains you are now being forwarded to the >Payment Processing page at another site. I recommend trying that as >browsers MAY warn you about being redirected to a SECURE URL on another web >site, i.e. not your own site. > >As I've mentioned, I've done server-side payment processing using a HTTP >POST to a similar service: Verisign's PayFlow Link. I don't know if there >are many pages needed before the customer can hit 'okay' and submit the >process, but you might want to see if you can bypass them by adding >additional urls to get to any 'final' page so the client can simply jump >from your site to one page on Paypal where s/he can hit 'purchase' and go >home (or return to your web site, often by specifing a form parameter). > >Regards, >David > >-----Original Message----- >From: mail [mailto:[EMAIL PROTECTED] >Sent: Friday, September 10, 2004 11:12 PM >To: Struts Users Mailing List >Subject: Re: Create and submit POST form from Action > > >Hey, > >Thanks for your thoughts! But that's not the part I can't figure out ;-) >If I do implement things on this low level, I don't see how to route the >users browser to the PayPal site. > >Having a JSP/Servlet environment to play with, I am bound to what it >offers me ... >I know how to do a POST submission, I just don't know how to do this >from either a Struts Action, >or HttpServlet, having the users browser end up on the PayPal site to >make his payment. > >So if you, or anybody could help my stuck mind build the bridge to that, >I'll be eternally thankful :o) > >Thanks, >Chris > > >David G. Friedman wrote: > > > >>Let's see, you could google this search query: +java +code +post +paypal >> >>You'll find this page which explains it all very nicely on how to post to >>PayPal: >>http://www.paypaldev.org/topic.asp?TOPIC_ID=228 >> >>My personal code is very similar to it. I'm not the best coder so don't be >>too critical of my code. Below is a snippet of my method that does a POST >>(HTTPS) to Verisign's PayFlowLink. It shouldn't take much for you to do >> >> >the > > >>same to adapt it to HTTP(S?) Post to PayPal. >> >>// BEGIN RELEVANT CODE SNIPPETS >> >>// The basics are to put these things in your method: >> >>// Add a security provider to allow SSL POSTs: >>Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); >> >>// Set a handler for SSL (not sure how this is different from the above >>System.setProperty("java.protocol.handler.pkgs", >> "com.sun.net.ssl.internal.www.protocol"); >> >>try { >> // Setup the URL: >> URL url = new URL("https://payflowlink.verisign.com/RunTrans.cfm"); >> >> // Setup the connection object: >> HttpURLConnection conn = (HttpURLConnection) url.openConnection(); >> >> // Setup the query string --- WARNING this below is for >> // Verisign PayFlowLink, NOT PAYPAL! >> String separators = new String("&"); >> StringBuffer parms = new StringBuffer("SOMETHING=SOMEVALUE" + separator); >> parms.append("PARAMTWO=VALUETWO" + separator); >> parms.append("PARAMTHREE=VALUETHREE" + separator); >> // An echo print for your testing mode (remove in production!!!!) >> System.out.println("Verisign POST is: " + parms.toString()); >> >> // Use a byte array for the String in the connection and set various >> // properties for the connection >> byte[] bytes = parms.toString().getBytes(); >> conn.setRequestMethod("POST"); >> conn.setRequestProperty("Content-Type", >> "application/x-www-form-urlencoded"); >> conn.setRequestProperty("Content-length", >> String.valueOf(bytes.length)); >> conn.setDoInput(true); >> conn.setDoOutput(true); >> OutputStream out = null; >> >> // Perform the HTTPS POST >> try { >> out = conn.getOutputStream(); >> out.write(bytes); >> out.flush(); >> out.close(); >> } catch (Exception e) { >> System.out.println( >> "Error opening OutputStream from Verisign Payment Post is:" >> + e.getMessage()); >> return (false); >> } >> >> // Read the returned information >> BufferedReader reader = >> new BufferedReader( >> new InputStreamReader(conn.getInputStream())); >> >> // Figure out how to read it. I use Perl5Utils to scan through >> // my Verisign result for specific error codes >> response = reader.readLine(); >> >>} catch (MalformedURLException mue) { >> System.out.println("Verisign Purchase: Bad URL, aborting."); >> return (false); >>} catch (IOException ioe) { >> System.out.println( >> "Verisign Purchase: Failed Internet Connection Attempt."); >> return (false); >>} >> >>// END RELEVANT CODE SNIPPETS >> >>Regards, >>David >> >>-----Original Message----- >>From: Wendy Smoak [mailto:[EMAIL PROTECTED] >>Sent: Friday, September 10, 2004 7:16 PM >>To: Struts Users Mailing List >>Subject: Re: Create and submit POST form from Action >> >> >>From: "mail" <[EMAIL PROTECTED]> >> >> >> >> >>>I populate my cart, and paypal expects a POST form submission to present >>>the user with the payment forms (register/login/submit payment), >>>and after the user submits or cancels the payment, paypal would submit a >>>reply form to my site ... at least this is the flow I understand from the >>>paypal developer docs. >>> >>> >>> >>> >>AFAIK they do their thing and either post to your 'success' page or your >>'failure' page. So if you make your 'success' page a URL that maps to an >>Action... wouldn't that do it? >> >>You may also want to go talk with these guys: >>http://www.paypaldev.org/topic.asp?TOPIC_ID=3239 >> >>-- >>Wendy Smoak >> >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> >> > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]