/** * Método que genera el formulario de pago en HTML * * @param string $button_type * Dimensión del boton a mostrar * * @return string * Formulario renderizado */ public function renderForm($button_type = '100x50') { $values = $this->getFormLabels(); $html = new DOMDocument(); $html->formatOutput = true; $form = $html->createElement('form'); $form->setAttribute('action', $this->getApiUrl()); $form->setAttribute('method', 'POST'); foreach ($values as $name => $value) { $input_hidden = $html->createElement('input'); $input_hidden->setAttribute('type', 'hidden'); $input_hidden->setAttribute('name', $name); $input_hidden->setAttribute('value', $value); $form->appendChild($input_hidden); } $input_hidden = $html->createElement('input'); $input_hidden->setAttribute('type', 'hidden'); $input_hidden->setAttribute('name', 'agent'); $input_hidden->setAttribute('value', $this->agent); $form->appendChild($input_hidden); $buttons = Khipu::getButtonsKhipu(); if (isset($buttons[$button_type])) { $button = $buttons[$button_type]; } else { $button = $buttons['100x50']; } $submit = $html->createElement('input'); $submit->setAttribute('type', 'image'); $submit->setAttribute('src', $button); $form->appendChild($submit); $html->appendChild($form); return $html->saveHTML(); }