I am integrating Google Wallet on my GWT app. At some point (at beginning of JSNI function purchase()
), I need to inject API JS code in my app.
<script src="https://sandbox.google.com/checkout/inapp/lib/buy.js"></script>
How can I do it?
public static native void purchase(String token) /*-{
// Success handler
var successHandler = function(status){
if ($wnd.console != undefined) {
console.log("Purchase completed successfully: ", status);
//window.location.reload();
}
}
// Failure handler
var failureHandler = function(status){
if ($wnd.console != undefined) {
console.log("Purchase failed ", status);
}
}
google.payments.inapp.buy({
'jwt' : token,
'success' : successHandler,
'failure' : failureHandler
});
}-*/;
You have to inject the code with a ScriptInjector, because the GWT-code may run within a hidden IFRAME (depends on the used Linker)