2011-06-04 158 views
4

我正在尝试为Magento写一个自定义支付网关。该模块在管理后端(系统 - 配置 - 支付方法)中被识别,但是当到达前端的“支付信息”时,不会显示选择模块的选项。Magento自定义支付网关

下面包含我创建的三个XML文件以及它们所在的目录。

任何帮助将不胜感激。谢谢。

根/应用程序的/ etc /模块/ Namespace_Module

<?xml version="1.0"?> 

<config> 
    <modules> 
    <Namespace_Module> 
     <active>true</active> 
     <codePool>local</codePool> 
    </Namespace_Module> 
    </modules> 
</config> 

根/应用程序/代码/本地//命名空间/模块的/ etc/config.xml中

<?xml version="1.0"?> 

<config> 
    <modules> 
    <Namespace_Module> 
     <version>0.1.0</version> 
    </Namespace_Module> 
    </modules> 

    <global> 

    <models> 
     <alias> 
      <class>Namespace_Module_Model</class> 
     </alias> 
    </models> 

    <resources> 
     <alias_setup> 
      <setup> 
       <module>Namespace_Module</module> 
      </setup> 
      <connection> 
       <use>core_setup</use> 
      </connection> 
     </alias_setup> 

     <alias_write> 
      <connection> 
       <use>core_write</use> 
      </connection> 
     </alias_write> 

     <alias_read> 
      <connection> 
       <use>core_read</use> 
      </connection> 
     </alias_read> 
    </resources> 

    </global> 

root/app/code/local //命名空间/模块/ etc/system.xml

<?xml version="1.0"?> 

<config> 
    <sections> 
    <payment> 
     <groups> 
      <alias translate="label"> 
       <label>Module</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> 

        <host translate="label"> 
         <label>Host Address: </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> 
        </host> 

        <port translate="label"> 
         <label>Port Number: </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> 
        </port> 

        <cctypes translate="label"> 
         <label>Credit Card Types: </label> 
         <frontend_type>multiselect</frontend_type> 
         <source_model>adminhtml/system_config_source_payment_cctype</source_model> 
         <sort_order>5</sort_order> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>0</show_in_store> 
        </cctypes> 

        <useccv translate="label"> 
         <label>Credit Card Verification: </label> 
         <frontend_type>select</frontend_type> 
         <source_model>adminhtml/system_config_source_yesno</source_model> 
         <sort_order>6</sort_order> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>0</show_in_store> 
        </useccv> 

       </fields> 
      </alias> 
     </groups> 
    </payment> 
</sections> 

回答

5

system.xml值在安装有全球Magento的配置值。付款模块必须包含名为model的配置字段,该字段指定负责付款逻辑的PHP类。参加

app/code/core/Mage/Payment/etc/system.xml 

看看通常情况下,一个模块使这是一个隐藏的配置字段,然后在提供一个​​3210默认值。考虑从Mage/Payment/etc/config.xml

<default> 
    <payment> 
     <ccsave> 
      <active>1</active> 
      <cctypes>AE,VI,MC,DI</cctypes> 
      <model>payment/method_ccsave</model> 
      <order_status>pending</order_status> 
      <title>Credit Card (saved)</title> 
      <allowspecific>0</allowspecific> 
      <group>offline</group> 
     </ccsave> 

这里XML的此位,他们已经设置的payment/method_ccsave的典范。这是对应于PHP Model类

Mage_Payment_Model_Method_Ccsave 

你的配置似乎缺少这一类,这是您的付款选项不会出现一个理由一类的别名。

+0

非常感谢。我已经添加了一个模型类,并且依次链接到它;然而,仍然没有。 如果有人能注意到任何可能会丢失的东西,我将不胜感激。谢谢! – Pete171 2011-06-06 06:48:28

+0

在上面的示例中,应用程序/ etc/modules /中的文件没有.xml扩展名。 Magento正在这个文件夹中寻找一个* .xml文件,然后它将加载你的任何模块的XML文件。 – 2013-04-16 09:57:36

1

您的xml似乎没有定义“块”部分。所以我假设你还没有创建* .phtml文件。我遇到了同样的问题。

发现这里的例子帮助我: http://www.magentocommerce.com/boards/viewthread/230559/

。注意到config.xml中的“块”部分。 另外,请注意Blocks/*。php文件和form.phtml文件。