Fix error when trying to create payment in languages which use , instead of .
This commit is contained in:
parent
0d4e109c72
commit
18cf55b156
2 changed files with 11 additions and 2 deletions
|
@ -5,6 +5,7 @@ import androidx.annotation.NonNull;
|
|||
import java.math.BigDecimal;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FiatMoney {
|
||||
private final BigDecimal amount;
|
||||
|
@ -37,7 +38,14 @@ public class FiatMoney {
|
|||
* @return amount, rounded to the default fractional amount.
|
||||
*/
|
||||
public @NonNull String getDefaultPrecisionString() {
|
||||
NumberFormat formatter = NumberFormat.getInstance();
|
||||
return getDefaultPrecisionString(Locale.getDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return amount, rounded to the default fractional amount.
|
||||
*/
|
||||
public @NonNull String getDefaultPrecisionString(@NonNull Locale locale) {
|
||||
NumberFormat formatter = NumberFormat.getInstance(locale);
|
||||
formatter.setMinimumFractionDigits(currency.getDefaultFractionDigits());
|
||||
formatter.setGroupingUsed(false);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.json.JSONException
|
|||
import org.json.JSONObject
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.money.FiatMoney
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Entrypoint for Google Pay APIs
|
||||
|
@ -124,7 +125,7 @@ class GooglePayApi(
|
|||
put("currencyCode", price.currency.currencyCode)
|
||||
put("countryCode", "US")
|
||||
put("totalPriceStatus", "FINAL")
|
||||
put("totalPrice", price.defaultPrecisionString)
|
||||
put("totalPrice", price.getDefaultPrecisionString(Locale.US))
|
||||
put("totalPriceLabel", label)
|
||||
put("checkoutOption", "COMPLETE_IMMEDIATE_PURCHASE")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue