Post by PPablo » Wed Nov 01, 2017 12:08 am

Buenas

Me pidieron que haga compatible un modulo de pago de OpenCart 2 a 3.x. El problema es que al ver el codigo de otros modulos como el Cash on Demand, G2APay y haciendo los arreglos pertinentes (como cambiar token por user_token), los datos que se ingresan en el panel de administración no son guardados, al hacer click en el boton de guardado los datos son enviados por POST pero viendo en la base de datos estos no ingresan

Descarto que sea un error de la vista porque viendo en la consola del navegador toma los datos asi que me intriga que sea el controlador, pero me resulta curioso que usando las mismas lineas de codigo de los otros modulos (solo cambiando los parametros) no sea capaz de guardar datos

Dejo el codigo del controlador y la vista. Como el codigo es propietario solo pongo 1 campo del formulario que sirve hpara habilitar o no el modulo, ni eso puedo lograr guardar en OpenCart

Controlador

Code: Select all

<?php
class ControllerExtensionPaymentMiPago extends Controller {
	private $error = array();

	public function index() {
		$this->document->setTitle('Mi Pago');

		$this->load->model('setting/setting');

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
			$this->model_setting_setting->editSetting('payment_mipago', $this->request->post);

			$this->session->data['success'] = $this->language->get('text_success');

			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true));
		}
		
		if (isset($this->error['warning'])) {
			$data['error_warning'] = $this->error['warning'];
		} else {
			$data['error_warning'] = "'';
		}
		
		$data['breadcrumbs'] = array();
		
		$data['breadcrumbs'][] = array(
			'text' => 'Inicio',
			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
		);
		
		$data['breadcrumbs'][] = array(
			'text' => 'Extensiones',
			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)
		);

		$data['breadcrumbs'][] = array(
			'text' => 'Mi Pago',
			'href' => $this->url->link('extension/payment/mipago', 'user_token=' . $this->session->data['user_token'], true)
		);

		$data['action'] = $this->url->link('extension/payment/mipago', 'user_token=' . $this->session->data['user_token'], true);
		
		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);
		
        if (isset($this->request->post['mipago_status'])) {
			$data['mipago_status'] = $this->request->post['mipago_status'];
		} else {
			$data['mipago_status'] = $this->config->get('mipago_status');
		}
	
		if (isset($this->request->post['paygol_order_status_id'])) {
			$data['mipago_order_status_id'] = $this->request->post['mipago_order_status_id'];
		} else {
			$data['mipago_order_status_id'] = $this->config->get('mipago_order_status_id');
		}
		
		$this->load->model('localisation/order_status');
		$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();

		if (isset($this->request->post['mipago_geo_zone_id'])) {
			$data['mipago_geo_zone_id'] = $this->request->post['mipago_geo_zone_id'];
		} else {
			$data['mipago_geo_zone_id'] = $this->config->get('mipago_geo_zone_id');
		}

		$data['header'] = $this->load->controller('common/header');
		$data['column_left'] = $this->load->controller('common/column_left');
		$data['footer'] = $this->load->controller('common/footer');

		$this->response->setOutput($this->load->view('extension/payment/mipago', $data));
	}

	protected function validate() {
		if (!$this->user->hasPermission('modify', 'extension/payment/mipago')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}
		return !$this->error;
	}
}
Vista

Code: Select all

{{ header }}{{ column_left }}
{% if error_warning %}
	{{ error_warning }}
{% endif %}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-mipago" data-toggle="tooltip" title={{ button_save }} class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href={{ cancel }} data-toggle="tooltip" title={{ button_cancel }} class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
      	{% for breadcrumb in breadcrumbs %}
        	<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i>{{ error_warning }}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i>{{ text_edit }}</h3>
      </div>
      <div class="panel-body">
        <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-mipago" class="form-horizontal">
			  	  
				
			   <div class="form-group">
					<label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
					<div class="col-sm-10">
						<select name="paygol_status" id="input-status" class="form-control">
							{% if paygol_status %}
							<option value="1" selected="selected">{{ text_enabled }}</option>
							<option value="0">{{ text_disabled }}</option>
							{% else %}
							<option value="1">{{ text_enabled}}</option>
							<option value="0" selected="selected">{{ text_disabled }}</option>
							{% endif %}
						</select>
					</div>
			  </div>
        </form>
      </div>
    </div>
  </div>
</div>
{{ footer }}

Newbie

Posts

Joined
Tue Oct 31, 2017 10:04 pm
Who is online

Users browsing this forum: Bing [Bot] and 8 guests