作为Magento单独的模块或几个方法可以结合在相同的模块,如果他们共享的功能或可以一起使用,每个支付方法可以做到。 让我们创建一个模块的一种支付方式,将:
我们的新模块将被称为NewModule的。
你的模块的名称和简化代码,仅包含字母数字字符和下划线的的“newmodule的所有实例替换”NewModule“。 确保app/code/local是在include_path。 如果您使用的是配置缓存,不要忘了复位后修改xml配置文件通过var/cache/config/删除的内容 一个很好的忠告:禁用缓存,然后再制定一个新的模块。 模块声明创建 app/etc/modules/CompanyName_NewModule.xml:
<config>
<modules>
<!-- declare CompanyName_NewModule module -->
<CompanyName_NewModule>
<!-- this is an active module -->
<active>true</active>
<!-- this module will be located in app/code/local code pool -->
<codePool>local</codePool>
<!-- specify dependencies for correct module loading order -->
<depends>
<Mage_Payment />
</depends>
</CompanyName_NewModule>
</modules>
</config>
现在,应用程序可以识别的模块,我们将让Magento的了解我们的模块的详细信息。 模块配置创建 app/code/local/CompanyName/NewModule/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<CompanyName_NewModule>
<!-- declare module's version information for database updates -->
<version>0.1.0</version>
</CompanyName_NewModule>
</modules>
<global>
<!-- IMPORTANT: if you use your own namespace (i.e. CompanyName) you also have to declare blocks group for new module. See topic: http://www.magentocommerce.com/boards/viewthread/22416/#t102732 -->
<blocks>
<newmodule>
<class>CompanyName_NewModule_Block</class>
</newmodule>
</blocks>
<!-- declare model group for new module -->
<models>
<!-- model group alias to be used in Mage::getModel('newmodule/...') -->
<newmodule>
<!-- base class name for the model group -->
<class>CompanyName_NewModule_Model</class>
</newmodule>
</models>
<!-- declare resource setup for new module -->
<resources>
<!-- resource identifier -->
<newmodule_setup>
<!-- specify that this resource is a setup resource and used for upgrades -->
<setup>
<!-- which module to look for install/upgrade files in -->
<module>CompanyName_NewModule</module>
</setup>
<!-- specify database connection for this resource -->
<connection>
<!-- do not create new connection, use predefined core setup connection -->
<use>core_setup</use>
</connection>
</newmodule_setup>
<newmodule_write>
<connection>
<use>core_write</use>
</connection>
</newmodule_write>
<newmodule_read>
<connection>
<use>core_read</use>
</connection>
</newmodule_read>
</resources>
</global>
<!-- declare default configuration values for this module -->
<default>
<!-- 'payment' configuration section (tab) -->
<payment>
<!-- 'newmodule' configuration group (fieldset) -->
<newmodule>
<!-- by default this payment method is inactive -->
<active>0</active>
<!-- model to handle logic for this payment method -->
<model>newmodule/paymentMethod</model>
<!-- order status for new orders paid by this payment method -->
<order_status>pending</order_status>
<!-- default title for payment checkout page and order view page -->
<title>Credit Card (Authorize.net)</title>
<cctypes>AE,VI,MC,DI</cctypes>
<payment_action>authorize</payment_action>
<allowspecific>0</allowspecific>
</newmodule>
</payment>
</default>
</config>
适配模型
注:PAYMENTMETHOD是任意的,是你的决定。如上图所示(请参阅config→default→payment→newmodule→model),您需要在config.xml中定义这个方法的名字。
<?php
/**
* Our test CC module adapter
*/
class CompanyName_NewModule_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
{
/**
* unique internal payment method identifier
*
* @var string [a-z0-9_]
*/
protected $_code = 'newmodule';
/**
* Here are examples of flags that will determine functionality availability
* of this module to be used by frontend and backend.
*
* @see all flags and their defaults in Mage_Payment_Model_Method_Abstract
*
* It is possible to have a custom dynamic logic by overloading
* public function can* for each flag respectively
*/
/**
* Is this payment method a gateway (online auth/charge) ?
*/
protected $_isGateway = true;
/**
* Can authorize online?
*/
protected $_canAuthorize = true;
/**
* Can capture funds online?
*/
protected $_canCapture = true;
/**
* Can capture partial amounts online?
*/
protected $_canCapturePartial = false;
/**
* Can refund online?
*/
protected $_canRefund = false;
/**
* Can void transactions online?
*/
protected $_canVoid = true;
/**
* Can use this payment method in administration panel?
*/
protected $_canUseInternal = true;
/**
* Can show this payment method as an option on checkout payment page?
*/
protected $_canUseCheckout = true;
/**
* Is this payment method suitable for multi-shipping checkout?
*/
protected $_canUseForMultishipping = true;
/**
* Can save credit card information for future processing?
*/
protected $_canSaveCc = false;
/**
* Here you will need to implement authorize, capture and void public methods
*
* @see examples of transaction specific public methods such as
* authorize, capture and void in Mage_Paygate_Model_Authorizenet
*/
}
?>
这是会做的所有实际工作与您的支付网关进行通信的类。当用户创建命令的授权或捕获您的类的方法将被调用。哪一种取决于您的设置。如果在管理页面中选择了”仅授权”,将调用该授权方法。如果您选择了”授权和捕获”,混淆不够只捕获方法将调用。如果您需要声明这些方法使用中的错误:
Mage::throwException("My error/debug message here");
这将导致 Magento,显示在您的消息的 javascript 弹出并停止订单处理。 现在,我们已让我们的模型给管理员配置它,并让结帐过程意识到此方法的方式。 声明管理面板的配置选项
此文件将定义如何您看到 Magento 管理面板系统中的System > Configuration
<?xml version="1.0"?>
<config>
<sections>
<!-- payment tab -->
<payment>
<groups>
<!-- newmodule fieldset -->
<newmodule translate="label" module="paygate">
<!-- will have title 'New Module' -->
<label>New Module</label>
<!-- position between other payment methods -->
<sort_order>670</sort_order>
<!-- do not show this configuration options in store scope -->
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<!-- is this payment method active for the website? -->
<active translate="label">
<!-- label for the field -->
<label>Enabled</label>
<!-- input type for configuration value -->
<frontend_type>select</frontend_type>
<!-- model to take the option values from -->
<source_model>adminhtml/system_config_source_yesno</source_model>
<!-- field position -->
<sort_order>1</sort_order>
<!-- do not show this field in store scope -->
<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>New order status</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
<sort_order>4</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>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>0</show_in_store>
</title>
</fields>
</newmodule>
</groups>
</payment>
</sections>
</config>
如果你现在去Admin/System/Configuration/Payment Methods,您应该看到”新建模块”组。使它并尝试签出。付款方法页面上,您应该看到”新建模块”付款方式与信用卡窗体。 数据库更新创建 app/code/local/CompanyName/NewModule/sql/newmodule_setup/mysql4-install-0.1.0.php:
<?php
// here are the table creation for this module e.g.:
$this->startSetup();
$this->run("HERE YOUR SQL");
$this->endSetup();
对于数据库更新更改在您的 confg.xml 模块版本:
<modules>
<CompanyName_NewModule>
<version>0.2.0</version>
</CompanyName_NewModule>
</modules>
然后创建 app/code/local/CompanyName/NewModule/sql/newmodule_setup/mysql4-upgrade-0.1.0-0.2.0.php:
<?php
// here are the table updates for this module e.g.:
$this->startSetup();
$this->run("HERE YOUR UPDATE SQL");
$this->endSetup();
故障排除
|

ecshop仿橡果国际2011模板
人气:684
Milano跨境电商综合商城m
人气:171
ecshop 商品详细页 快速订购
人气:1998
仿rutaobao俄文淘宝代购系统
人气:1130
ecshop仿kela珂兰钻石整站模
人气:681
Tiffany模板ecshop模板
人气:939