cancel
Showing results for 
Search instead for 
Did you mean: 

Módulo de pago que no aparece en checkout

Módulo de pago que no aparece en checkout

Hola a todos!

 

Estoy desarrollando un módulo de Magento con la versión CE 1.9, pero no logro que mi formulario se muestre al seleccionar la forma de pago. El radiobutton de la forma de pago sí que aparece, pero no muestra el formulario al seleccionarla. ¿Alguien sabe por qué podría ser?

 

Aquí os adjunto mi código.

 

config.xml:

<config>
<modules>
    <Checkbuy_Checkbuy>
        <version>0.0.3</version>
    </Checkbuy_Checkbuy>
</modules>

<global>
    <models>
        <checkbuy>
            <class>Checkbuy_Checkbuy_Model</class>
        </checkbuy>
    </models>

    <blocks>
        <checkbuy>
            <class>Checkbuy_Checkbuy_Block</class>
        </checkbuy>
    </blocks>

    <helpers>
        <checkbuy>
            <class>Checkbuy_Checkbuy_Helper</class>
        </checkbuy>
    </helpers>

    <fieldsets>
        <sales_convert_quote_payment>
            <check_no>
                <to_order_payment>*</to_order_payment>
            </check_no>
            <check_date>
                <to_order_payment>*</to_order_payment>
            </check_date>
        </sales_convert_quote_payment>
    </fieldsets>
</global>

<default>
    <payment>
        <checkbuy>
            <active>1</active>
            <model>checkbuy/Checkbuy</model>
            <order_status>processing</order_status>
            <title>Checkbuy Payment Method</title>
            <allowspecific>0</allowspecific>
            <form_block_type>0</form_block_type>
        </checkbuy>
    </payment>
</default>
</config>

system.xml:

<config>
<sections>
    <payment>
        <groups>
            <checkbuytranslate="label" module="checkbuy">
                <label>Checkbuy Payment Module</label>
                <sort_order>0</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>0</show_in_store>
                <fields>
                    <active translate="label">
                        <label>Enabled</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_yesno</source_model>
                        <sort_order>1</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </active>
                    <order_status translate="label">
                        <label>New order status</label>
                        <frontend_type>select</frontend_type>
                        <source_model>adminhtml/system_config_source_order_status_processing</source_model>
                        <sort_order>2</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </order_status>
                    <title translate="label">
                        <label>Title</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>3</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </title>
                </fields>
            </checkbuy>
        </groups>
    </payment>
</sections>
</config>

Model (Checkbuy.php):

<?php
class Checkbuy_Checkbuy_Model_Checkbuy extends Mage_Payment_Model_Method_Abstract {

protected $_code             = 'checkbuy';
protected $_formBlockType    = 'checkbuy/form';
protected $_infoBlockType    = 'checkbuy/info';
protected $canUseCheckout    = TRUE;

public function isAvailable($quote = NULL)
{
    return TRUE;
}

public function assignData($data)
{
    if(!($data instanceof Varien_Object))
    {
        $data = new Varien_Object($data);
    }
    $info = $this->getInfoInstance();
    $info->setCheckNo($data->getCheckNo())->setCheckDate($data->getCheckDate());
    return $this;
}

public function validate()
{
    parent::validate();

    $info = $this->getInfoInstance();

    $no      = $info->getCheckNo();
    $date    = $info->getCheckDate();
    if(empty($no) || empty($date))
    {
        $errorCode   = 'invalid_data';
        $errorMsg    = $this->_getHelper()->__('Check No and Date are required fields');
    }

    if($errorMsg)
    {
        Mage::throwException($errorMsg);
    }
    return $this;
}

}

 

Block (Form.php):

<?php

class Checkbuy_Checkbuy_Block_Form extends Mage_Payment_Block_Form {

protected function _construct()
{
    parent::_construct();
    $this->setTemplate('checkbuy/form.phtml');
}

public function getCustomFormBlockType()
{
    return $this->getMethod()->getConfigData('form_block_type');
}

}

form.phtml

<?php $_code=$this->getMethodCode() ?>
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
<li>
    <h4>Checkbuy</h4>
</li>
<li>
    <label for="<?php echo $_code ?>_check_no" class="required"><em>*</em><?php echo $this->__('Check No#') ?></label>
    <span class="input-box">
        <input type="text" title="<?php echo $this->__('Check No#') ?>" class="input-text required-entry" id="<?php echo $_code ?>_check_no" name="payment[check_no]" value="<?php echo $this->htmlEscape($this->getInfoData('check_no')) ?>" />
    </span>
</li>
<li>
    <label for="<?php echo $_code ?>_check_date" class="required"><em>*</em><?php echo $this->__('Check Date:') ?></label>
    <span class="input-box">
        <input type="text" title="<?php echo $this->__('Check Date:') ?>" class="input-text required-entry" id="<?php echo $_code ?>_check_date" name="payment[check_date]" value="<?php echo $this->htmlEscape($this->getInfoData('check_date')) ?>" />
    </span>
</li>
</ul>

Gracias de antemano por la ayuda