以paypal标准创建两个商业帐户

时间:2011-03-07 14:16:55

标签: magento paypal account

有谁能告诉我如何创建两个商业帐户?实际上,我想要这样的功能,如果我的购物车总数超过100美元,我想将其传递给我的第一个商家帐户,否则想要传递第二个商家电子邮件。我知道,这是可行的。当页面被重定向到paypal时,我必须根据购物车总数传递不同的电子邮件。我想创建一个saparate模块,我可以通过该模块提供两个商家电子邮件,因此这两个输入的电子邮件都可以根据购物车总数使用.TIA,任何帮助?

3 个答案:

答案 0 :(得分:0)

关于使用两个Authorize.net帐户,请查看this recent answer。 Paypal的概念是一样的。在模型Mage_Paypal_Model_Standard中,有一个名为getConfig的方法:

/**
 * Config instance getter
 * @return Mage_Paypal_Model_Config
 */
public function getConfig()
{
    if (null === $this->_config) {
        $params = array($this->_code);
        if ($store = $this->getStore()) {
            $params[] = is_object($store) ? $store->getId() : $store;
        }
        $this->_config = Mage::getModel('paypal/config', $params);
    }
    return $this->_config;
}    

对于覆盖来说,这似乎是你最好的选择。此时你应该可以打电话:

$this->getCheckout()->getQuote();

获取引用对象。用它来决定加载哪些Paypal信息。将该paypal信息保存在备用路径(例如paypal/config_alt)下的数据库中,并根据需要返回。

希望有所帮助!

答案 1 :(得分:0)

最后,我在标签后添加了system.xml

<business_account2 translate="label comment tooltip">
    <label>Email Associated with PayPal Merchant Account more than 100 amount</label>
    <comment><![CDATA[<a href="http://www.magentocommerce.com/paypal">Start accepting payments via PayPal!</a>]]></comment>
    <tooltip>Don't have a PayPal account? Simply enter your email address.</tooltip>
    <config_path>paypal/general/business_account2</config_path>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <sort_order>10</sort_order>
    <frontend_class>validate-email</frontend_class>
</business_account2>

创建此配置并保存配置后,您可以在core_config_data表中看到最后设置的路径为'paypal / general / business_account2'。现在将getStandardCheckoutFormFields()更改为

$business2 = Mage::getStoreConfig('paypal/general/business_account2');
$grandTotal = $order->getGrandTotal();
if($grandTotal >= 100) {
    unset($result['business']);
    $result['business'] = $business2;
}

在Payment / Model / Standard.php中的$result = $api->getStandardCheckoutRequest();后,我在Core文件中进行了这些更改,但是你们都知道我必须使用本地文件夹创建它。我希望这可以帮助你。

答案 2 :(得分:0)

创建system.xml并粘贴

<config>
  <sections>
    <paypal>
        <groups>
            <account translate="label">
                <label>Merchant Account</label>
                <fieldset_css>paypal-config</fieldset_css>
                <frontend_type>text</frontend_type>
                <sort_order>0</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <fields>
                    <business_account2 translate="label comment tooltip">
                        <label>Email Associated with PayPal Merchant Account more than 5 amount</label>
                        <comment><![CDATA[<a href="http://www.magentocommerce.com/paypal">Start accepting payments via PayPal!</a>]]></comment>
                        <tooltip>Don't have a PayPal account? Simply enter your email address.</tooltip>
                        <config_path>paypal/general/business_account2</config_path>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <sort_order>10</sort_order>
                        <frontend_class>validate-email</frontend_class>
                    </business_account2>
                </fields>
            </account>
        </groups>
    </paypal>
  </sections>
</config>

创建config.xml并粘贴

<config>
    <modules>
        <My_CustomPaypal>
            <version>1.0.0</version>
            <depends>
            <!-- no dependencies -->
            </depends>
        </My_CustomPaypal>
    </modules>
    <global>
        <models>
          <paypal>
              <rewrite>
                  <standard>My_CustomPaypal_Model_Standard</standard>
              </rewrite>
          </paypal>
        </models>
        <resources />
        <extraconfig />
        <blocks />
    </global>
</config>

然后覆盖standard.php并声明getStandardCheckoutFormFields()方法,其中必须放置上述注释中所写的逻辑。你肯定会得到私有方法_getAggregatedCartSummary()的错误,所以重新定义就像在核心只是范围是公共的。并完成了。