Add locale based feature flags for iDEAL / SEPA donations.
This commit is contained in:
parent
dddd0e7b71
commit
162ca3e21e
3 changed files with 28 additions and 7 deletions
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components.settings.app.subscription
|
|||
import org.signal.donations.PaymentSourceType
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.DonateToSignalType
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.Environment
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.LocaleFeatureFlags
|
||||
|
||||
|
@ -66,14 +67,14 @@ object InAppDonations {
|
|||
* Whether the user is in a region which supports SEPA Debit transfers, based off local phone number.
|
||||
*/
|
||||
fun isSEPADebitAvailable(): Boolean {
|
||||
return FeatureFlags.sepaDebitDonations()
|
||||
return Environment.IS_STAGING || (FeatureFlags.sepaDebitDonations() && LocaleFeatureFlags.isSepaEnabled())
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the user is in a region which supports IDEAL transfers, based off local phone number.
|
||||
*/
|
||||
fun isIDEALAvailable(): Boolean {
|
||||
return FeatureFlags.idealDonations()
|
||||
return Environment.IS_STAGING || (FeatureFlags.idealDonations() && LocaleFeatureFlags.isIdealEnabled())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +82,7 @@ object InAppDonations {
|
|||
* and donation type.
|
||||
*/
|
||||
fun isSEPADebitAvailableForDonateToSignalType(donateToSignalType: DonateToSignalType): Boolean {
|
||||
return donateToSignalType != DonateToSignalType.GIFT && FeatureFlags.sepaDebitDonations()
|
||||
return donateToSignalType != DonateToSignalType.GIFT && isSEPADebitAvailable()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,6 +90,6 @@ object InAppDonations {
|
|||
* donation type
|
||||
*/
|
||||
fun isIDEALAvailbleForDonateToSignalType(donateToSignalType: DonateToSignalType): Boolean {
|
||||
return donateToSignalType != DonateToSignalType.GIFT && FeatureFlags.idealDonations()
|
||||
return donateToSignalType != DonateToSignalType.GIFT && isIDEALAvailable()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,8 @@ public final class FeatureFlags {
|
|||
public static final String CRASH_PROMPT_CONFIG = "android.crashPromptConfig";
|
||||
private static final String SEPA_DEBIT_DONATIONS = "android.sepa.debit.donations";
|
||||
private static final String IDEAL_DONATIONS = "android.ideal.donations";
|
||||
public static final String IDEAL_ENABLED_REGIONS = "global.donations.idealEnabledRegions";
|
||||
public static final String SEPA_ENABLED_REGIONS = "global.donations.sepaEnabledRegions";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
|
@ -189,7 +191,9 @@ public final class FeatureFlags {
|
|||
CRASH_PROMPT_CONFIG,
|
||||
BLOCK_SSE,
|
||||
SEPA_DEBIT_DONATIONS,
|
||||
IDEAL_DONATIONS
|
||||
IDEAL_DONATIONS,
|
||||
IDEAL_ENABLED_REGIONS,
|
||||
SEPA_ENABLED_REGIONS
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -689,11 +693,19 @@ public final class FeatureFlags {
|
|||
* WARNING: This feature is under heavy development and is *not* ready for wider use.
|
||||
*/
|
||||
public static boolean sepaDebitDonations() {
|
||||
return getBoolean(SEPA_DEBIT_DONATIONS, Environment.IS_STAGING);
|
||||
return getBoolean(SEPA_DEBIT_DONATIONS, false);
|
||||
}
|
||||
|
||||
public static boolean idealDonations() {
|
||||
return getBoolean(IDEAL_DONATIONS, Environment.IS_STAGING);
|
||||
return getBoolean(IDEAL_DONATIONS, false);
|
||||
}
|
||||
|
||||
public static String idealEnabledRegions() {
|
||||
return getString(IDEAL_ENABLED_REGIONS, "");
|
||||
}
|
||||
|
||||
public static String sepaEnabledRegions() {
|
||||
return getString(SEPA_ENABLED_REGIONS, "");
|
||||
}
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
|
|
|
@ -65,6 +65,14 @@ public final class LocaleFeatureFlags {
|
|||
return isEnabled(FeatureFlags.PAYPAL_DISABLED_REGIONS, FeatureFlags.paypalDisabledRegions());
|
||||
}
|
||||
|
||||
public static boolean isIdealEnabled() {
|
||||
return isEnabled(FeatureFlags.IDEAL_ENABLED_REGIONS, FeatureFlags.idealEnabledRegions());
|
||||
}
|
||||
|
||||
public static boolean isSepaEnabled() {
|
||||
return isEnabled(FeatureFlags.SEPA_ENABLED_REGIONS, FeatureFlags.sepaEnabledRegions());
|
||||
}
|
||||
|
||||
public static boolean isDelayedNotificationPromptEnabled() {
|
||||
return FeatureFlags.internalUser() || isEnabled(FeatureFlags.PROMPT_FOR_NOTIFICATION_LOGS, FeatureFlags.promptForDelayedNotificationLogs());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue