/**
  * Return an instance of this class.
  *
  * @return object A single instance of this class.
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Constructor for the gateway.
  *
  * @return void
  */
 public function __construct()
 {
     // Standards.
     $this->id = 'mercadopago';
     $this->icon = apply_filters('woocommerce_mercadopago_icon', plugins_url('images/mercadopago.png', plugin_dir_path(__FILE__)));
     $this->has_fields = false;
     $this->method_title = __('MercadoPago', 'woocommerce-mercadopago');
     // API URLs.
     $this->payment_url = 'https://api.mercadolibre.com/checkout/preferences?access_token=';
     $this->ipn_url = 'https://api.mercadolibre.com/collections/notifications/';
     $this->sandbox_ipn_url = 'https://api.mercadolibre.com/sandbox/collections/notifications/';
     $this->oauth_token = 'https://api.mercadolibre.com/oauth/token';
     // Load the form fields.
     $this->init_form_fields();
     // Load the settings.
     $this->init_settings();
     // Define user set variables.
     $this->title = $this->get_option('title');
     $this->description = $this->get_option('description');
     $this->client_id = $this->get_option('client_id');
     $this->client_secret = $this->get_option('client_secret');
     $this->invoice_prefix = $this->get_option('invoice_prefix', 'WC-');
     $this->method = $this->get_option('method', 'modal');
     $this->sandbox = $this->get_option('sandbox', false);
     $this->debug = $this->get_option('debug');
     // Actions.
     add_action('woocommerce_api_wc_mercadopago_gateway', array($this, 'check_ipn_response'));
     add_action('valid_mercadopago_ipn_request', array($this, 'successful_request'));
     add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page'));
     add_action('wp_head', array($this, 'css'));
     add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
     // Checks if client_id is not empty.
     if (empty($this->client_id)) {
         add_action('admin_notices', array($this, 'client_id_missing_message'));
     }
     // Checks if client_secret is not empty.
     if (empty($this->client_secret)) {
         add_action('admin_notices', array($this, 'client_secret_missing_message'));
     }
     // Checks that the currency is supported
     if (!$this->using_supported_currency()) {
         add_action('admin_notices', array($this, 'currency_not_supported_message'));
     }
     // Active logs.
     if ('yes' == $this->debug) {
         if (class_exists('WC_Logger')) {
             $this->log = new WC_Logger();
         } else {
             $this->log = WC_MercadoPago::woocommerce_instance()->logger();
         }
     }
 }