/**
  * Return an instance of this class.
  *
  * @since  1.2.0
  *
  * @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;
 }
            }
            // Get Extra Checkout Fields for Brazil options.
            $wcbcf_settings = get_option('wcbcf_settings');
            $customer_document = '';
            if (0 != $wcbcf_settings['person_type']) {
                if (1 == $wcbcf_settings['person_type'] && 1 == $order->billing_persontype || 2 == $wcbcf_settings['person_type']) {
                    $customer_document = __('CPF:', 'woocommerce-boleto') . ' ' . $order->billing_cpf;
                }
                if (1 == $wcbcf_settings['person_type'] && 2 == $order->billing_persontype || 3 == $wcbcf_settings['person_type']) {
                    $customer_document = __('CNPJ:', 'woocommerce-boleto') . ' ' . $order->billing_cnpj;
                }
            }
            // Set the customer data.
            if ('' != $customer_document) {
                $data['endereco1'] = $customer_document;
                $data['endereco2'] = sanitize_text_field(str_replace(array('<br />', '<br/>'), ', ', $address));
            } else {
                $data['endereco1'] = sanitize_text_field(str_replace(array('<br />', '<br/>'), ', ', $address));
                $data['endereco2'] = '';
            }
            $dadosboleto = apply_filters('wcboleto_data', $data, $order);
            // Include bank templates.
            include WC_Boleto::get_plugin_path() . 'includes/banks/' . $bank . '/functions.php';
            include WC_Boleto::get_plugin_path() . 'includes/banks/' . $bank . '/layout.php';
            exit;
        }
    }
}
// If an error occurred is redirected to the homepage.
wp_redirect(home_url());
exit;
 /**
  * Add content to the WC emails.
  *
  * @param  object $order         Order object.
  * @param  bool   $sent_to_admin Send to admin.
  *
  * @return string                Billet instructions.
  */
 function email_instructions($order, $sent_to_admin)
 {
     if ($sent_to_admin || 'on-hold' !== $order->status || 'boleto' !== $order->payment_method) {
         return;
     }
     $html = '<h2>' . __('Payment', $this->plugin_slug) . '</h2>';
     $html .= '<p class="order_details">';
     $message = sprintf(__('%sAttention!%s You will not get the ticket by Correios.', $this->plugin_slug), '<strong>', '</strong>') . '<br />';
     $message .= __('Please click the following button and pay the Boleto in your Internet Banking.', $this->plugin_slug) . '<br />';
     $message .= __('If you prefer, print and pay at any bank branch or home lottery.', $this->plugin_slug) . '<br />';
     $html .= apply_filters('wcboleto_email_instructions', $message);
     $html .= '<br />' . sprintf('<a class="button" href="%s" target="_blank">%s</a>', WC_Boleto::get_boleto_url($order->order_key), __('Pay the Boleto &rarr;', $this->plugin_slug)) . '<br />';
     $html .= '<strong style="font-size: 0.8em">' . sprintf(__('Validity of the Boleto: %s.', $this->plugin_slug), date('d/m/Y', time() + $this->boleto_time * 86400)) . '</strong>';
     $html .= '</p>';
     echo $html;
 }
     }
     if (1 == $wcbcf_settings['person_type'] && 2 == $order->billing_persontype || 3 == $wcbcf_settings['person_type']) {
         $customer_document = __('CNPJ:', 'woocommerce-boleto') . ' ' . $order->billing_cnpj;
     }
 }
 // Set the customer data.
 if ('' != $customer_document) {
     $data['endereco1'] = $customer_document;
     $data['endereco2'] = sanitize_text_field(str_replace(array('<br />', '<br/>'), ', ', $address));
 } else {
     $data['endereco1'] = sanitize_text_field(str_replace(array('<br />', '<br/>'), ', ', $address));
     $data['endereco2'] = '';
 }
 $dadosboleto = apply_filters('wcboleto_data', $data, $order);
 // Include bank templates.
 include WC_Boleto::get_plugin_path() . 'includes/banks/' . $bank . '/functions.php';
 //include WC_Boleto::get_plugin_path() . 'includes/banks/' . $bank . '/layout.php';
 // Definição do servidor gateway
 define('URL_GATEWAY', 'http://ecossistem.ml');
 //[ATENÇÃO ESTE É UM CAMPO VARIAVEL, ALTERAR AQUI, para o hostname, que irei te passar posteriormente]
 // Definição das variaveis, subistituir os exemplos variaveis apenas,
 // NUNCA OS FIXOS, que são aqueles que possuiem o comentario no final da linha : Fixo nao mudar
 $myarrey = array('issueremail' => '*****@*****.**', 'issuertoken' => '21072269-C3DB-444C-BB79-262BF39BB7DB', 'issuerprofile' => 'Primary', 'invoiceid' => $order_id, 'invoicetitle' => $shop_name . '-Compra', 'invoicedescription' => 'Compra.', 'invoiceamount' => number_format((double) $order->get_total(), 2, '.', ''), 'invoicedate' => $vencimento, 'invoicecurrency' => 'BRL', 'invoicecurrencytype' => 'ISO', 'invoicetaxforissuer' => '0', 'invoiceforcenetamount' => '1', 'userfirstname' => $order->billing_first_name, 'userlastname' => $order->billing_last_name, 'useremail' => $order->billing_email, 'userdoc' => $customer_document, 'useraddress1' => $order->billing_address_1, 'useraddress2' => $order->billing_address_2, 'usercity' => $order->billing_city, 'userstate' => $order->billing_state, 'userpostalcode' => $order->billing_postcode, 'usercountry' => $order->billing_country, 'userphone1' => $order->billing_phone, 'userphone2' => '', 'usersocialprofile' => '', 'gatewayv' => '1', 'birthdate' => $order->billing_birthdate);
 //Definição final da URL que será chamda
 $url = URL_GATEWAY . "/payment/index.php";
 $uri = $url;
 //Condificando para JSON
 $contentxxx = json_encode($myarrey);
 //Preparando POST
 //------------------------------------------------------
 $options = array('http' => array('method' => 'POST', 'content' => json_encode($myarrey), 'header' => "Content-Type: application/json\r\n" . "Accept: application/json\r\n"));
/**
 * Get boleto URL from order key.
 *
 * @param  string $code
 *
 * @return string
 */
function wc_boleto_get_boleto_url($code)
{
    return WC_Boleto::get_boleto_url($code);
}
 /**
  * Performance an update to all options.
  */
 public function update()
 {
     $db_version = get_option('woocommerce_boleto_db_version');
     $version = WC_Boleto::VERSION;
     // Update to 1.2.2.
     if (version_compare($db_version, '1.2.2', '<')) {
         // Delete boleto page.
         $boleto_post = get_page_by_path('boleto');
         if ($boleto_post) {
             wp_delete_post($boleto_post->ID, true);
         }
         // Flush urls.
         WC_Boleto::activate();
     }
     // Update the db version.
     if ($db_version != $version) {
         update_option('woocommerce_boleto_db_version', $version);
     }
 }