0

My Custom Payment no showing at the checkout. Help, please! Life or death issue.

My code:

app\code\local\FITeND\DuplicatePayment\Block\Form\DuplicatePayment.php

class FITeND_DuplicatePayment_Block_Form_Duplicatepayment extends Mage_Core_Block_Template
{
    protected function _construct(){
       parent::_construct();

       $this->setTemplate('fitend/duplicatepayment/form/duplicatepayment.phtml');
    }
    public function getCustomFormBlockType()
    {
       return $this->getMethod()->getConfigData('form_block_type');
    }  
}

app\code\local\FITeND\DuplicatePayment\Block\Info\DuplicatePayment.php

class FITeND_DuplicatePayment_Block_Info_Duplicatepayment extends Mage_Payment_Block_Info{
protected function _prepareSpecificInformation($transport = null)
   {
       if (null !== $this->_paymentSpecificInformation) {
           return $this->_paymentSpecificInformation;
       }
       $info = $this->getInfo();
       $transport = new Varien_Object();

       $transport->addData(array(
           Mage::helper('payment')->__('Check No#') => $info->getCheckNo(),
           Mage::helper('payment')->__('Check Date') => $info->getCheckDate()
       ));

       $transport = parent::_prepareSpecificInformation($transport);
       return $transport;
   }
}

app\code\local\FITeND\DuplicatePayment\etc\config.xml

<?xml version="1.0"?>
<config>
        <modules>
             <FITeND_DuplicatePayment>
                    <version>0.1.0</version>
             </FITeND_DuplicatePayment>
        </modules>
        <global>
        <blocks>
                <duplicatepayment>
                        <class>FITeND_DuplicatePayment_Block</class>
                </duplicatepayment>
        </blocks>
                <models>
                        <duplicatepayment>
                                <class>FITeND_DuplicatePayment_Model</class>
                        </duplicatepayment>
                </models>

                <resources>
                        <duplicatepayment_setup>
                                <setup>
                                        <module>FITeND_DuplicatePayment</module>
                                </setup>
                                <connection>
                                        <use>core_setup</use>
                                </connection>
                        </duplicatepayment_setup>
                        <duplicatepayment_write>
                                <connection>
                                    <use>core_write</use>
                                </connection>
                        </duplicatepayment_write>
                        <duplicatepayment_read>
                             <connection>
                                <use>core_read</use>
                            </connection>
                        </duplicatepayment_read>
                </resources>
        </global>

        <default>
                <payment>
                        <duplicatepayment>
                                <active>1</active>
                                <model>duplicatepayment/duplicatepayment</model>
                                <order_status>1</order_status>
                                <login backend_model="adminhtml/system_config_backend_encrypted"/>
                                <order_status>pending</order_status>
                                <payment_action>authorize</payment_action>
                                <debug>0</debug>
                                <email_customer>0</email_customer>
                                <trans_key backend_model="adminhtml/system_config_backend_encrypted"/>
                                <allowspecific>0</allowspecific>
                                <can_use_checkout>1</can_use_checkout>
                        </duplicatepayment>
                 </payment>
        </default>
</config>

app\code\local\FITeND\DuplicatePayment\etc\system.xml

<?xml version="1.0"?>
<config>
   <sections>
        <payment>
            <groups>
                <duplicatepayment translate="label" module="paygate">
                    <label>Duplicata</label>
                    <sort_order>10</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>Ativo</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>Novo Status do Pedido</label>
                                 <frontend_type>select</frontend_type>
                                 <source_model>adminhtml/system_config_source_order_status_new</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>Título</label>
                                 <frontend_type>text</frontend_type>
                                 <sort_order>1</sort_order>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>1</show_in_store>
                              </title>
                              <error_email translate="label">
                                 <label>Destinatário de email de erro</label>
                                 <frontend_type>text</frontend_type>
                                 <sort_order>27</sort_order>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>0</show_in_store>
                              </error_email>
                              <debug translate="label">
                                 <label>Debug</label>
                                 <frontend_type>select</frontend_type>
                                 <source_model>adminhtml/system_config_source_yesno</source_model>
                                 <sort_order>28</sort_order>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>0</show_in_store>
                              </debug>
                              <allowspecific translate="label">
                                 <label>Pagamento de países aplicáveis</label>
                                 <frontend_type>allowspecific</frontend_type>
                                 <sort_order>50</sort_order>
                                 <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>0</show_in_store>
                              </allowspecific>
                              <specificcountry translate="label">
                                 <label>Pagamento de países específicos</label>
                                 <frontend_type>multiselect</frontend_type>
                                 <sort_order>51</sort_order>
                                 <source_model>adminhtml/system_config_source_country</source_model>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>0</show_in_store>
                                 <can_be_empty>1</can_be_empty>
                              </specificcountry>
                              <min_order_total translate="label">
                                 <label>Valor Mínimo do Pedido</label>
                                 <frontend_type>text</frontend_type>
                                 <sort_order>98</sort_order>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>0</show_in_store>
                              </min_order_total>
                              <max_order_total translate="label">
                                 <label>Valor Máximo do Pedido</label>
                                 <frontend_type>text</frontend_type>
                                 <sort_order>99</sort_order>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>0</show_in_store>
                              </max_order_total>
                              <sort_order translate="label">
                                 <label>Sort Order</label>
                                 <frontend_type>text</frontend_type>
                                 <sort_order>100</sort_order>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>0</show_in_store>
                              </sort_order>
                    </fields>
                </duplicatepayment>
            </groups>
        </payment>
    </sections>
</config>

app\code\local\FITeND\DuplicatePayment\Helper\Data.php

class FITeND_DuplicatePayment_Helper_Data extends Mage_Core_Helper_Data{
}

app\code\local\FITeND\DuplicatePayment\Model\DuplicatePayment.php

class FITeND_DuplicatePayment_Model_DuplicatePayment extends Mage_Payment_Model_Method_Checkmo {

protected $_code = 'duplicatepayment';

protected $_isGateway = true;

protected $_canAuthorize = true;

protected $_canCapture = true;

protected $_canCapturePartial = false;

protected $_canRefund = false;

protected $_canVoid = true;

protected $_canUseInternal = true;

protected $_canUseCheckout = true;

protected $_canUseForMultishipping  = true;

protected $_formBlockType = 'duplicatepayment/form_duplicatepayment';

protected $_infoBlockType = 'duplicatepayment/info_duplicatepayment';


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;
}
}

app\design\frontend\base\default\template\fitend\duplicatepayment\form\duplicatepayment.phtml

<?php $_code = $this->getMethod()->getCode() ?>
<ul class="form-list" id="payment_form_<?php echo $_code ?>" 
style="display:none;">
<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>
<li>
    <div>
        <?php echo $this->getMethod()->getConfigData('message');?>
    </div>
</li>

Thanks a lot for your help!

  • In addition to the answer already posted, just let me add that you put yourself in an unnecessary hell when you use strange combinations of uppercase and lowercase letters in your Namespace and/or module name – simonthesorcerer Feb 27 '18 at 15:12
0

Lots of wrong naming.

  1. app\code\local\FITeND\DuplicatePayment\Block\Form\DuplicatePayment.php Should be app\code\local\FITeND\DuplicatePayment\Block\Form\Duplicatepayment.php

  2. app\code\local\FITeND\DuplicatePayment\Block\Info\DuplicatePayment.php Should be app\code\local\FITeND\DuplicatePayment\Block\Info\Duplicatepayment.php

  3. app\code\local\FITeND\DuplicatePayment\Model\DuplicatePayment.php Should be app\code\local\FITeND\DuplicatePayment\Model\Duplicatepayment.php and content should be


class FITeND_DuplicatePayment_Model_Duplicatepayment extends Mage_Payment_Model_Method_Checkmo
{

    protected $_code = 'duplicatepayment';

    protected $_isGateway = true;

    protected $_canAuthorize = true;

    protected $_canCapture = true;

    protected $_canCapturePartial = false;

    protected $_canRefund = false;

    protected $_canVoid = true;

    protected $_canUseInternal = true;

    protected $_canUseCheckout = true;

    protected $_canUseForMultishipping  = true;

    protected $_formBlockType = 'duplicatepayment/form_duplicatepayment';

    protected $_infoBlockType = 'duplicatepayment/info_duplicatepayment';


    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;
    }
}
  1. app\design\frontend\base\default\template\fitend\duplicatepayment\form\duplicatepayment.phtml you use style="display:none;" remove that.

  2. app/etc/modules/FITeND_DuplicatePayment.xml


<?xml version="1.0"?>
<config>
    <modules>
        <FITeND_DuplicatePayment>
            <active>true
            <codePool>local
            <depends>
                <Mage_Payment/>
            </depends>
        </FITeND_DuplicatePayment>
    </modules>
</config>

Download Module From here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.