Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 33
  1. #11
    Join Date
    Apr 2008
    Location
    internet
    Posts
    41
    Plugin Contributions
    0

    Default Re: 1.3.9e :: PayPal Express Checkout :: error 10413 & 10417 :: totals do not match

    yes, removedthe sale
    and its fine.

    seems its caused by the rounding of the totals.

    in the shopping cart, im assuming you first multiple amount by qty then round off.

    in paypal, it firsts rounds off then multiplies by the qty.

    also i noticed in paypalwpp.php, your check
    PHP Code:
        // check subtotals
        
    if (strval($subTotalLI) - strval($sumOfLineItems) > 0.02) {
          
    $this->zcLog('getLineItemDetails 5''Line-item subtotals do not add up properly. Line-item-details skipped.' "\n" . (float)$sumOfLineItems ' ' . (float)$subTotalTax print_r(array_merge($optionsST$optionsLI), true));
          
    $optionsLI = array();
        } 
    should this be changed to

    PHP Code:
        // check subtotals
        
    if (strval($optionsST['ITEMAMT']) - strval($sumOfLineItems) > 0) {
          
    $this->zcLog('getLineItemDetails 5''Line-item subtotals do not add up properly. Line-item-details skipped.' "\n" . (float)$sumOfLineItems ' ' . (float)$subTotalTax print_r(array_merge($optionsST$optionsLI), true));
          
    $optionsLI = array();
        } 

  2. #12
    Join Date
    Apr 2009
    Posts
    46
    Plugin Contributions
    0

    Default Re: 1.3.9e :: PayPal Express Checkout :: error 10413 & 10417 :: totals do not match

    Does this code change fix the problem with those errors?

  3. #13
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: 1.3.9e :: PayPal Express Checkout :: error 10413 & 10417 :: totals do not match

    Quote Originally Posted by Dazmode View Post
    Does this code change fix the problem with those errors?
    Dazmode, are you asking that question because you have a SALE on AND you're getting those errors ONLY when the sale is on?
    If not, then your issue might well be different, and thus the suggested change may not be relevant.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #14
    Join Date
    Apr 2009
    Posts
    46
    Plugin Contributions
    0

    Default Re: 1.3.9e :: PayPal Express Checkout :: error 10413 & 10417 :: totals do not match

    I just disabled sale that was based on % discount and I will wait few days to see if errors will stop.

    Thank you for double checking on cause.

  5. #15
    Join Date
    Apr 2009
    Posts
    46
    Plugin Contributions
    0

    Default Re: 1.3.9e :: PayPal Express Checkout :: error 10413 & 10417 :: totals do not match

    Got same the error on items that are not on sale. I guess I have something else.

  6. #16
    Join Date
    Apr 2008
    Location
    internet
    Posts
    41
    Plugin Contributions
    0

    Default Re: 1.3.9e :: PayPal Express Checkout :: error 10413 & 10417 :: totals do not match

    you can try my work around posted above, it will remove all the line items when the totals do not add up (bug work around)

    Ive rewritten large parts of paypalwpp.php , in order to fix this and a few other paypal quirks.
    Last edited by xcooling; 23 Aug 2010 at 07:04 PM.

  7. #17
    Join Date
    Apr 2009
    Posts
    46
    Plugin Contributions
    0

    Default Re: Website Payments Pro dreaded 10413 problem caused by rounding error with taxes

    It seems this error shows mostly for item with .99c price ending. When price rounded up, customers can check out ok.

  8. #18
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: 1.3.9e :: PayPal Express Checkout :: error 10413 & 10417 :: totals do not match

    Here's a possible solution. Unfortunately I can't test it with your exact configuration, since I don't have those details.

    Perhaps you can test it and see what happens for you, and report back.

    /includes/modules/payment/paypalwpp.php
    Around line 1171 you'll see this block of code:
    Code:
          // PayPal can't handle partial-quantity values, so fudge it here
          if ($order->products[$i]['qty'] != (int)$order->products[$i]['qty']) {
            $optionsLI["L_NAME$k"] = '('.$order->products[$i]['qty'].' x ) ' . $optionsLI["L_NAME$k"];
            $optionsLI["L_AMT$k"] = ($order->products[$i]['qty'] * $order->products[$i]['final_price']);
            $optionsLI["L_TAXAMT$k"] = zen_calculate_tax($order->products[$i]['qty'] * $order->products[$i]['final_price'], $order->products[$i]['tax']);
            $optionsLI["L_QTY$k"] = 1;
          } else {
            $optionsLI["L_AMT$k"] = $order->products[$i]['final_price'];
            $optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
            $optionsLI["L_TAXAMT$k"] = zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']);
          }
    Replace it with the following block of code:
    Code:
          // check for rounding problems with taxes
          $m1 = zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
          $m2 = ($order->products[$i]['qty'] * zen_round($order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']));
          $n1 = $order->products[$i]['qty'] * zen_calculate_tax($order->products[$i]['final_price'], $order->products[$i]['tax']);
          $n2 = zen_calculate_tax($order->products[$i]['qty'] * $order->products[$i]['final_price'], $order->products[$i]['tax']);
          if ($m1 != $m2 || zen_round($n1, $currencies->currencies[$_SESSION['currency']]['decimal_places']) != zen_round($n2, $currencies->currencies[$_SESSION['currency']]['decimal_places'])) $flag_treat_as_partial = true;
    
          // PayPal can't handle partial-quantity values, so fudge it here
          if ($flag_treat_as_partial || $order->products[$i]['qty'] != (int)$order->products[$i]['qty']) {
            $optionsLI["L_NAME$k"] = '('.$order->products[$i]['qty'].' x ) ' . $optionsLI["L_NAME$k"];
            $optionsLI["L_AMT$k"] = zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
            $optionsLI["L_TAXAMT$k"] = zen_calculate_tax(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), $order->products[$i]['tax']);
            $optionsLI["L_QTY$k"] = 1;
          } else {
            $optionsLI["L_AMT$k"] = $order->products[$i]['final_price'];
            $optionsLI["L_QTY$k"] = $order->products[$i]['qty'];
            $optionsLI["L_TAXAMT$k"] = zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']);
          }
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #19
    Join Date
    Apr 2009
    Posts
    46
    Plugin Contributions
    0

    Default Re: [Done v1.3.9g] PayPal Express Checkout :: error 10413 & 10417 :: totals do not ma

    Seems it helped. Thank you.

  10. #20
    Join Date
    Apr 2008
    Location
    internet
    Posts
    41
    Plugin Contributions
    0

    red flag Re: [Done v1.3.9g] PayPal Express Checkout :: error 10413 & 10417 :: totals do not ma

    After extensive testing, your solution does not fix all the rounding errors.

    You need to add the following code as well as yours, to solve all the issues. (tested on +/-500 PAYPAL orders)


    /includes/modules/payment/paypalwpp.php

    Find the following, around line 1320
    Code:
    // check subtotals
        if (strval($subTotalLI) - strval($sumOfLineItems) > 0.02) {
          $this->zcLog('getLineItemDetails 5', 'Line-item subtotals do not add up properly. Line-item-details skipped.' . "\n" . (float)$sumOfLineItems . ' ' . (float)$subTotalTax . print_r(array_merge($optionsST, $optionsLI), true));
          $optionsLI = array();
        }
    After the code, Add the following
    Code:
    /****** BOF BUG FIX ******/
    	// By Adrian kriel : root-at-extremecooling-dot-org
        // Do extra sanity check on item amount and line item totals (bug fix to prevent fail with error code 10413)
    	//(caused by item being on sale, price is rounded off before the qty multiplication, hence why totals will be out by a few cents)
    	// this will add an extra line item that will appear on the paypal invoice.
    	
    $this->zcLog('getLineItemDetails 6', 'PayPal Correction Info:(sumOfLineItems: '.$sumOfLineItems.', ITEMAMT: '.$optionsST['ITEMAMT'].')'."\n");
    
    	if(strval($optionsST['ITEMAMT'])!= strval($sumOfLineItems)){ //$optionsST['ITEMAMT'] seems to be a more correct varible, than using $subTotalLI
    		
    		$numberOfLineItemsProcessed++;
            $k = $numberOfLineItemsProcessed;
    				
    		//check to make sure we have more than 1 line option
    		if($k >= 1){
    			//calculate the correction value required.
    			$lineItemCorrection = strval($optionsST['ITEMAMT']) - strval($sumOfLineItems);
    	
    			$this->zcLog('getLineItemDetails 6', 'PayPal Correction Fixed: Line-item subtotals do not add up properly (sumOfLineItems: '.$sumOfLineItems.', ITEMAMT: '.$optionsST['ITEMAMT'].'). Adding Bugfix line item with ammount: '. $lineItemCorrection .'\n');
    			
    			//you could reset the array instead of assigning an extra line item
    			//$optionsLI = array();
    			$optionsLI["L_NUMBER$k"] = "";
    			$optionsLI["L_NAME$k"] = "PayPal Correction";
    			$optionsLI["L_AMT$k"] = strval($lineItemCorrection);
    			$optionsLI["L_QTY$k"] = 1;	  
    			
    			$sumOfLineItems += strval($lineItemCorrection); //update the $sumOfLineItems Total
    		}
        }
    /****** EOF BUG FIX ******/
    Attached Images Attached Images  
    Last edited by xcooling; 28 Sep 2010 at 02:53 PM.

 

 
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. v150 Paypal Express Checkout 10417 error; only from Customers using Pay-pal account to pay
    By mikecnz in forum PayPal Express Checkout support
    Replies: 1
    Last Post: 5 Mar 2013, 05:15 AM
  2. Replies: 2
    Last Post: 5 Apr 2012, 06:42 AM
  3. PayPal Express Checkout Error (10413)‏
    By Easyp in forum PayPal Express Checkout support
    Replies: 2
    Last Post: 14 Feb 2010, 06:12 AM
  4. 10417 errors Paypal Express Checkout
    By Natty in forum PayPal Express Checkout support
    Replies: 1
    Last Post: 26 Dec 2009, 10:37 PM
  5. Field format error: 10413-The totals of the cart item amounts do not match
    By roscoeh in forum PayPal Website Payments Pro support
    Replies: 1
    Last Post: 14 Aug 2008, 10:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg