IAB improvements

pull/197/head
M66B 4 years ago
parent 45314498b0
commit 7cb43ba587

@ -165,7 +165,7 @@ public class ActivityBilling extends ActivityBase implements /*PurchasesUpdatedL
} }
private static String getResponse(Context context) throws NoSuchAlgorithmException { private static String getResponse(Context context) throws NoSuchAlgorithmException {
return Helper.sha256(BuildConfig.APPLICATION_ID + getChallenge(context)); return Helper.sha256(BuildConfig.APPLICATION_ID.replace(".debug", "") + getChallenge(context));
} }
static boolean activatePro(Context context, Uri data) throws NoSuchAlgorithmException { static boolean activatePro(Context context, Uri data) throws NoSuchAlgorithmException {
@ -229,7 +229,9 @@ public class ActivityBilling extends ActivityBase implements /*PurchasesUpdatedL
// reportError(result, "IAB launch billing flow"); // reportError(result, "IAB launch billing flow");
} else } else
try { try {
Uri uri = Uri.parse(BuildConfig.PRO_FEATURES_URI + "?challenge=" + getChallenge(this)); Uri uri = Uri.parse(BuildConfig.PRO_FEATURES_URI +
"?challenge=" + getChallenge(this) +
"&version=" + BuildConfig.VERSION_CODE);
Helper.view(this, uri, true); Helper.view(this, uri, true);
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
Log.unexpectedError(getSupportFragmentManager(), ex); Log.unexpectedError(getSupportFragmentManager(), ex);
@ -375,6 +377,7 @@ public class ActivityBilling extends ActivityBase implements /*PurchasesUpdatedL
" purchased=" + isPurchased(purchase) + " purchased=" + isPurchased(purchase) +
" valid=" + isPurchaseValid(purchase) + " valid=" + isPurchaseValid(purchase) +
" time=" + new Date(time)); " time=" + new Date(time));
Log.i("IAB json=" + purchase.getOriginalJson());
//if (new Date().getTime() - purchase.getPurchaseTime() > 3 * 60 * 1000L) { //if (new Date().getTime() - purchase.getPurchaseTime() > 3 * 60 * 1000L) {
// consumePurchase(purchase); // consumePurchase(purchase);
@ -510,17 +513,26 @@ public class ActivityBilling extends ActivityBase implements /*PurchasesUpdatedL
if (result == null) if (result == null)
message = stage; message = stage;
else { else {
message = getBillingResponseText(result);
String debug = result.getDebugMessage(); String debug = result.getDebugMessage();
message = getBillingResponseText(result) + (debug == null ? "" : " " + debug) + " " + stage; if (!TextUtils.isEmpty(debug))
message += " " + debug;
message += " " + stage;
}
EntityLog.log(this, message);
if (result != null) {
// https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponse#service_disconnected // https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponse#service_disconnected
if (result.getResponseCode() == BillingClient.BillingResponseCode.SERVICE_DISCONNECTED) if (result.getResponseCode() == BillingClient.BillingResponseCode.SERVICE_DISCONNECTED)
retry(60); retry(60);
}
EntityLog.log(this, message); if (result.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED)
return;
}
if (result.getResponseCode() != BillingClient.BillingResponseCode.USER_CANCELED)
for (IBillingListener listener : listeners) for (IBillingListener listener : listeners)
listener.onError(message); listener.onError(message);
} }

@ -229,7 +229,9 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
reportError(result, "IAB launch billing flow"); reportError(result, "IAB launch billing flow");
} else } else
try { try {
Uri uri = Uri.parse(BuildConfig.PRO_FEATURES_URI + "?challenge=" + getChallenge(this)); Uri uri = Uri.parse(BuildConfig.PRO_FEATURES_URI +
"?challenge=" + getChallenge(this) +
"&version=" + BuildConfig.VERSION_CODE);
Helper.view(this, uri, true); Helper.view(this, uri, true);
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
Log.unexpectedError(getSupportFragmentManager(), ex); Log.unexpectedError(getSupportFragmentManager(), ex);

Loading…
Cancel
Save