[英]Magento Custom Payment Gateway
I'm trying to write a custom payment gateway for Magento.我正在尝试为 Magento 编写自定义支付网关。 The module is recognised in the administration backend (System - Config - Payment Methods), but when reaching 'Payment Information' in the frontend, the option to select the module does not appear.该模块在管理后端(系统 - 配置 - 付款方式)中被识别,但在前端到达“付款信息”时,不会出现 select 模块的选项。
Below contains the three XML files I have created, and the directory in which they reside.下面包含我创建的三个 XML 文件,以及它们所在的目录。
Any help would be much appreciated.任何帮助将非常感激。 Thanks.谢谢。
root/app/etc/modules/Namespace_Module根/app/etc/modules/Namespace_Module
<?xml version="1.0"?>
<config>
<modules>
<Namespace_Module>
<active>true</active>
<codePool>local</codePool>
</Namespace_Module>
</modules>
</config>
root/app/code/local//Namespace/Module/etc/config.xml root/app/code/local//命名空间/模块/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//Namespace/Module/etc/system.xml 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>
The values you setup in system.xml
are global Magento configuration values.您在system.xml
中设置的值是全局 Magento 配置值。 Payment module's are required to include a configuration field named model
, which specifies the PHP class that's responsible for payment logic.支付模块需要包含一个名为model
的配置字段,它指定负责支付逻辑的 PHP class。 Take a look in进去看看
app/code/core/Mage/Payment/etc/system.xml
Typically, a module makes this a hidden configuration field, and then supplies a default value in config.xml
.通常,模块将此设置为隐藏配置字段,然后在config.xml
中提供默认值。 Consider this bit of XML from Mage/Payment/etc/config.xml
考虑来自Mage/Payment/etc/config.xml
的 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>
Here they've setup a model of payment/method_ccsave
.在这里,他们设置了payment/method_ccsave
的 model 。 This is a class alias that corresponds to the PHP Model class这是一个 class 别名,对应于 PHP Model ZA2F2ED4F8EBC2CBB4C21A29DZ40AB6
Mage_Payment_Model_Method_Ccsave
You configuration appears to be missing this class, which is one reason your payment option doesn't appear.您的配置似乎缺少此 class,这是您的付款选项未出现的原因之一。
Your xml doesn't seem to have a "blocks" section defined.您的 xml 似乎没有定义“块”部分。 So I assume you do not yet have the *.phtml file created either.所以我假设您还没有创建 *.phtml 文件。 I experienced the same problem.我遇到了同样的问题。
The example found here helped me: http://www.magentocommerce.com/boards/viewthread/230559/在这里找到的例子对我有帮助: http://www.magentocommerce.com/boards/viewthread/230559/
Take note of the "blocks" section of the config.xml.注意 config.xml 的“块”部分。 Also, notice the Blocks/*.php file and the form.phtml file.另外,请注意 Blocks/*.php 文件和 form.phtml 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.