PluginProbe
PayPlug for WooCommerce (Official) / 3.1.0
PayPlug for WooCommerce (Official) v3.1.0
3.1.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 All 102 releases
← All changes | src/PayplugWoocommerce.php +205 -94 1.0.6 → 3.1.0 View file →
@@ -2,125 +2,236 @@
2 2
3 3 namespace Payplug\PayplugWoocommerce;
4 4
5 5 // Exit if accessed directly
6 -if ( ! defined( 'ABSPATH' ) ) {
7 - exit;
6 +if (!defined('ABSPATH')) {
7 + exit;
8 8 }
9 9
10 +use Payplug\PayplugWoocommerce\Admin\Ajax;
10 11 use Payplug\PayplugWoocommerce\Admin\Metabox;
11 12 use Payplug\PayplugWoocommerce\Admin\Notices;
13 +use Payplug\PayplugWoocommerce\Admin\SetupCallback;
12 14 use Payplug\PayplugWoocommerce\Admin\WoocommerceActions;
15 +use Payplug\PayplugWoocommerce\Front\Oney\OneyDisplay;
16 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugAmex;
17 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugApplePay;
18 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugBancontact;
19 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugBizum;
20 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugCreditCard;
21 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugIdeal;
22 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugMybank;
23 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugOney3x;
24 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugOney3xWithoutFees;
25 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugOney4x;
26 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugOney4xWithoutFees;
27 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugSatispay;
28 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugScalapay;
29 +use Payplug\PayplugWoocommerce\Gateway\Blocks\PayplugWero;
30 +use Payplug\PayplugWoocommerce\Traits\GatewayGetter;
31 +use Payplug\PayplugWoocommerce\Traits\ServiceGetter;
13 32
14 -class PayplugWoocommerce {
33 +class PayplugWoocommerce
34 +{
35 + use ServiceGetter;
36 + use GatewayGetter;
15 37
16 - /**
17 - * @var PayplugWoocommerce
18 - */
19 - private static $instance;
38 + /**
39 + * @var PayplugWoocommerce
40 + */
41 + private static $instance;
20 42
21 - /**
22 - * PayPlug admin notices
23 - *
24 - * @var Notices
25 - */
26 - public $notices;
43 + /**
44 + * PayPlug admin notices
45 + *
46 + * @var Notices
47 + */
48 + public $notices;
27 49
28 - /**
29 - * PayPlug metabox
30 - *
31 - * @var Metabox
32 - */
33 - public $metabox;
50 + /**
51 + * PayPlug metabox
52 + *
53 + * @var Metabox
54 + */
55 + public $metabox;
34 56
35 - /**
36 - * Custom woocommerce actions
37 - *
38 - * @var WoocommerceActions
39 - */
40 - public $actions;
57 + /**
58 + * Custom woocommerce actions
59 + *
60 + * @var WoocommerceActions
61 + */
62 + public $actions;
41 63
42 - /**
43 - * @var PayplugWoocommerceRequest
44 - */
45 - public $requests;
64 + /**
65 + * @var PayplugWoocommerceRequest
66 + */
67 + public $requests;
46 68
47 - /**
48 - * Get the singleton instance.
49 - *
50 - * @return PayplugWoocommerce
51 - */
52 - public static function get_instance() {
53 - if ( is_null( self::$instance ) ) {
54 - self::$instance = new static();
55 - }
69 + /**
70 + * Ajax actions handler
71 + *
72 + * @var Ajax
73 + */
74 + public $ajax;
56 75
57 - return self::$instance;
58 - }
76 + /**
77 + * PayPlug Setup authentifications.
78 + *
79 + * @var SetupCallback
80 + */
81 + public $setup_callback;
59 82
60 - /**
61 - * Singleton instance can't be cloned.
62 - */
63 - private function __clone() {
64 - }
83 + /**
84 + * Get the singleton instance.
85 + *
86 + * @return PayplugWoocommerce
87 + */
88 + public static function get_instance()
89 + {
90 + if (is_null(self::$instance)) {
91 + self::$instance = new static();
92 + }
65 93
66 - /**
67 - * Singleton instance can't be serialized.
68 - */
69 - private function __wakeup() {
70 - }
94 + return self::$instance;
95 + }
71 96
72 - /**
73 - * PayplugWoocommerce constructor.
74 - */
75 - private function __construct() {
97 + /**
98 + * Singleton instance can't be cloned.
99 + */
100 + private function __clone()
101 + {
102 + }
76 103
77 - // Bail early if WooCommerce is not activated
78 - if ( ! defined( 'WC_VERSION' ) ) {
79 - add_action( 'admin_notices', function () {
80 - ?>
104 + /**
105 + * Singleton instance can't be serialized.
106 + */
107 + public function __wakeup(): void
108 + {
109 + }
110 +
111 + /**
112 + * PayplugWoocommerce constructor.
113 + */
114 + private function __construct()
115 + {
116 + // Bail early if WooCommerce is not activated
117 + if (!defined('WC_VERSION')) {
118 + add_action('admin_notices', function (): void {
119 + ?>
81 120 <div id="message" class="notice notice-error">
82 - <p><?php _e( 'PayPlug requires an active version of WooCommerce', 'payplug' ); ?></p>
121 + <p><?php _e('PayPlug requires an active version of WooCommerce', 'payplug'); ?></p>
83 122 </div>
84 123 <?php
85 - } );
124 + });
86 125
87 - return;
88 - }
126 + return;
127 + }
89 128
90 - $this->notices = new Notices();
91 - $this->metabox = new Metabox();
92 - $this->actions = new WoocommerceActions();
93 - $this->requests = new PayplugWoocommerceRequest();
129 + $this->check_upgrade();
94 130
95 - add_action( 'woocommerce_payment_gateways', [ $this, 'register_payplug_gateway' ] );
96 - add_filter( 'plugin_action_links_' . PAYPLUG_GATEWAY_PLUGIN_BASENAME, [ $this, 'plugin_action_links' ] );
97 - }
131 + if (PayplugWoocommerceHelper::is_pre_30()) {
132 + require_once PAYPLUG_GATEWAY_PLUGIN_DIR . '/woocommerce-compat.php';
133 + }
98 134
99 - /**
100 - * Register PayPlug gateway.
101 - *
102 - * @param $methods
103 - *
104 - * @return array
105 - */
106 - public function register_payplug_gateway( $methods ) {
107 - $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGateway';
135 + $this->notices = new Notices();
136 + $this->metabox = new Metabox();
137 + $this->actions = new WoocommerceActions();
138 + $this->requests = new PayplugWoocommerceRequest();
139 + new Front\ApplePay();
140 + $this->ajax = new Ajax();
108 141
109 - return $methods;
110 - }
142 + $this->setup_callback = new SetupCallback();
111 143
112 - /**
113 - * Add additional action links.
114 - *
115 - * @param array $links
116 - *
117 - * @return array
118 - */
119 - public function plugin_action_links( $links = [] ) {
120 - $plugin_links = [
121 - '<a href="' . esc_url( PayplugWoocommerceHelper::get_setting_link() ) . '">' . esc_html__( 'Settings', 'payplug' ) . '</a>',
122 - ];
144 + if (PayplugWoocommerceHelper::show_oney_popup()) {
145 + $this->animationHandlers();
146 + }
123 147
124 - return array_merge( $plugin_links, $links );
125 - }
126 -}
148 + add_action('woocommerce_payment_gateways', [$this, 'register_payplug_gateway']);
149 +
150 + // Registers WooCommerce Blocks integration.
151 + add_action('woocommerce_blocks_loaded', [$this, 'woocommerce_gateways_block_support']);
152 +
153 + add_filter('plugin_action_links_' . PAYPLUG_GATEWAY_PLUGIN_BASENAME, [$this, 'plugin_action_links']);
154 + }
155 +
156 + /**
157 + * Register PayPlug gateway.
158 + *
159 + * @param $methods
160 + *
161 + * @return array
162 + */
163 + public function register_payplug_gateway($methods)
164 + {
165 + $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugCreditCard';
166 + $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney3x';
167 + $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney4x';
168 + $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney3xWithoutFees';
169 + $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney4xWithoutFees';
170 + $methods[] = __NAMESPACE__ . '\\Gateway\\Bancontact';
171 + $methods[] = __NAMESPACE__ . '\\Gateway\\AmericanExpress';
172 + $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Mybank';
173 + $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Ideal';
174 + $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Satispay';
175 + $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Wero';
176 + $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Bizum';
177 + $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Scalapay';
178 +
179 + $methods[] = __NAMESPACE__ . '\\Controller\\ApplePay';
180 +
181 + return $methods;
182 + }
183 +
184 + /**
185 + * Add additional action links.
186 + *
187 + * @param array $links
188 + *
189 + * @return array
190 + */
191 + public function plugin_action_links($links = [])
192 + {
193 + $plugin_links = [
194 + '<a href="' . esc_url(PayplugWoocommerceHelper::get_setting_link()) . '">' . esc_html__('Settings', 'payplug') . '</a>',
195 + ];
196 +
197 + return array_merge($plugin_links, $links);
198 + }
199 +
200 + public function animationHandlers(): void
201 + {
202 + new OneyDisplay();
203 + }
204 +
205 + /**
206 + * Registers WooCommerce Blocks integration.
207 + */
208 + public function woocommerce_gateways_block_support(): void
209 + {
210 + if (class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) {
211 + add_action(
212 + 'woocommerce_blocks_payment_method_type_registration',
213 + function (\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry): void {
214 + $payment_method_registry->register(new PayplugCreditCard());
215 + $payment_method_registry->register(new PayplugBancontact());
216 + $payment_method_registry->register(new PayplugSatispay());
217 + $payment_method_registry->register(new PayplugAmex());
218 + $payment_method_registry->register(new PayplugIdeal());
219 + $payment_method_registry->register(new PayplugMybank());
220 + $payment_method_registry->register(new PayplugWero());
221 + $payment_method_registry->register(new PayplugBizum());
222 + $payment_method_registry->register(new PayplugScalapay());
223 + $payment_method_registry->register(new PayplugApplePay());
224 + $payment_method_registry->register(new PayplugOney3x());
225 + $payment_method_registry->register(new PayplugOney4x());
226 + $payment_method_registry->register(new PayplugOney3xWithoutFees());
227 + $payment_method_registry->register(new PayplugOney4xWithoutFees());
228 + }
229 + );
230 + }
231 + }
232 +
233 + private function check_upgrade()
234 + {
235 + return $this->get_service('upgrade')->run_upgrade();
236 + }
237 +}