Hi,
Can anyone suggest how I can forward a post using servlets?
I have a page with 3 forms on it. The forms are paypal, google checkout, and
one other payment methods.
eg:
<form method="POST"
action="
https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/***"
name="gc" >
<input type="hidden" name="cart" value="$googleCart">
<input type="hidden" name="signature" value="$googleSignature">
<input type="image" name="Google Checkout" alt="Fast checkout
through Google"
src="
http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=***
&w=180&h=46&style=white&variant=text&loc=en_GB" height="46"
width="180">
</form>
etc
I want to be able to track which of the buttons users click, so I am using a
form like this:
<form method="POST" >
<input type="image" name="Google Checkout" alt="Fast checkout through
Google"
src="
http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=***
&w=180&h=46&style=white&variant=text&loc=en_GB" height="46"
width="180">
<input type="image" src="
https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0"
name="Paypal" alt="PayPal - The safer, easier way to pay online.">
etc
</form>
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.
Been playing around with a HttpsURLConnection :
URL url = new URL(
"
https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/***");
HttpsURLConnection conn = (HttpsURLConnection)
url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
OutputStreamWriter wr = new OutputStreamWriter(conn
.getOutputStream());
wr.write("name=\"cart\"");
wr.write("value=\""+encodedCart+"\"");
wr.write("name=\"signature\"");
wr.write("value=\""+signedCart+"\"");
wr.flush();
conn.disconnect();
I'm not sure if that sends he info to google, but it certainly doesn't move
the user onto google's site.
Can anyone help?
TIA,
John