Bug: Doesn't add tax to Paypal subscriptions

Discussion in 'Troubleshooting' started by sirc, Mar 1, 2007.

  1. sirc

    sirc New Member

    Joined:
    Sep 24, 2005
    Messages:
    3
    Just reporting a bug in the paypal processing plugin found when I upgraded from aMember 2.x.x to 3.0.8

    The paypal payment plugin doesn't at tax to subscriptions products.

    To fix this bug, in plugins/payment/paypal_r/paypal_r.inc.php line 193 I added the follow code (which was in my previous version of paypal_r.inc.php
    PHP:
    $a[3] = $total_price// dirty hack to make coupons working!
    The full version of the function build_subscription_params at line:137 now looks like.
    PHP:
    function build_subscription_params($products$total_price){
            
    $a $p $t = array(=> ''=> ''=> '');
            
    $was_recurring 0;
            foreach (
    $products as $pr){
                
    $pa $pp $pt = array(=> ''=> ''=> '');
                
    $pa[1] = $pr['trial1_price'];
                
    $pa[2] = $pr['trial2_price'];
                
    $pa[3] = $pr['price'];
                if (
    $pr['trial1_days'] != '')
                    list(
    $pp[1], $pt[1]) = $this->get_days($pr['trial1_days']);
                if (
    $pr['trial2_days'] != '')
                    list(
    $pp[2], $pt[2]) = $this->get_days($pr['trial2_days']);
                if (
    $pr['expire_days'] != '')
                    list(
    $pp[3], $pt[3]) = $this->get_days($pr['expire_days']);
                if (!
    $pr['is_recurring']){
                    
    fatal_error(_PLUG_PAY_PAYPALR_FERROR7);
                    
    //$a[1] += $pa[3];
                    // there is at least one recurring product if we went here
                
    } else { // recurring
                    
    if ($was_recurring){ // check if it was compatible
                        
    if (array_diff($p$pp) || array_diff($t$pt))
                            
    fatal_error(_PLUG_PAY_PAYPALR_FERROR8);
                    }
                    
    $a[1]+=$pa[1]; $a[2]+=$pa[2]; $a[3]+=$pa[3];
                    
    $p[1] =$pp[1]; $p[2] =$pp[2]; $p[3] =$pp[3];
                    
    $t[1] =$pt[1]; $t[2] =$pt[2]; $t[3] =$pt[3];
                    
    $was_recurring++;
                }
            }
            if (
    $a[1] && !$p[1]){
                
    $p[1] = $p[3];
                
    $t[1] = $t[3];
            }
            
    ///
            
    if ($disc $GLOBALS['COUPON_DISCOUNT']){
                if (
    $a[1]){ // first trial used, make second
                    
    fatal_error(_PLUG_PAY_PAYPALR_ERROR12);
                } else {
                    
    $a[1] = $a[3] - $disc;
                    
    $p[1] = $p[3];
                    
    $t[1] = $t[3];
                }
            }
            
    $a[3] = $total_price// dirty hack to make coupons working!
            
    return array($a$p$t);
        }
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    This may cause other issues.

    Hopefully, we already have working code that keeps these problems in past. It will be released with aMember 3.1.0-BETA.

Share This Page