notices = new Notices();
$this->metabox = new Metabox();
$this->actions = new WoocommerceActions();
$this->requests = new PayplugWoocommerceRequest();
$this->ajax = new Ajax();
if( PayplugWoocommerceHelper::show_oney_popup() ) {
$this->animationHandlers();
}
add_action( 'woocommerce_payment_gateways', [ $this, 'register_payplug_gateway' ] );
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\\PayplugGateway';
$methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney3x';
$methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney4x';
$methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney3xWithoutFees';
$methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney4xWithoutFees';
$methods[] = __NAMESPACE__ . '\\Controller\\Bancontact';
$methods[] = __NAMESPACE__ . '\\Controller\\ApplePay';
$methods[] = __NAMESPACE__ . '\\Controller\\AmericanExpress';
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['payplug_merchant_country']) ) {
$options['payplug_merchant_country'] = PayplugWoocommerceHelper::UpdateCountryOption($options);
}
//failsafe
if( empty($options['payplug_merchant_country']) ){
return ;
}
if( !class_exists( "\\Payplug\\PayplugWoocommerce\\Front\\PayplugOney\\Country\\Oney" .$options['payplug_merchant_country'] )){
return ;
}
//check if the options has the Country setted
Switch($options['oney_type']){
case "without_fees" : new OneyWithoutFees();break;
default: new OneyWithFees();break;
}
}
}