当前位置: 首页 > 工具软件 > VirtueMart > 使用案例 >

Virtuemart PayPal API Bugs and Solutions

楚威
2023-12-01
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
 类似资料:

相关阅读

相关文章

相关问答