显示 Magento 自定义支付方式表单(扩展开发)

Displaying Magento Custom Payment Methods Form (Extension Development)

选择方法后,我无法显示 "My Custom Gateway" 的付款表格。

我已经创建了 form.phtml 模板并且它已正确加载。我可以看到标签已正确加载。此外,即使我还没有选择该方法,它也是可见的。因此我必须隐藏表单直到选择网关,所以我有以下 form.phtml:

<?php 
// PHP Code
?>
<ul class="form-list" id="mygateway_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
    <li>
        <div class="input-box">
            This will be the Forms
        </div>
    </li>
</ul>

在我的模型中,我扩展了 Mage_Payment_Model_Method_Abstract 而不是 CC

我在 Magento 源代码中找不到任何参考来处理这个琐碎的逻辑:隐藏和显示付款表单。

那么,在 magento 中,当用户点击特定的付款方式时,如何让我的表单可见?

参考列表

查看 payment/methods.phtmlinput.onclick 将触发 payment.switchMethod($_code)

深入varien/payment.js:switchMethod函数,命名约定对表单很重要。 id 必须以 payment_form_<paymentmethod>

开头

因此,我在forms.phtml中犯了一个错误。应该是:

<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">

现在可以正确显示表格了。