protected function send_to_conekta()
 {
     global $woocommerce;
     include_once 'conekta_gateway_helper.php';
     Conekta::setApiKey($this->secret_key);
     Conekta::setLocale("es");
     $data = getRequestData($this->order);
     $line_items = array();
     $items = $this->order->get_items();
     $line_items = build_line_items($items);
     $details = build_details($data, $line_items);
     try {
         $charge = Conekta_Charge::create(array("amount" => $data['amount'], "currency" => $data['currency'], "reference_id" => $this->order->id, "description" => "Recibo de pago para orden # " . $this->order->id, "cash" => array("type" => "oxxo"), "details" => $details));
         $this->transactionId = $charge->id;
         update_post_meta($this->order->id, 'conekta-id', $charge->id);
         update_post_meta($this->order->id, 'conekta-creado', $charge->created_at);
         update_post_meta($this->order->id, 'conekta-expira', $charge->payment_method->expiry_date);
         update_post_meta($this->order->id, 'conekta-barcode', $charge->payment_method->barcode);
         update_post_meta($this->order->id, 'conekta-barcodeurl', $charge->payment_method->barcode_url);
         return true;
     } catch (Conekta_Error $e) {
         $description = $e->message_to_purchaser;
         global $wp_version;
         if (version_compare($wp_version, '4.1', '>=')) {
             wc_add_notice(__('Error: ', 'woothemes') . $description, $notice_type = 'error');
         } else {
             error_log('Gateway Error:' . $description . "\n");
             $woocommerce->add_error(__('Error: ', 'woothemes') . $description);
         }
         return false;
     }
 }
 protected function send_to_conekta()
 {
     global $woocommerce;
     include_once 'conekta_gateway_helper.php';
     Conekta::setApiKey($this->secret_key);
     Conekta::setLocale("es");
     $data = getRequestData($this->order);
     try {
         $line_items = array();
         $items = $this->order->get_items();
         $line_items = build_line_items($items);
         $details = build_details($data, $line_items);
         $charge = Conekta_Charge::create(array("amount" => $data['amount'], "currency" => $data['currency'], "monthly_installments" => $data['monthly_installments'] > 1 ? $data['monthly_installments'] : null, "card" => $data['token'], "reference_id" => $this->order->id, "description" => "Compra con orden # " . $this->order->id . " desde Woocommerce v" . $this->version, "details" => $details));
         $this->transactionId = $charge->id;
         if ($data['monthly_installments'] > 1) {
             update_post_meta($this->order->id, 'meses-sin-intereses', $data['monthly_installments']);
         }
         update_post_meta($this->order->id, 'transaction_id', $this->transactionId);
         return true;
     } catch (Conekta_Error $e) {
         $description = $e->message_to_purchaser;
         global $wp_version;
         if (version_compare($wp_version, '4.1', '>=')) {
             wc_add_notice(__('Error: ', 'woothemes') . $description, $notice_type = 'error');
         } else {
             error_log('Gateway Error:' . $description . "\n");
             $woocommerce->add_error(__('Error: ', 'woothemes') . $description);
         }
         return false;
     }
 }