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