Initial commit
diff --git a/includes/class-wc-stripe-feature-flags.php b/includes/class-wc-stripe-feature-flags.php
new file mode 100644
index 0000000..69377bb
--- /dev/null
+++ b/includes/class-wc-stripe-feature-flags.php
@@ -0,0 +1,39 @@
+<?php
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+class WC_Stripe_Feature_Flags {
+ const UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME = 'upe_checkout_experience_enabled';
+
+ /**
+ * Checks whether UPE "preview" feature flag is enabled.
+ * This allows the merchant to enable/disable UPE checkout.
+ *
+ * @return bool
+ */
+ public static function is_upe_preview_enabled() {
+ return 'yes' === get_option( '_wcstripe_feature_upe', 'yes' );
+ }
+
+ /**
+ * Checks whether UPE is enabled.
+ *
+ * @return bool
+ */
+ public static function is_upe_checkout_enabled() {
+ $stripe_settings = get_option( 'woocommerce_stripe_settings', null );
+ return ! empty( $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] )
+ && 'yes' === $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ];
+ }
+
+ /**
+ * Checks whether UPE has been manually disabled by the merchant.
+ *
+ * @return bool
+ */
+ public static function did_merchant_disable_upe() {
+ $stripe_settings = get_option( 'woocommerce_stripe_settings', null );
+ return ! empty( $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] ) && 'disabled' === $stripe_settings[ self::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ];
+ }
+}