Add blocked regions from global config for donations payments.

main
Alex Hart 2022-11-10 10:17:13 -04:00 zatwierdzone przez GitHub
rodzic 8f56c1baa5
commit c69b91c4db
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 59 dodań i 3 usunięć

Wyświetl plik

@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.components.settings.app.subscription
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.util.FeatureFlags
import org.thoughtcrime.securesms.util.LocaleFeatureFlags
import org.thoughtcrime.securesms.util.PlayServicesUtil
/**
@ -17,14 +18,14 @@ object InAppDonations {
* - Able to use PayPal and is in a region where it is able to be accepted.
*/
fun hasAtLeastOnePaymentMethodAvailable(): Boolean {
return isCreditCardAvailable() || isPayPalAvailable() || isPlayServicesAvailable()
return isCreditCardAvailable() || isPayPalAvailable() || isGooglePayAvailable()
}
/**
* Whether the user is in a region that supports credit cards, based off local phone number.
*/
fun isCreditCardAvailable(): Boolean {
return FeatureFlags.creditCardPayments()
return FeatureFlags.creditCardPayments() && !LocaleFeatureFlags.isCreditCardDisabled()
}
/**
@ -34,6 +35,13 @@ object InAppDonations {
return false
}
/**
* Whether the user is in a region that supports GooglePay, based off local phone number.
*/
private fun isGooglePayAvailable(): Boolean {
return isPlayServicesAvailable() && !LocaleFeatureFlags.isGooglePayDisabled()
}
/**
* Whether Play Services is available. This will *not* tell you whether a user has Google Pay set up, but is
* enough information to determine whether we can display Google Pay as an option.

Wyświetl plik

@ -103,6 +103,9 @@ public final class FeatureFlags {
public static final String CREDIT_CARD_PAYMENTS = "android.credit.card.payments.1";
private static final String PAYMENTS_REQUEST_ACTIVATE_FLOW = "android.payments.requestActivateFlow";
private static final String KEEP_MUTED_CHATS_ARCHIVED = "android.keepMutedChatsArchived";
public static final String GOOGLE_PAY_DISABLED_REGIONS = "global.donations.gpayDisabledRegions";
public static final String CREDIT_CARD_DISABLED_REGIONS = "global.donations.ccDisabledRegions";
public static final String PAYPAL_DISABLED_REGIONS = "global.donations.paypalDisabledRegions";
/**
* We will only store remote values for flags in this set. If you want a flag to be controllable
@ -157,7 +160,10 @@ public final class FeatureFlags {
SMS_EXPORT_MEGAPHONE_DELAY_DAYS,
CREDIT_CARD_PAYMENTS,
PAYMENTS_REQUEST_ACTIVATE_FLOW,
KEEP_MUTED_CHATS_ARCHIVED
KEEP_MUTED_CHATS_ARCHIVED,
GOOGLE_PAY_DISABLED_REGIONS,
CREDIT_CARD_DISABLED_REGIONS,
PAYPAL_DISABLED_REGIONS
);
@VisibleForTesting
@ -562,6 +568,27 @@ public final class FeatureFlags {
return getBoolean(KEEP_MUTED_CHATS_ARCHIVED, false);
}
/**
* @return Serialized list of regions in which Google Pay is disabled for donations
*/
public static @NonNull String googlePayDisabledRegions() {
return getString(GOOGLE_PAY_DISABLED_REGIONS, "*");
}
/**
* @return Serialized list of regions in which credit cards are disabled for donations
*/
public static @NonNull String creditCardDisabledRegions() {
return getString(CREDIT_CARD_DISABLED_REGIONS, "*");
}
/**
* @return Serialized list of regions in which PayPal is disabled for donations
*/
public static @NonNull String paypalDisabledRegions() {
return getString(PAYPAL_DISABLED_REGIONS, "*");
}
/** Only for rendering debug info. */
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
return new TreeMap<>(REMOTE_VALUES);

Wyświetl plik

@ -48,6 +48,27 @@ public final class LocaleFeatureFlags {
return isEnabled(releaseNoteUuid, countries);
}
/**
* @return Whether Google Pay is disabled in this region
*/
public static boolean isGooglePayDisabled() {
return isEnabled(FeatureFlags.GOOGLE_PAY_DISABLED_REGIONS, FeatureFlags.googlePayDisabledRegions());
}
/**
* @return Whether credit cards are disabled in this region
*/
public static boolean isCreditCardDisabled() {
return isEnabled(FeatureFlags.CREDIT_CARD_DISABLED_REGIONS, FeatureFlags.googlePayDisabledRegions());
}
/**
* @return Whether PayPal is disabled in this region
*/
public static boolean isPayPalDisabled() {
return isEnabled(FeatureFlags.PAYPAL_DISABLED_REGIONS, FeatureFlags.googlePayDisabledRegions());
}
/**
* Parses a comma-separated list of country codes colon-separated from how many buckets out of 1 million
* should be enabled to see this megaphone in that country code. At the end of the list, an optional