* Is Stripe payment enabled for the form. * * @since 1.8.4 * * @param array $form_data Form data. * * @return bool */ public static function is_payments_enabled( $form_data ) { return self::is_modern_settings_enabled( $form_data ) || ! empty( $form_data['payments']['stripe']['enable'] ); } /** * Is Stripe modern payment enabled for the form. * * @since 1.8.4 * * @param array $form_data Form data. * * @return bool */ public static function is_modern_settings_enabled( $form_data ) { return ! empty( $form_data['payments']['stripe']['enable_one_time'] ) || ! empty( $form_data['payments']['stripe']['enable_recurring'] ); } /** * Detect if form supports multiple subscription plans. * * @since 1.8.4 * * @param array $form_data Form data. * * @return bool */ public static function is_form_supports_multiple_recurring_plans( $form_data ) { return ! isset( $form_data['payments']['stripe'] ) || empty( $form_data['payments']['stripe']['recurring']['enable'] ); } /** * Determine if legacy payment settings should be displayed. * * @since 1.8.4 * * @param array $form_data Form data. * * @return bool */ public static function is_legacy_payment_settings( $form_data ) { $has_legacy_settings = ! self::is_form_supports_multiple_recurring_plans( $form_data ); // Return early if form has legacy payment settings. if ( $has_legacy_settings ) { return true; } $addon_compat = ( new StripeAddonCompatibility() )->init(); // Return early if Stripe Pro addon doesn't support modern settings (multiple plans). if ( $addon_compat && ! $addon_compat->is_supported_modern_settings() ) { return true; } return false; } /** * Determine whether the Link is supported. * * @link https://docs.stripe.com/payments/payment-methods/integration-options#payment-method-availability * * @since 1.8.8 * * @return bool */ public static function is_link_supported(): bool { return ! in_array( self::get_account_country(), [ 'br', 'in', 'id', 'th' ], true ); } /** * Get account country. * * @since 1.8.8 * * @return string */ private static function get_account_country(): string { $mode = self::get_stripe_mode(); return get_option( "wpforms_stripe_{$mode}_account_country", '' ); } }