PluginProbe
PayPlug for WooCommerce (Official) / 2.10.0
PayPlug for WooCommerce (Official) v2.10.0
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
payplug / src / Gateway / PayplugGatewayRequirements.php

PayplugGatewayRequirements.php in PayPlug for WooCommerce (Official) 2.10.0, at src/Gateway/PayplugGatewayRequirements.php

166 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Payplug\PayplugWoocommerce\Gateway;
4
5 use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper;
6
7 // Exit if accessed directly
8 use const OPENSSL_VERSION_TEXT;
9 use const PHP_VERSION;
10 use function sprintf;
11 use function var_dump;
12 use Payplug\PayplugWoocommerce\Gateway\PayplugPermissions;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 class PayplugGatewayRequirements {
19
20 const PHP_MIN = '5.6';
21 const OPENSSL_MIN = 268439567;
22 const OPENSSL_MIN_TEXT = 'OpenSSL 1.0.1 14 Mar 2012';
23
24 /**
25 * @var PayplugGateway
26 */
27 private $gateway;
28
29 /**
30 * Gateway settings.
31 *
32 * @var array
33 */
34 protected $settings;
35
36 /**
37 * PayplugGatewayRequirements constructor.
38 *
39 * @param PayplugGateway $gateway
40 */
41 public function __construct( PayplugGateway $gateway ) {
42 $this->gateway = $gateway;
43 $this->settings = get_option( 'woocommerce_payplug_settings', [] );
44 }
45
46 /**
47 * Check if all gateway requirements are fulfilled.
48 *
49 * @return bool
50 */
51 public function satisfy_requirements() {
52 return $this->valid_php()
53 && $this->valid_curl()
54 && $this->valid_openssl()
55 && $this->valid_currency()
56 && $this->valid_account();
57 }
58
59 /**
60 * @return array
61 */
62 public function curl_requirement() {
63 return array(
64 "status" => $this->valid_curl(),
65 "text" => __("payplug_section_status_curl", "payplug")
66 );
67 }
68
69 /**
70 * @return array
71 */
72 public function php_requirement() {
73 return array(
74 "status" => $this->valid_php(),
75 "text" => __("payplug_section_status_php", "payplug")
76 );
77
78 }
79
80 /**
81 * @return array
82 */
83 public function openssl_requirement() {
84 return array(
85 "status" => $this->valid_openssl(),
86 "text" => __("payplug_section_status_ssl", "payplug")
87 );
88 }
89
90 /**
91 * @return array
92 */
93 public function currency_requirement() {
94 return array(
95 "status" => $this->valid_currency(),
96 "text" => __("payplug_section_status_currency", "payplug")
97 );
98 }
99
100 /**
101 * @return array
102 */
103 public function account_requirement() {
104 return array(
105 "status" => $this->valid_account(),
106 "text" => __("payplug_section_status_account", "payplug")
107 );
108 }
109
110 /**
111 * Check if CURL is available and support SSL
112 *
113 * @return bool
114 */
115 public function valid_curl() {
116 if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) {
117 return false;
118 }
119
120 // Also Check for SSL support
121 $curl_version = curl_version();
122 if ( ! ( CURL_VERSION_SSL & $curl_version['features'] ) ) {
123 return false;
124 }
125
126 return true;
127 }
128
129 /**
130 * Check if PHP version is equal or above the minimum supported.
131 *
132 * @return bool
133 */
134 public function valid_php() {
135 return version_compare( PHP_VERSION, self::PHP_MIN, '>=' );
136 }
137
138 /**
139 * Check if OPENSSL version is equal or above the minimum supported.
140 *
141 * @return bool
142 */
143 public function valid_openssl() {
144 return OPENSSL_VERSION_NUMBER >= self::OPENSSL_MIN;
145 }
146
147 /**
148 * Check if the shop currency is Euro.
149 *
150 * @return bool
151 */
152 public function valid_currency() {
153 return 'EUR' === get_woocommerce_currency();
154 }
155
156 /**
157 * Check if the user is logged in.
158 *
159 * @return bool
160 */
161 public function valid_account() {
162 return $this->gateway->user_logged_in();
163 }
164
165 }
166