开发者

Creating two business account in paypal standard

Can anyone tell me how can i create two bu开发者_高级运维siness accounts? Actually, i want functionality like this, if my cart total becomes greater than 100USD than i want to pass it to my first merchant account else want to pass second merchant email. I know, its feasible. When page is redirected to paypal i have to pass different emails based on cart total.I want to create a saparate module by which i can provide two merchant emails , so these both entered emails can be used based on cart total.TIA, any help?


Create system.xml and paste

<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>

And create config.xml and paste

<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>

Then override standard.php and declare getStandardCheckoutFormFields() method in which have to put logic as written in above comment. You will surely get error of private method _getAggregatedCartSummary() so redefine as it is as in core just scope is public. And finished.


Take a look at this recent answer regarding using two Authorize.net accounts. The concept for Paypal is the same. In the model Mage_Paypal_Model_Standard, there is a method called 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 looks like your best bet for an override. At this point you should be able to call:

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

to get your quote object. Use that to decide which Paypal information to load. Save that paypal information in the database under an alternate path (say paypal/config_alt) and return as necessary.

Hope that helps!


Finally,I have added in system.xml after tag as

<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>

After creating this and save config,you can see in core_config_data table that there is a path set at last as 'paypal/general/business_account2'. Now change getStandardCheckoutFormFields() as

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

after $result = $api->getStandardCheckoutRequest(); in Payment/Model/Standard.php, I have made these changes in Core files, But as you all know i have to create this using local folder.I hope this may help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜