check_upgrade(); if (PayplugWoocommerceHelper::is_pre_30()) { require_once PAYPLUG_GATEWAY_PLUGIN_DIR . '/woocommerce-compat.php'; } $this->notices = new Notices(); $this->metabox = new Metabox(); $this->actions = new WoocommerceActions(); $this->requests = new PayplugWoocommerceRequest(); new Front\ApplePay(); $this->ajax = new Ajax(); $this->setup_callback = new SetupCallback(); if (PayplugWoocommerceHelper::show_oney_popup()) { $this->animationHandlers(); } add_action('woocommerce_payment_gateways', [$this, 'register_payplug_gateway']); // Registers WooCommerce Blocks integration. add_action('woocommerce_blocks_loaded', [$this, 'woocommerce_gateways_block_support']); add_filter('plugin_action_links_' . PAYPLUG_GATEWAY_PLUGIN_BASENAME, [$this, 'plugin_action_links']); } /** * Register PayPlug gateway. * * @param $methods * * @return array */ public function register_payplug_gateway($methods) { $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugCreditCard'; $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney3x'; $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney4x'; $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney3xWithoutFees'; $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney4xWithoutFees'; $methods[] = __NAMESPACE__ . '\\Gateway\\Bancontact'; $methods[] = __NAMESPACE__ . '\\Gateway\\AmericanExpress'; $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Mybank'; $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Ideal'; $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Satispay'; $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Wero'; $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Bizum'; $methods[] = __NAMESPACE__ . '\\Gateway\\PPRO\\Scalapay'; $methods[] = __NAMESPACE__ . '\\Controller\\ApplePay'; return $methods; } /** * Add additional action links. * * @param array $links * * @return array */ public function plugin_action_links($links = []) { $plugin_links = [ '' . esc_html__('Settings', 'payplug') . '', ]; return array_merge($plugin_links, $links); } public function animationHandlers() { $options = get_option('woocommerce_payplug_settings', []); //if live and don't have country setted on the option if (!isset($options['company_iso'])) { $options['company_iso'] = PayplugWoocommerceHelper::UpdateCountryOption($options); } //failsafe if (empty($options['company_iso']) || !isset($options['payment_methods']['configuration']['oney']['with_fees'])) { return; } if (!class_exists('\\Payplug\\PayplugWoocommerce\\Front\\PayplugOney\\Country\\Oney' . $options['company_iso'])) { return; } $oney_type = $options['payment_methods']['configuration']['oney']['with_fees'] ? 'with_fees' : 'without_fees'; switch ($oney_type) { case 'without_fees' : $class = 'PayplugGatewayOney3xWithoutFees'; break; default: $class = 'PayplugGatewayOney3x'; break; } new OneyAnimation($oney_type, $class); } /** * Registers WooCommerce Blocks integration. */ public function woocommerce_gateways_block_support() { if (class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) { add_action( 'woocommerce_blocks_payment_method_type_registration', function (\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) { $payment_method_registry->register(new PayplugCreditCard()); $payment_method_registry->register(new PayplugBancontact()); $payment_method_registry->register(new PayplugSatispay()); $payment_method_registry->register(new PayplugAmex()); $payment_method_registry->register(new PayplugIdeal()); $payment_method_registry->register(new PayplugMybank()); $payment_method_registry->register(new PayplugWero()); $payment_method_registry->register(new PayplugBizum()); $payment_method_registry->register(new PayplugScalapay()); $payment_method_registry->register(new PayplugApplePay()); $payment_method_registry->register(new PayplugOney3x()); $payment_method_registry->register(new PayplugOney4x()); $payment_method_registry->register(new PayplugOney3xWithoutFees()); $payment_method_registry->register(new PayplugOney4xWithoutFees()); } ); } } private function check_upgrade() { return $this->get_service('upgrade')->run_upgrade(); } }