1

magento 结帐页面中,我想要Credit card payment on delivery喜欢the cash on delivery

是否有人实施此信用卡货到付款,请帮助我

也请提供参考链接

提前致谢

4

1 回答 1

4

只是代码,是的,有可能做到这一点。

基本上你只需要这样的模型:支付模块的基本结构是(我将展示带有1个附加信息字段的基本支付示例:

Module
------->Block
------------->Form
------------------->Pay.php
------------->Info
------------------->Pay.php
------->etc
------------->config.xml
------------->system.xml
------->Model
------------->Paymentmethodmodel.php

关于这个模块的重要事项:

Yourpaymentmodule_Block_Form_Pay

此块制作前端视图。编码:

<?php
class YourPaymentModule_Block_Form_Pay extends Mage_Payment_Block_Form
{
protected function _construct(){
    parent::_construct();
    $this->setTemplate('yourpaymentmodule/form/pay.phtml');
}
}

另一个是 Yourpaymentmodule_Block_Info_Pay,这个是从 Admin Order Details 中查看的。

<?php
class YourPaymentModule_Block_Info_Pay extends Mage_Payment_Block_Info
{
protected function _construct(){
    parent::_construct();
    $this->setTemplate('yourpaymentmodule/form/pay.phtml');
}

protected function _prepareSpecificInformation($transport = null)
{
    if (null !== $this->_paymentSpecificInformation) {
        return $this->_paymentSpecificInformation;
    }
    $info = $this->getInfo();
    $transport = new Varien_Object();
    $transport = parent::_prepareSpecificInformation($transport);
    $transport->addData(array(
        Mage::helper('payment')->__('Additional Information') => $info->getAdditional(),
    ));
    return $transport;
}
}

最后在你的模型上:

<?php 
class PPaymentModuleName_Model_PaymentModuleName extends Mage_Payment_Model_Method_Abstract
{
    protected $_code = 'custompaymentmodule';
    protected $_formBlockType = 'custompaymentmodule/form_pay';
    protected $_infoBlockType = 'custompaymentmodule/info_pay';
    protected $_canUseInternal              = true;
    protected $_canOrder                    = true;

public function assignData($data)
{
    if (!($data instanceof Varien_Object)) {
        $data = new Varien_Object($data);
    }
    $info = $this->getInfoInstance();
    $info->setAdditionalINformation($data->getAdditionalINformation());
    return $this;
}

public function canUseForCountry($country)
{
    return true;
}

public function canUseForCurrency($currencyCode){
    return true;
}
}
    ?>

在您的 phtml 文件上,您进行设计,只是简单的字段或其他东西。

其他重要的事情在您的 etc/modules/CustomPaymentModule.xml 中:

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
    <CustomPaymentModule>
        <active>true</active>
        <codePool>community</codePool>
        <depends> 
            <Mage_Payment /> 
        </depends> 
    </CustomPaymentModule>
</modules>
</config>

就是这样。

于 2012-12-05T13:02:38.197 回答