gateway = $gateway; } /** * Check if all gateway requirements are fulfilled. * * @return bool */ public function satisfy_requirements() { return $this->valid_php() && $this->valid_curl() && $this->valid_openssl() && $this->valid_currency() && $this->valid_account(); } /** * @return string */ public function curl_requirement() { return ( $this->valid_curl() ) ? '

' . __( 'The PHP cURL extension is installed and activated on your server.', 'payplug' ) . '

' : '

' . __( 'The PHP cURL extension must be installed and activated on your server.', 'payplug' ) . '

'; } /** * @return string */ public function php_requirement() { return ( $this->valid_php() ) ? '

' . __( 'The PHP version on your server is valid.', 'payplug' ) . '

' /* translators: %s: minimum required PHP version */ : '

' . sprintf( __( 'The PHP version on your server is not supported. Your server must run PHP %s or greater.', 'payplug' ), self::PHP_MIN ) . '

'; } /** * @return string */ public function openssl_requirement() { return ( $this->valid_openssl() ) ? '

' . __( 'OpenSSL is up to date.', 'payplug' ) . '

' /* translators: %s: minimum required OpenSSL version */ : '

' . sprintf( __( 'OpenSSL is not up to date. Please update to OpenSSL %s or later.', 'payplug' ), self::OPENSSL_MIN . ' ( ' . self::OPENSSL_MIN_TEXT . ' )' ) . '

'; } /** * @return string */ public function currency_requirement() { return ( $this->valid_currency() ) ? '

' . __( 'Your shop currency has been set up with Euro.', 'payplug' ) . '

' : '

' . __( 'Your shop currency must be set up with Euro.', 'payplug' ) . '

'; } /** * @return string */ public function account_requirement() { return ( $this->valid_account() ) ? '

' . __( 'You are logged in with your PayPlug account.', 'payplug' ) . '

' : '

' . __( 'You must be logged in with your PayPlug account.', 'payplug' ) . '

'; } /** * Check if CURL is available and support SSL * * @return bool */ public function valid_curl() { if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) { return false; } // Also Check for SSL support $curl_version = curl_version(); if ( ! ( CURL_VERSION_SSL & $curl_version['features'] ) ) { return false; } return true; } /** * Check if PHP version is equal or above the minimum supported. * * @return bool */ public function valid_php() { return version_compare( PHP_VERSION, self::PHP_MIN, '>=' ); } /** * Check if OPENSSL version is equal or above the minimum supported. * * @return bool */ public function valid_openssl() { return OPENSSL_VERSION_NUMBER >= self::OPENSSL_MIN; } /** * Check if the shop currency is Euro. * * @return bool */ public function valid_currency() { return 'EUR' === get_woocommerce_currency(); } /** * Check if the user is logged in. * * @return bool */ public function valid_account() { return $this->gateway->user_logged_in(); } }