Google Checkout integration

388 views
Skip to first unread message

Ankur

unread,
Dec 13, 2010, 4:21:50 AM12/13/10
to play-framework
I am trying to integrate google checkout for payment processing. While
going over the tutorials at
http://code.google.com/apis/checkout/developer/Google_Checkout_Custom_Processing_How_To.html
I found that i need the httpservlet request and response objects. It
is my understanding that this is not possible using the play framework
as these objects don't really exist. Is there a way i can achieve this
integration without super drastic measures.

Any help is appreciated.

Erwan Loisant

unread,
Dec 13, 2010, 4:44:27 AM12/13/10
to play-fr...@googlegroups.com
I think the best way is simply to use their API directly, without the
servlet lib:
http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_API_Processing.html

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Erwan Loisant

Ankur

unread,
Dec 13, 2010, 7:31:41 PM12/13/10
to play-framework
Hmmm.... seems like a lot of rework. Is there some preexisting code
that does this?
What about paypal? the documentation confuses me. They have too many
options and I can't seem to find what is the parallel to the google
checkout.
It seems like express checkout is the one but I don't understand how
does the paypal server communicate back.(parallel to notification api
in gcheckout)


On Dec 13, 1:44 am, Erwan Loisant <elois...@gmail.com> wrote:
> I think the best way is simply to use their API directly, without the
> servlet lib:http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_A...
>
>
>
>
>
>
>
>
>
> On Mon, Dec 13, 2010 at 10:21, Ankur <ankurtro...@gmail.com> wrote:
> > I am trying to integrate google checkout for payment processing. While
> > going over the tutorials at
> >http://code.google.com/apis/checkout/developer/Google_Checkout_Custom...

Erwan Loisant

unread,
Dec 14, 2010, 4:03:27 AM12/14/10
to play-fr...@googlegroups.com
Integrating with APIs is not that hard, it's a lot of redirects and
the WS lib is here for server to server communication.

For Playapps.net we use Paypal (express checkout) without any
particular lib and the code is less than 200 lines.

The paypal server communicates back to your server by redirecting the
user to a URL on your server.

Ankur

unread,
Dec 14, 2010, 5:49:27 AM12/14/10
to play-framework
Thanks. I will look at that.

Guillaume Bort

unread,
Dec 14, 2010, 2:49:38 PM12/14/10
to play-fr...@googlegroups.com
Here a sample code extracted from playapps to create an
ExpressCheckout via Paypal. No external library required.

Map params = new HashMap();

// Add login infos
params.put("METHOD", method);
params.put("VERSION", "62.0");
params.put("USER", username);
params.put("PWD", password);
params.put("SIGNATURE", signature);

//
params.put("EMAIL", account.email);
params.put("RETURNURL", ok);
params.put("CANCELURL", cancel);
params.put("LOCALECODE", "US");
params.put("NOSHIPPING", "1"); // No shipping address
params.put("SOLUTIONTYPE", "Sole"); // No paypal account needed
params.put("LANDINGPAGE", "Billing"); // Non login page
params.put("CHANNELTYPE", "Merchant");
params.put("PAYMENTREQUEST_0_AMT", amount);
params.put("PAYMENTREQUEST_0_CURRENCYCODE", "EUR");
params.put("PAYMENTREQUEST_0_CUSTOM", "For account " + account.id);
params.put("PAYMENTREQUEST_0_PAYMENTACTION", "Sale");
params.put("GIFTMESSAGEENABLE", "0");
params.put("GIFTRECEIPTENABLE", "0");
params.put("GIFTWRAPENABLE", "0");
params.put("L_PAYMENTREQUEST_0_NAME0", "Credit your prepaid account");
params.put("L_PAYMENTREQUEST_0_AMT0", amount);
params.put("L_PAYMENTREQUEST_0_QTY0", "1");

// Call paypal
String back = WS.url(api).params(params).post().getString();

// Parse result
Map<String,String[]> r = UrlEncodedParser.parse(back);
Map<String,String> result = new HashMap<String,String>();
for(String k : r.keySet()) {
result.put(k, r.get(k)[0]);
}

if(!("Success".equals(result.get("ACK")))) {
Logger.error("SetExpressCheckout has failed: %s", result);
}

String token = result.get("TOKEN");

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Carlos Carvalho

unread,
Nov 23, 2012, 10:55:40 AM11/23/12
to play-fr...@googlegroups.com
HI Guillaume!

I've tried to do as you said but it returns "Method Specified is not Supported".

But if I have a template like this: 

<html>
<head></head>
<body>

<form method=post action=https://api-3t.sandbox.paypal.com/nvp
<input type=hidden name=USER value= apisel_1353511936_biz_api1.gmail.com
<input type=hidden name=PWD value= 1353511955> 
<input type=hidden name=SIGNATURE value= AOD903KdfH3SSwH-RcVtmlsdCMe4AFNYO0cEXlj8kT9fREZS-Xi1iEG0> 
<input type=hidden name=VERSION value=2.3> 
<input type=hidden name=PAYMENTACTION value=Authorization> 
<input name=AMT value=19.95> 
<input type="hidden" name="item_name" value="NameTest">
<input type="hidden" name="amount" value="20.00">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="button_subtype" value="services">
<input type=hidden name=RETURNURL 
<input type=hidden name=CANCELURL 
<input type=submit name=METHOD value="SetExpressCheckout"> 
</form>

</body>
</html>

The response is successful. Have you seen this behavior before???

Thanks!
Reply all
Reply to author
Forward
0 new messages