diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index f3a49bc143..71810016a6 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -904,6 +904,7 @@ public class OsmandSettings { public static final String BILLING_USER_DONATION_NONE_PARAMETER = "none"; public final OsmandPreference BILLING_USER_ID = new StringPreference("billing_user_id", "").makeGlobal(); + public final OsmandPreference BILLING_USER_TOKEN = new StringPreference("billing_user_token", "").makeGlobal(); public final OsmandPreference BILLING_USER_NAME = new StringPreference("billing_user_name", "").makeGlobal(); public final OsmandPreference BILLING_USER_EMAIL = new StringPreference("billing_user_email", "").makeGlobal(); public final OsmandPreference BILLING_USER_COUNTRY = new StringPreference("billing_user_country", "").makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java index 5011514b2d..c047a82f1c 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppHelper.java @@ -231,7 +231,7 @@ public class InAppHelper { boolean needSendToken = false; if (!isDeveloperVersion && liveUpdatesPurchase != null) { OsmandSettings settings = ctx.getSettings(); - if (Algorithms.isEmpty(settings.BILLING_USER_ID.get()) + if ((Algorithms.isEmpty(settings.BILLING_USER_ID.get()) || Algorithms.isEmpty(settings.BILLING_USER_TOKEN.get())) && !Algorithms.isEmpty(liveUpdatesPurchase.getDeveloperPayload())) { String payload = liveUpdatesPurchase.getDeveloperPayload(); if (!Algorithms.isEmpty(payload)) { @@ -241,6 +241,7 @@ public class InAppHelper { } if (arr.length > 1) { token = arr[1]; + settings.BILLING_USER_TOKEN.set(token); } } } @@ -324,8 +325,9 @@ public class InAppHelper { try { JSONObject obj = new JSONObject(response); userId = obj.getString("userid"); - token = obj.getString("token"); ctx.getSettings().BILLING_USER_ID.set(userId); + token = obj.getString("token"); + ctx.getSettings().BILLING_USER_TOKEN.set(token); logDebug("UserId=" + userId); } catch (JSONException e) { String message = "JSON parsing error: " @@ -432,6 +434,7 @@ public class InAppHelper { private void sendToken(String purchaseToken, final OnRequestResultListener listener) { final String userId = ctx.getSettings().BILLING_USER_ID.get(); + final String token = ctx.getSettings().BILLING_USER_TOKEN.get(); final String email = ctx.getSettings().BILLING_USER_EMAIL.get(); try { Map parameters = new HashMap<>();