In-app Products - Wrong Price (Google Play)

Prices that are higher than a few thousands are incorrectly fetched by Unreal Engine. In this example, I set the price to “4000.00 TRY”. However, it shows to user “-294.97 TRY”. Of course “4000.00 TRY” is very high and for only testing purpose, but “4000 KRW” and “4000 IDR” are normal prices but because of this bug, we belie our customers by showing a value seems like “294.97 KRW” or “294.97 IDR”. This bug is critical for end-user satisfaction.

Address of the bug: Engine\Build\Android\Java\src\com\epicgames\ue4\GooglePlayStoreHelper.java:163

Float priceRaw = (float) object.getInt("price_amount_micros") / 1000000.0f;
					pricesRaw.add(priceRaw);
					Log.debug("[GooglePlayStoreHelper] - price_amount_micros: " + priceRaw.toString());

Instead of int, long must be used.

To repeat this in a clean java project, use this code:

public class Main {
	public static void main(String[] args) {
		int price = (int)4000000000L;
		Float priceRaw = (float) price / 1000000.0f;
		System.out.println(priceRaw);
	}
}

Output is -294.9673 instead of 4000

This is how Google Play sends price data, in micro currency units. They send it as long but Unreal tries to convert it to int, here is the problem.

To fix this you may change this line:

Float priceRaw = (float) object.getInt("price_amount_micros") / 1000000.0f;

into this line:

Float priceRaw = (float) object.getLong("price_amount_micros") / 1000000.0f;

Today this bug showed someone 1,705.03 VND of price tag, yes, this time positive. But when he bought, we received 6,000.00 VND. This is considered as fraud in many countries including mine.

Forgive me if i’m missing something…but why are you initializing the int with such a large number(too large for int)… just to later reduce it anyway?