Hi,

At least with Google checkout, I have found a better solution. I have a form
with just their button image as a submit, and in my handler I do:

String xmlCart = cart.createXML();
 MerchantInfo mi = GoogleMerchantInfoFactory.createMerchantInfo(
EnvironmentType.Sandbox);
 CheckoutShoppingCartRequest cscr = new CheckoutShoppingCartRequest( mi,
xmlCart);
CheckoutResponse checkoutResponse = cscr.send();
 String redirectUrl = checkoutResponse.getRedirectUrl();

It turns out that GC has some java code already that uses the
HttpURLConnection class - it posts the data in the shopping cart, the
retrieves a forwarding url that takes the user to their payment page.
Google's CheckoutShoppingCartRequest contains the HttpURLConnection code
which posts the data - server to server.

Thanks for the heads up.

Unfortunately, I don't think Paypal have an equivalent, unless I sign up for
their £20/month Paypal Pro ( I am not sure if their code makes this
functionality available - for that price, I won't even look - I'll just
stick to using javascript onLoad(submit()) in a page conatining nothing but
the Paypal button form.

John

On 20/03/2008, Christopher Schultz <[EMAIL PROTECTED]> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> John,
>
>
> John Pedersen wrote:
> | Can anyone suggest how I can forward a post using servlets?
>
>
> [snip]
>
>
> | Then, depending on which button the user clicks, I want to forward the
> user
> | on to google/paypal using POST, adding the parameters such as cart,
> | signature.
>
>
> This is typically called a "man-in-the-middle attack". ;)
>
> Seriously, though, you'll have to build the POST manually. Look at the
> java.net.HttpURLConnection class. You could also look at HttpClient
> (http://hc.apache.org/httpcomponents-client/index.html), which
> encapsulates a lot of what you want to do.
>
> Just remember that if you decide to act as a proxy like this, you will
> have top handle a lot of things like cookie-passing, etc. in order to do
> it properly.
>
> Perhaps there's a better API for you to use than their user-facing
> web-based one... such as a SOAP or REST API where a lot of those issues
> are removed.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.8 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkfiaE8ACgkQ9CaO5/Lv0PAAVgCffK5ZwvwMZwMVXcDsF295MqjJ
> GC0AoKJOK1s4TMfT/fUDUatijBn9c/OB
> =mlDx
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to