Модуль пользовательского платежа не работает на Frontend

magento.stackexchange https://magento.stackexchange.com/questions/805

  •  16-10-2019
  •  | 
  •  

Вопрос

Я создал платежный модуль, но он не отображается на странице оформления заказа, в то время как он работает в configuration -> payment methods.

Это мое config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <EM_Netregistry>
            <version>1.1.0</version>
        </EM_Netregistry>
    </modules>
    <global>
        <models>
            <netregistry>
                <class>EM_Netregistry_Model</class>
            </netregistry>
        </models>
        <resources>
            <netregistry_setup>
                <setup>
                    <module>EM_Netregistry</module>
                    <class>Mage_Eav_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </netregistry_setup>
            <netregistry_write>
                <use>core_write</use>
            </netregistry_write>
            <netregistry_read>
                <use>core_read</use>
            </netregistry_read>
        </resources>
        <blocks>
            <netregistry>
                <class>EM_Netregistry_Block</class>
            </netregistry>
        </blocks>
        <helpers>
            <netregistry>
                <class>EM_Netregistry_Helper</class>
            </netregistry>
        </helpers>        
    </global>
    <default>
        <payment>
            <netregistry>
                <active>0</active>
                <model>netregistry/netregistry</model>
                <order_status>1</order_status>
                <title>Net Registry</title>
                <allowspecific>0</allowspecific>
                <form_block_type>0</form_block_type>
            </netregistry>
        </payment>
    </default>
    <adminhtml>
        <translate>
            <modules>
                <EM_Netregistry>
                    <files>
                        <default>EM_Netregistry.csv</default>
                    </files>
                </EM_Netregistry>
            </modules>
        </translate>
    </adminhtml>
    <frontend>
        <routers>
            <netregistry>
                <use>standard</use>
                <args>
                    <module>EM_Netregistry</module>
                    <frontname>customcard</frontname>
                </args>
            </netregistry>
        </routers>
        <translate>
            <modules>
                <EM_Netregistry>
                    <files>
                        <default>EM_Netregistry.csv</default>
                    </files>
                </EM_Netregistry>
            </modules>
        </translate>
    </frontend>
    <default>
        <payment>
            <netregistry>
                <title>Net Registry</title>
                <active>1</active>
                <order_status>pending</order_status>
                <allowspecific>0</allowspecific>
                <payment_action>authorize</payment_action>
                <show_bank_accounts_in_pdf>1</show_bank_accounts_in_pdf>
                <show_customtext_in_pdf>1</show_customtext_in_pdf>
            </netregistry>
        </payment>
    </default>
</config>

Это мое system.xml:

<?xml version="1.0"?>
<config>
    <sections>
        <payment>
            <groups>
                <netregistry translate="label" module="netregistry">
                    <label>Net Registry</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>
                    <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>1</show_in_store>
                        </active>
                        <title translate="label">
                            <label>Title</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </title>
                        <merchant_id translate="label">
                            <label>Merchant ID</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>1</show_in_store>
                        </merchant_id>
                        <merchant_pass translate="label">
                            <label>Password</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>4</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </merchant_pass>
                        <allowspecific translate="label">
                            <label>Payment from applicable countries</label>
                            <frontend_type>allowspecific</frontend_type>
                            <sort_order>5</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>1</show_in_store>
                        </allowspecific>
                        <specificcountry translate="label">
                            <label>Payment from Specific countries</label>
                            <frontend_type>multiselect</frontend_type>
                            <sort_order>6</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>1</show_in_store>
                        </specificcountry>
                    </fields>
                </netregistry>
            </groups>
        </payment>
    </sections>
</config>

Это моя модель model/Netregistry.php:

/**
* Our test CC module adapter
*/
class EM_Netregistry_Model_Netregistry extends Mage_Payment_Model_Method_Cc
{

    protected $_code = 'netregistry';
    protected $_formBlockType = 'netregistry/form';
    protected $_infoBlockType = 'netregistry/form';

}

И это мой form.php В моей блоке папке:

class EM_Netregistry_Block_Form extends Mage_Payment_Block_Form
{
    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('netregistry/form.phtml');
    }
}
Это было полезно?

Решение

Пожалуйста, используйте этот код для вашей модели расширенный класс. Mage_Payment_Model_Method_Cc использовать это Mage_Payment_Model_Method_Abstract

<?php

/**
* Our test CC module adapter
*/
class EM_Netregistry_Model_Netregistry extends Mage_Payment_Model_Method_Abstract
{

    protected $_code = 'netregistry';
    protected $_formBlockType = 'netregistry/form';
    protected $_infoBlockType = 'netregistry/form';

}

Другие советы

Если Config in Admin отсутствует, проверьте, если у вас есть правильно созданный файл начальной загрузки в и т. Д./Модули. Здесь не хватает, может быть, это причина.

Также вам не хватает объявления модели в config.xml

<default>
   <payment>
      <netregistry>
          <model>.....

Заметил, что у вас есть двойной <default><payment><netregistry> узлы. Попробуйте объединить их.
Добавьте следующий код в свою модель оплаты

    public function isAvailable($quote = null)
    {
        return true;
    }

Логика отображения лежит в Mage_Payment_Helper_Data метод getStoreMethods. Анкет Попробуйте отладить этот цикл.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top