question

jemchicomac avatar image
jemchicomac asked

Amazon IAP not working in Live mode.

Hi, We are Jemchicomac, an indie game studio that has published their first game, 'Crazy Belts', in the Amazon store a couple of weeks ago. The game works fine, but we have a feature that doesn't work (even making some small updates and fixes). That feature is the In-App purchases. In sandbox mode everything works fine, but when the app is on the store (live mode), the IAP products are not shown in the game. For what we have investigated, it appears to happen in the reception of the products, and the error that is shown in the game may be because the products are not received or because the conversion of the prices to float numbers fails. We have revised that last thing, but in sandbox mode works great, and the code parses the prices string to just get the nunbers and point ('.') or comma (','). We have no clue of what can be happening, so we post here to see if someone has the solution or have fixed this problem. Thanks!
iap
10 |5000

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

jemchicomac avatar image
jemchicomac answered
Here we add a portion of the code that parse the prices: final Map items = response.getItemData(); String[] prices = new String[4]; float[] floatPrices = new float[prices.length]; int i = 0; for (final String key : items.keySet()) { //Get the item. Item item = items.get(key); //Pass the price to an array. prices[i] = item.getPrice(); //Extract the value. String aux = ""; for(int c = 0;c < prices[i].length();c++) { char ch = prices[i].charAt(c); if((ch >= '0' && ch <= '9') || ch == '.' || ch ==',') aux += ch; } //Convert to float. try { floatPrices[i] = Float.parseFloat(aux); } catch (NumberFormatException exception) { applicasaManagerAndroid.failMilesPacksConnection(); if(CrazyBelts.DEBUG) { Gdx.app.log("AMAZON IAP", "Error when extracting IAPs float price."); } return; } //Iterate i. i++; }
10 |5000

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

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Sergio, First, I see the code you have posted is not correct. This wont even compile. Can you copy and paste the code what you are doing after receiving ItemDataResponse? Second, you are neither posting from the account that owns the app nor you have mentioned the app name. If you do not want to say the app name publicly, please file a ContactUs ( https://developer.amazon.com/help/contactus.html) with a reference of this thread URL. Thanks. Message was edited by: Sujoy@Amazon
10 |5000

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

jemchicomac avatar image
jemchicomac answered
Hi, Our producer is Immanitas Entertainnment and the game is published in the Amazon Store with the name Crazy Belts. The code after receiving ItemDataResponse is the one I posted. This code compiles with no problem, the game currently in the store use the code and this code used in Sandbox mode works perfectly, so we think it's ok and the problem could be in other place. Thanks.
10 |5000

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

Sujoy@Amazon avatar image
Sujoy@Amazon answered
I am sorry. Actually I realized that we can not post [ ] with 'i' in the middle in the forum. It's reserved char sequence for italicize the words. That was the reason [, ] and i were missing from the code that you have posted above. I will take a look on the issue and get back to you shortly.
10 |5000

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

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi, I downloaded the app and can see the IAP catalog (different packs of miles) there with the correct price. I also can purchase them as well. I have used my US account to purchase the app and I see the price is in $ unit. Which market place you are using to purchase the app?
10 |5000

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

jemchicomac avatar image
jemchicomac answered
Hi, It surprises us. We usually test it from Spain and never works, but I think that we have people from other countries in Europe that also notified us that the IAPs aren't listed and don't work. Maybe a problem only from European countries? Thanks for your help.
10 |5000

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

Sujoy@Amazon avatar image
Sujoy@Amazon answered
The parseFloat method doesn't work with commas. The standard method for currency display for many European countries such as Spain utilize commas. That is likely the cause of their error.
10 |5000

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

slumley-xy avatar image
slumley-xy answered
Hi jemchicomac, I'm sorry for joining the conversation so late, but I hope this helps for future reference. We had a similar issue as this, when formatting the prices of the store. The first thing one needs to note is that Amazon IAP v.2 only sends the formatted string with the price, but it is unclear which is the format used for the parsing, therefore, there is not a straight forwards way for getting the numeric price. The issue is, one needs the [b]language[/b] used for formatting the price, but Amazon IAP v.2 API does not provide an API for obtaining the language, only the [b]country[/b]. This is clearly not enough, since formatting a country like Canada might be in French or English language. It is still unclear if the formatting happens with the language of the device or the language of the store. There are a few options to work around this. 1. Try to make some kind of smart parsing that tries to assume the language of a given country 2. Keep a map of Amazon's supported markets (as of writing, English (U.S.), English (Australian), English (U.K.), French, German, Italian, Japanese, Portuguese (Brazil), and Spanish) and only support those 3. Map the SKUs with an external service where you can obtain the prices in number (e.g. a JSON file with the SKUs of the products and the prices in US Dollars or Euros, then manually make the conversion) I hope this helps a bit, waiting for a possible solution to this, maybe in Amazon IAP v.3! Best, /Sergio R. Lumley
10 |5000

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