I am implementing in-app purchases for an app with support for several countries.
The In-App Billing Version 3 API claims that:
No currency co
Full information can be found here, but essentially in August 2014 this was resolved with:
The getSkuDetails() method
This method returns product details for a list of product IDs. In the response Bundle sent by Google Play, the query results are stored in a String ArrayList mapped to the DETAILS_LIST key. Each String in the details list contains product details for a single product in JSON format. The fields in the JSON string with the product details are summarized below
price_currency_code ISO 4217 currency code for price. For example, if price is specified in British pounds sterling, price_currency_code is "GBP".
price_amount_micros Price in micro-units, where 1,000,000 micro-units equal one unit of the currency. For example, if price is "€7.99", price_amount_micros is "7990000".
You can. You need to modify SkuDetails.java like below.
Steps:
import org.json.JSONException; import org.json.JSONObject; /** * Represents an in-app product's listing details. */ public class SkuDetails { String mItemType; String mSku; String mType; int mPriceAmountMicros; String mPriceCurrencyCode; String mPrice; String mTitle; String mDescription; String mJson; public SkuDetails(String jsonSkuDetails) throws JSONException { this(IabHelper.ITEM_TYPE_INAPP, jsonSkuDetails); } public SkuDetails(String itemType, String jsonSkuDetails) throws JSONException { mItemType = itemType; mJson = jsonSkuDetails; JSONObject o = new JSONObject(mJson); mSku = o.optString("productId"); mType = o.optString("type"); mPrice = o.optString("price"); mPriceAmountMicros = o.optInt("price_amount_micros"); mPriceCurrencyCode = o.optString("price_currency_code"); mTitle = o.optString("title"); mDescription = o.optString("description"); } public String getSku() { return mSku; } public String getType() { return mType; } public String getPrice() { return mPrice; } public String getTitle() { return mTitle; } public String getDescription() { return mDescription; } public int getPriceAmountMicros() { return mPriceAmountMicros; } public String getPriceCurrencyCode() { return mPriceCurrencyCode; } @Override public String toString() { return "SkuDetails:" + mJson; } }
Here is my workaround :)
private static Locale findLocale(String price) {
for (Locale locale : Locale.getAvailableLocales()){
try {
Currency currency = Currency.getInstance(locale);
if (price.endsWith(currency.getSymbol()))
return locale;
}catch (Exception e){
}
}
return null;
}
Usage:
Locale locale = findLocale(price);
String currency = Currency.getInstance(locale).getCurrencyCode();
double priceClean = NumberFormat.getCurrencyInstance(locale).parse(price).doubleValue();
Very simple. SKU returns the currency code ("price_currency_code" field). With that code you can retrieve the symbol using the Currency class. See the code attached:
String currencyCode = skuObj.getString("price_currency_code");
currencySymbol = Currency.getInstance(currencyCode).getSymbol();
You can check this The Android developers in select countries can now offer apps for sale in multiple currencies through Google Wallet Merchant Center. To sell your apps in additional currencies, you will need to set the price of the app in each country/currency. A list of supported countries/currencies is available in our help center.
If you make an app available in local currency, Google Play customers will only see the app for sale in that currency. Customers will be charged in their local currency, but payment will be issued in the currency set in your Google Wallet Merchant Center account.
Another hardcoded workaround is to price items for countries with the same symbol, differently by a cent or so. When you retrieve the price of the item from google play upon purchasing and you know the retrieved currency symbol is one which is used in many countries ie. $. You then have a log of different prices on your backend server and correlate the purchase price with a specific country.