Virtuemart PayPal API Bugs and Solutions

http://www.aglobalweb.com/aglobalweb/blog/2-virtuemart/48-virtuemart-paypal-api

Problem

The introduction of new payment method "PayPal (new API)" is causing "Credit Card" payment option to appear for no reason.

Solution

To completely get rid of this problem, there are 3 files involved

  • administrator/components/com_virtuemart/classes/ps_checkout.php -> method list_payment_methods()
  • administrator/components/com_virtuemart/classes/ps_payment_method.php -> method list_payment_radio()
  • components/com_virtuemart/themes/default/templates/checkout/get_payment_method_paypal_ex.tpl.php

administrator/components/com_virtuemart/classes/ps_checkout.php Line 826-834

Paypal (new API) are implemented separately from generic Virtuemart payment methods. So we need to prevent it from reloading again

function list_payment_methods( $payment_method_id=0 ) {
        ...
        
        $db_nocc  = new ps_DB;
        $q = "SELECT * from #__{vm}_payment_method,#__{vm}_shopper_group WHERE ";
        $q .= "#__{vm}_payment_method.shopper_group_id=#__{vm}_shopper_group.shopper_group_id ";
        $q .= "AND (#__{vm}_payment_method.shopper_group_id='".$auth['shopper_group_id']."' ";
        $q .= "OR #__{vm}_shopper_group.default='1') ";
        $q .= "AND (enable_processor='B' OR enable_processor='N' OR (enable_processor='P' AND `payment_class`!='ps_paypal_api')) ";
        $q .= "AND payment_enabled='Y' ";
        $q .= "AND #__{vm}_payment_method.vendor_id='$ps_vendor_id' ";
        $q .= " ORDER BY list_order";
...
        
 }

administrator/components/com_virtuemart/classes/ps_payment_method.php Line 394-397 

Paypal (new API) are implemented separately from generic Virtuemart payment methods. So we need to prevent it from reloading again

function list_payment_radio($selector, $payment_method_id, $horiz) {

...

$q = "SELECT payment_method_id,payment_method_discount, payment_method_discount_is_percent, payment_method_name from #__{vm}_payment_method WHERE ";
        $q .= "(enable_processor='$selector' AND `payment_class`!='ps_paypal_api') AND ";
        $q .= "payment_enabled='Y' AND ";
        $q .= "vendor_id='$ps_vendor_id' AND ";

...

}

components/com_virtuemart/themes/default/templates/checkout/get_payment_method_paypal_ex.tpl.php Line 74-86

If you only use one payment method "Paypal (new API)", you need that payment method to be selected by default.

<fieldset><legend><strong>PayPal</strong></legend>
        <table border="0" cellspacing="0" cellpadding="2" width="100%">
            <tr>
                <td style="vertical-align:middle;">
                    <input type="hidden" id="paypalExpress_ecm" name="payment_method_ppex" value="" />
                    <input type="radio" id="paypalExpressID_ecm" name="payment_method_id" value="<?php echo ps_paypal_api::getPaymentMethodId();?>" checked="true" />
            </td>
            <td>
                    <?php echo $html; ?>
                </td>
            </tr>
        </table>
    </fieldset>

Last Updated on Monday, 07 March 2011 21:34
-bugs-and-solutions.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值