[Resolved] When loading products, the order in which products are indexed?

I added IAP products to Amazon store exactly the same way as I did with Google Play, but it looks like amazon.sdktester.json lists these products in what-seems-to-be in a random order.  I read somewhere in Amazon doc site that it doesn’t matter – but then, when the products are loaded on Kindle Fire, they are listed in what-appears-to-be in a random order again (but not the same order as they are listed in amazon.sdktester.json file.)

If I see the products loaded in the same order as Google Play version, I wouldn’t be so concerned, because I know my In-App Billing works fine with Google Play.  But with Amazon store, I can’t verify if it works until it goes live, and I don’t know if I can trust test mode to yield exact same results as the live mode.

So… for a sanity check, I’m wondering if there’s a rule under which the products are listed when they are loaded.

For example, I added products to Amazon in this order:

Product A  (consumable)

Product B (consumable)

Product C (entitlement)

Product D (entitlement)

The amazon.sdktester.json show them in the order of something like:

Product C

Product B

Product D

Product A

And these products are loaded onto Kindle device in the order of something like:

Product B

Product C

Product A

Product D

I then index the products to something like:

myProductTable[1] = Product B

myProductTable[2] = Product C

myProductTable[3] = Product A

myProductTable[4] = Product D

And then, when the user purchases Product A, my code would assume that the user purchased myProductTable[3].

But if Product A isn’t always loaded as the 3rd product in the table, it wouldn’t work…  Am I worrying about things I don’t need to?  Do I need to dynamically work out the index every time the app is launched to make sure index match up with intended products properly?  (I hope my question is clear enough and make some sense…)

Naomi

Hi Naomi,

The items returned in the loadProducts() callback in the Amazon IAP Plugin match up  with the items in the ItemDataResponse.getItemData() call of the Amazon In-App Purchasing API(see docs here) This response returns a Set of items which are unordered. This means that you cannot count on the order of the items in the event.products table in the loadProducts callback. 

I would suggest not using numeric indices in myProductTable and instead use an identifier internal to your app so ordering is not a concern. 

-Preston

Got it.  Thank you, Preston.  Actually, I looked at what I did with Google Play, and it looks like I worked out the myProductTable dynamically, and yes, the ordering shouldn’t be a concern there.  (It’s been a while since I worked out this bit of code, so I really didn’t remember exactly how I got it done.)

Thanks again.

Naomi

No problem. I am glad you’ve figured it out.

-Preston

Hi Naomi,

The items returned in the loadProducts() callback in the Amazon IAP Plugin match up  with the items in the ItemDataResponse.getItemData() call of the Amazon In-App Purchasing API(see docs here) This response returns a Set of items which are unordered. This means that you cannot count on the order of the items in the event.products table in the loadProducts callback. 

I would suggest not using numeric indices in myProductTable and instead use an identifier internal to your app so ordering is not a concern. 

-Preston

Got it.  Thank you, Preston.  Actually, I looked at what I did with Google Play, and it looks like I worked out the myProductTable dynamically, and yes, the ordering shouldn’t be a concern there.  (It’s been a while since I worked out this bit of code, so I really didn’t remember exactly how I got it done.)

Thanks again.

Naomi

No problem. I am glad you’ve figured it out.

-Preston