【问题标题】:Magento Custom Payment iFrame Module ErrorMagento 自定义支付 iFrame 模块错误
【发布时间】:2013-02-10 19:28:49
【问题描述】:

我正在尝试编写将调用 iFrame 而不是标准 CC 块的 Magento 支付模块。但是,当运行下面的代码时,出现以下错误:

致命错误:在第 106 行的 /opt/bitnami/apps/magento/htdocs/app/code/core/Mage/Payment/Helper/Data.php 中的非对象上调用成员函数 setMethod()

Config.xml:

 <?xml version="1.0"?>
<config>
    <modules>
       <Lynch_Peach>
<!-- declare module's version information for database updates -->
          <version>0.1.0</version>
       </Lynch_Peach>
    </modules>

    <global>
    <blocks>
        <peach>
            <class>Lynch_Peach_Block</class>
        </peach>
    </blocks>


        <models>
            <peach>
  <class>Lynch_Peach_Model</class>
            </peach>
        </models>

<!-- declare resource setup for new module -->
        <resources>
<!-- resource identifier -->
            <peach_setup>
<!-- specify that this resource is a setup resource and used for upgrades -->
                <setup>
<!-- which module to look for install/upgrade files in -->
                    <module>Lynch_Peach</module>
                </setup>
<!-- specify database connection for this resource -->
                <connection>
<!-- do not create new connection, use predefined core setup connection -->
                    <use>core_setup</use>
                </connection>
            </peach_setup>
            <peach_write>
                <connection>
                  <use>core_write</use>
                </connection>
            </peach_write>
            <peach_read>
               <connection>
                <use>core_read</use>
              </connection>
            </peach_read>
        </resources>
    </global>

<!-- declare default configuration values for this module -->
    <default>
<!-- 'payment' configuration section (tab) -->
        <payment>
<!-- 'peach' configuration group (fieldset) -->
            <peach>
<!-- by default this payment method is inactive -->
                <active>0</active>
<!-- model to handle logic for this payment method -->
                <model>peach/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>Peach Payments</title>

                <cctypes>VI,MC</cctypes>

                <payment_action>authorize_capture</payment_action>
                <allowspecific>0</allowspecific>
            </peach>
         </payment>
    </default>
</config>

支付方式.php

<?php
class Lynch_Peach_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
{

    protected $_code = 'peach';
    protected $_formBlockType = 'peach/form';
    protected $_isGateway               = false;
    protected $_canAuthorize            = false;
    protected $_canCapture              = false;
    protected $_canCapturePartial       = false;
    protected $_canRefund               = false;
    protected $_canVoid                 = false;
    protected $_canUseInternal          = false;
    protected $_canUseCheckout          = true;
    protected $_canUseForMultishipping  = false;
    protected $_canSaveCc = false;


  public function createFormBlock($name)
    {
        $block = $this->getLayout()->createBlock('peach/form', $name)
            ->setMethod('peach')
            ->setPayment($this->getPayment())
            ->setTemplate('peach/form.phtml');

        return $block;
    }

}
?>

Form.php:

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

?>

【问题讨论】:

  • 看起来不错。你哪里有这个错误?你在哪里使用createFormBlock函数?

标签: magento module payment


【解决方案1】:

表单构造函数中有双 $$。

【讨论】:

    【解决方案2】:

    您可以尝试应用以下更改。

    protected $_formBlockType = 'peach/form';
    

    像下面这样改变上面,

    protected $_formBlockType = 'peach/Form';
    

    如果您在 Windows 环境中运行应用程序,这通常无关紧要。但在非 Windows 环境中运行时,这可能会出现问题。

    【讨论】:

      猜你喜欢
      • 2013-10-11
      • 1970-01-01
      • 2011-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-10
      • 1970-01-01
      • 2014-07-09
      相关资源
      最近更新 更多