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 +201 -103 1.0.19 → 3.1.0 View file →
@@ -2,138 +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 10 use Payplug\PayplugWoocommerce\Admin\Ajax;
11 11 use Payplug\PayplugWoocommerce\Admin\Metabox;
12 12 use Payplug\PayplugWoocommerce\Admin\Notices;
13 +use Payplug\PayplugWoocommerce\Admin\SetupCallback;
13 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;
14 32
15 -class PayplugWoocommerce {
33 +class PayplugWoocommerce
34 +{
35 + use ServiceGetter;
36 + use GatewayGetter;
16 37
17 - /**
18 - * @var PayplugWoocommerce
19 - */
20 - private static $instance;
38 + /**
39 + * @var PayplugWoocommerce
40 + */
41 + private static $instance;
21 42
22 - /**
23 - * PayPlug admin notices
24 - *
25 - * @var Notices
26 - */
27 - public $notices;
43 + /**
44 + * PayPlug admin notices
45 + *
46 + * @var Notices
47 + */
48 + public $notices;
28 49
29 - /**
30 - * PayPlug metabox
31 - *
32 - * @var Metabox
33 - */
34 - public $metabox;
50 + /**
51 + * PayPlug metabox
52 + *
53 + * @var Metabox
54 + */
55 + public $metabox;
35 56
36 - /**
37 - * Custom woocommerce actions
38 - *
39 - * @var WoocommerceActions
40 - */
41 - public $actions;
57 + /**
58 + * Custom woocommerce actions
59 + *
60 + * @var WoocommerceActions
61 + */
62 + public $actions;
42 63
43 - /**
44 - * @var PayplugWoocommerceRequest
45 - */
46 - public $requests;
64 + /**
65 + * @var PayplugWoocommerceRequest
66 + */
67 + public $requests;
47 68
48 - /**
49 - * Ajax actions handler
50 - *
51 - * @var Ajax
52 - */
53 - public $ajax;
69 + /**
70 + * Ajax actions handler
71 + *
72 + * @var Ajax
73 + */
74 + public $ajax;
54 75
55 - /**
56 - * Get the singleton instance.
57 - *
58 - * @return PayplugWoocommerce
59 - */
60 - public static function get_instance() {
61 - if ( is_null( self::$instance ) ) {
62 - self::$instance = new static();
63 - }
76 + /**
77 + * PayPlug Setup authentifications.
78 + *
79 + * @var SetupCallback
80 + */
81 + public $setup_callback;
64 82
65 - return self::$instance;
66 - }
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 + }
67 93
68 - /**
69 - * Singleton instance can't be cloned.
70 - */
71 - private function __clone() {
72 - }
94 + return self::$instance;
95 + }
73 96
74 - /**
75 - * Singleton instance can't be serialized.
76 - */
77 - private function __wakeup() {
78 - }
97 + /**
98 + * Singleton instance can't be cloned.
99 + */
100 + private function __clone()
101 + {
102 + }
79 103
80 - /**
81 - * PayplugWoocommerce constructor.
82 - */
83 - private function __construct() {
104 + /**
105 + * Singleton instance can't be serialized.
106 + */
107 + public function __wakeup(): void
108 + {
109 + }
84 110
85 - // Bail early if WooCommerce is not activated
86 - if ( ! defined( 'WC_VERSION' ) ) {
87 - add_action( 'admin_notices', function () {
88 - ?>
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 + ?>
89 120 <div id="message" class="notice notice-error">
90 - <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>
91 122 </div>
92 123 <?php
93 - } );
124 + });
94 125
95 - return;
96 - }
126 + return;
127 + }
97 128
98 - if ( PayplugWoocommerceHelper::is_pre_30() ) {
99 - require_once PAYPLUG_GATEWAY_PLUGIN_DIR . '/woocommerce-compat.php';
100 - }
129 + $this->check_upgrade();
101 130
102 - $this->notices = new Notices();
103 - $this->metabox = new Metabox();
104 - $this->actions = new WoocommerceActions();
105 - $this->requests = new PayplugWoocommerceRequest();
106 - $this->ajax = new Ajax();
131 + if (PayplugWoocommerceHelper::is_pre_30()) {
132 + require_once PAYPLUG_GATEWAY_PLUGIN_DIR . '/woocommerce-compat.php';
133 + }
107 134
108 - add_action( 'woocommerce_payment_gateways', [ $this, 'register_payplug_gateway' ] );
109 - add_filter( 'plugin_action_links_' . PAYPLUG_GATEWAY_PLUGIN_BASENAME, [ $this, 'plugin_action_links' ] );
110 - }
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();
111 141
112 - /**
113 - * Register PayPlug gateway.
114 - *
115 - * @param $methods
116 - *
117 - * @return array
118 - */
119 - public function register_payplug_gateway( $methods ) {
120 - $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGateway';
142 + $this->setup_callback = new SetupCallback();
121 143
122 - return $methods;
123 - }
144 + if (PayplugWoocommerceHelper::show_oney_popup()) {
145 + $this->animationHandlers();
146 + }
124 147
125 - /**
126 - * Add additional action links.
127 - *
128 - * @param array $links
129 - *
130 - * @return array
131 - */
132 - public function plugin_action_links( $links = [] ) {
133 - $plugin_links = [
134 - '<a href="' . esc_url( PayplugWoocommerceHelper::get_setting_link() ) . '">' . esc_html__( 'Settings', 'payplug' ) . '</a>',
135 - ];
148 + add_action('woocommerce_payment_gateways', [$this, 'register_payplug_gateway']);
136 149
137 - return array_merge( $plugin_links, $links );
138 - }
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 + }
139 237 }