Magento自定义支付网关 [英] Magento Custom Payment Gateway

查看:90
本文介绍了Magento自定义支付网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Magento编写自定义支付网关.该模块可以在管理后端(系统-配置-付款方式)中识别,但是在前端到达付款信息"时,不会出现用于选择模块的选项.

I'm trying to write a custom payment gateway for 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.

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

Below contains the three XML files I have created, and the directory in which they reside.

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

Any help would be much appreciated. Thanks.

root/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

<?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

<?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>

推荐答案

您在system.xml中设置的值是Magento全局配置值.支付模块必须包含一个名为model的配置字段,该字段指定负责支付逻辑的PHP类.看看

The values you setup in system.xml are global Magento configuration values. Payment module's are required to include a configuration field named model, which specifies the PHP class that's responsible for payment logic. Take a look in

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

通常,模块将其设置为隐藏的配置字段,然后在config.xml中提供默认值.考虑Mage/Payment/etc/config.xml

Typically, a module makes this a hidden configuration field, and then supplies a default value in config.xml. Consider this bit of XML from 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>

在这里,他们设置了payment/method_ccsave的模型.这是与PHP Model类相对应的类别名

Here they've setup a model of payment/method_ccsave. This is a class alias that corresponds to the PHP Model class

Mage_Payment_Model_Method_Ccsave

您的配置似乎缺少该类,这是您的付款选项未出现的原因之一.

You configuration appears to be missing this class, which is one reason your payment option doesn't appear.

这篇关于Magento自定义支付网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆