Frameset and google API not supported?

56 views
Skip to first unread message

robertkr

unread,
Dec 19, 2011, 4:47:37 AM12/19/11
to In-App Payments
Goodmorning from Sweden!

I am trying to incorporate the google payment service in a website
which is using framesets. I get warnings/errors when trying to
initialize:

"No relay set (used as window.postMessage targetOrigin), cannot send
cross-domain message"


Has anyone had experience with this?

I've tried to have a look at the google API code which is pulled in
but, oh boy, it is somewhat "obfuscated" for my eyes (maybe I'm
getting old, hehe) I can imagine that "window" should be changed to
"f_pres.window" at some places(?) but the google.load call doesn't
seem to have parameters for this.


I am grateful for all the help I can get..

/Robert


About the frameset solution:
A tiny testcase:
http://hem.bredband.net/robertkr/i.htm

i.htm:
<html>
<frameset onload="" cols="100%,0" frameborder=no framespacing=0
border=0>
<frame name="f_pres" src="p.htm">
<frame name="f_ms" scrolling="no" noresize>
</frameset>
</html>

p.htm:
<html><head>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script>
google.load('payments', '1.0', {'packages': ['sandbox_config']});
//No relay set (used as window.postMessage targetOrigin), cannot send
cross-domain message
</script>
</head><body></body></html>

Daniel Hermes

unread,
Dec 20, 2011, 12:24:33 PM12/20/11
to In-App Payments
Robert,

Since you are calling the JS API loader from an iframe, rather than
from your window, you are getting the cross domain error.

Please load the script in the page you intend to use it on. Is there
any particular reason you need nested frames to place a payment
button?

Regards,

robertkr

unread,
Dec 21, 2011, 9:15:09 AM12/21/11
to In-App Payments
Hello Dan and others, thanks for the reply!

Dan, about your answer:
- iframe? I assume you mean frame. My f_pres frame (p.htm) is the
main frame which is displayed to the user.


From my experimentation:
I can get rid of the warning if I place jsapi script+load in the
frameset document (i.htm) but later on it will fail:

The Google solution when initiating a "buy" scenario, creates some
stuff (e.g. divs,iframes etc) on the client when establishing the
messaging communication with the google server. This is done in the
same file/document where the API is loaded.

So it will then create stuff in the i.htm file(the frameset file)
which is not desireable (iframes,divs etc must not reside in a
frameset file).

If I place jsapi+load in the p.htm file(f_pres frame) then everything
is ok (except for the "no relay set...") warning.

I can achieve initialization of the communication,Google opens a
window, displays the login page, I can login and the invoice is
shortly displayed but at this point the communication will fail and I
get a warning. I presume the warning has to do with the "no relay
set...".

Am I missing something here or is this a bug or is it not supposed to
work with framesets??

/Robert, from the land of Santa Claus :-)

Pablo Benito

unread,
Feb 29, 2012, 1:10:53 PM2/29/12
to in-app-...@googlegroups.com
Hi Robert,

The js that implements the payments api, checks if the javascript is not running in the top window,

if you see https://www.google.com/uds/api/payments/1.0/66eb580ec94d34ec0e76b4c6c36c8574/default,sandbox_config.I.js  (the js that implements de payment api)  on the google chrome debugger with the Pretty print mode ({})  , in the line 2121 there is the check I mentioned 

2121 if (l[eb] != l) { // <== this line is equivalent to window.parent != window , and evaluate to true, because the script run in an iframe.
2122 var b = N.b.v(); // then enter here
2123 b.gcv && $b(b.gcv);
2124 var f = b.jsh;
2125 f && ac(f);
2126 cc(hc(b, "..", ""), O);
2127 cc(b, O);
2128 l[w](function() {// <== this line is equivalent to window.setTimeout, that trigger the error you comment "No relay set (used as ..."
2129 N.e[D]("..", "_noop_echo", a)
2130 }, 0)
2131 }

How you can see, the code isn't so ofuscated if yo use the Pretty print mode


 
Bye!

robertkr

unread,
Mar 2, 2012, 5:18:17 AM3/2/12
to in-app-...@googlegroups.com
Hi Pablo!
ok thx for the tip, will surely be easier to 'debug' google code now, hehe.

It seems to me that in-app, by design, is not able to coexist with framesets? Has anyone else successfully integrated the two?

If not, shouldn't there be some google docs that mentions this, as it is a constraint on the current solution? Maybe there is ?

keep on hackin' :-)
/robert
Reply all
Reply to author
Forward
0 new messages