Hi everybody.
I'm developing a custom payment module for Magento CE 1.9 and I can't figure out how to get my form to show on the Checkout page. The radiobutton is shown, but clicking on it doesn't trigger the form display. Any help would very much welcome.
Here is my code:
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>
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>
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>
Thanks in advance for helping.
Solved! Go to Solution.
There's a small error in the system.xml, did you correct that already? It's probably not showing in the admin right now and not being picked up in the module config.
<checkbuytranslate="label" module="checkbuy">
If that's not it, do you have a model extending Mage_Payment_Model_Info?
There's a small error in the system.xml, did you correct that already? It's probably not showing in the admin right now and not being picked up in the module config.
<checkbuytranslate="label" module="checkbuy">
If that's not it, do you have a model extending Mage_Payment_Model_Info?
That was it! Thanks a lot, Melvyn!!