question

newuser-ad67e4bd-8ba6-402f-afd4-981013ce35f2 avatar image

window.AmazonIapV2 intermittently undefined

I am testing a html5 web app on a FireTv device, I've included both the necessary scripts from the example :

https://resources.amazonwebapps.com/v1/latest/Amazon-Web-App-API-tester.min.js

https://resources.amazonwebapps.com/v1/latest/Amazon-Web-App-API.min.js


However, the global window.AmazonIapV2 intermittently evaluates to undefined and window.AmazonIapV2.addListener errors out.

It is as if the IAP v2 script is not injected in.

Is there a temporal limit set on the request by IP from test devices ?



if (window.AmazonIapV2 === null) { 

}  
else {    
   window.AmazonIapV2.addListener('getUserDataResponse', function(resp) {});    
   window.AmazonIapV2.addListener('getProductDataResponse', function(data) {});    
   window.AmazonIapV2.addListener('purchaseResponse', this.onPurchaseResponse);    
   window.AmazonIapV2.addListener('getPurchaseUpdatesResponse',this.onPurchaseUpdatesResponse);  
}
iapfire tvpurchasing
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered

Hi there,

Apologies for a late response. If you still have issues, please refer to the latest documentation: https://developer.amazon.com/docs/in-app-purchasing/iap-example-webapp.html

The issue may have been that the listeners have to be added on amazonPlatformReady:

document.addEventListener('amazonPlatformReady', function() {
    // Ensure we can call the IAP API
    if (window.AmazonIapV2 === null) {
        console.debug('Amazon In-App-Purchasing only works with Apps from the Appstore');
    } else {
        window.AmazonIapV2.addListener('getUserDataResponse', function(resp) {});
        window.AmazonIapV2.addListener('getProductDataResponse', function(data) {});
        window.AmazonIapV2.addListener('purchaseResponse', this.onPurchaseResponse);
        window.AmazonIapV2.addListener('getPurchaseUpdatesResponse', this.onPurchaseUpdatesResponse);
    }
}.bind(this));
4 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

A new version of Web App Tester was successfully published to all devices, including Fire OS 7 devices. Thanks!

1 Like 1 ·

Hi @Levon@Amazon

Could you comment on Web App Tester not being available on Fire OS 7 devices (e.g., Cube gen 2, Fire HD 10 tablets). Is there a hope that it will be updated to run on those devices? Without it development for those devices rather suck.

Thank you, Jacek

0 Likes 0 ·

Hi Jacek,

Thanks for bringing it to our attention. I asked the web team to check that. Thanks!

-1 Like -1 ·
Jacek avatar image Jacek Levon@Amazon ♦ ·

Hi @Levon@Amazon

It has been a couple of [weeks] months since you asked the web team. Did you receive any answer? Can you ask about the current status, maybe ETA?

0 Likes 0 ·