Forums / Bug Reports / [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

[Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

Locked

Views: 2,102

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
23 Aug 2010, 5:00 PM
#1
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

[Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

We are also having the dreaded 10413 problem. The problem is definitely caused by rounding error and in our case it was triggered this time around by rounding error with tax calculation. Not really sure how to solve this problem because it looks like Zen Cart and PayPal are using two different rounding methods which results in $0.01 (one cent) difference. If I process the same order but ship to a customer outside of GA (meaning no tax calculation) then the transaction goes through just fine.

Here is the log:

Aug-23-2010 12:10:14 (1282579814)
getLineItemDetails 7 - subtotal comparisons
BEFORE line-item calcs: Array
(
    [AMT] => 51.13
    [ITEMAMT] => 42.99
    [TAXAMT] => 2.89
    [SHIPPINGAMT] => 5.25
    [SHIPDISCAMT] => 0
    [HANDLINGAMT] => 0
    [INSURANCEAMT] => 0
)
 - AFTER doing line-item calcs: Array
(
    [AMT] => 51.13
    [ITEMAMT] => 42.99
    [TAXAMT] => 2.575
    [SHIPPINGAMT] => 5.565
    [SHIPDISCAMT] => 0
    [HANDLINGAMT] => 0
    [INSURANCEAMT] => 0
    [L_NUMBER0] => CSBK0772
    [L_NAME0] => Read and Share DVD Bible Gift Set (4 DVD Pack) by Gwen Ellis
    [L_AMT0] => 42.99
    [L_QTY0] => 1
)

=================================

Aug-23-2010 12:10:14 (1282579814)
getLineItemDetails 8
checking subtotals... 
Array
(
    [calculated total] => 51.13
    [AMT] => 51.13
    [ITEMAMT] => 42.99
    [TAXAMT] => 2.58
    [SHIPPINGAMT] => 5.57
)

-------------------
difference: 0  (abs+rounded: 0)
=================================

Aug-23-2010 12:10:14 (1282579814)
getLineItemDetails 10
subtotals balance - okay
=================================

Aug-23-2010 12:10:14 (1282579814)
before_process - DP-1
Beginning DP mode
=================================

Aug-23-2010 12:10:14 (1282579814)
before_process - DP-4
options: Array
(
    [AMT] => 51.13
    [ITEMAMT] => 42.99
    [TAXAMT] => 2.58
    [SHIPPINGAMT] => 5.57
    [L_NUMBER0] => CSBK0772
    [L_NAME0] => Read and Share DVD Bible Gift Set (4 DVD Pack) by Gwen Ellis
    [L_AMT0] => 42.99
    [L_QTY0] => 1
    [STREET] => MASKED***
    [ZIP] => 30144
    [CITY] => Kennesaw
    [STATE] => GA
    [EXPDATE] => 082010
    [EMAIL] => MASKED***
    [PHONENUM] => MASKED***
    [BUTTONSOURCE] => ZenCart-DP_us
    [CURRENCY] => USD
    [IPADDRESS] => MASKED***
    [CARDISSUE] => 
    [CUSTOM] => DP-92-1282579814
    [INVNUM] => 92-1282579814-[Clevershopperscom]
    [COUNTRY] => US
    [PAYMENTACTION] => Sale
    [SHIPTONAME] => MASKED***
    [SHIPTOSTREET] => MASKED***
    [SHIPTOCITY] => Kennesaw
    [SHIPTOZIP] => 30144
    [SHIPTOSTATE] => GA
    [SHIPTOCOUNTRY] => US
)

Rest of data: 
MASKED*** Visa
=================================

Aug-23-2010 12:10:15 (1282579815)
before_process - DP-5
resultset:
Array
(
    [TIMESTAMP] => 2010-08-23T16:10:09Z
    [CORRELATIONID] => 1061d6076cde9
    [ACK] => Failure
    [VERSION] => 60.0
    [BUILD] => 1466644
    [L_ERRORCODE0] => 10413
    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_LONGMESSAGE0] => The totals of the cart item amounts do not match order amounts.
    [L_SEVERITYCODE0] => Error
    [AMT] => 51.14
    [CURRENCYCODE] => USD
    [CURL_ERRORS] => 
)

=================================

Aug-23-2010 12:10:15 (1282579815)
termEC-2
BEFORE: Token Data:
=================================

Aug-23-2010 12:10:15 (1282579815)
termEC-10
Redirecting to checkout_payment - Stack: checkout_payment
Message: 10413  <!--  -->  Transaction refused because of an invalid argument. See additional error messages for details. - The totals of the cart item amounts do not match order amounts.
Session Data: Array
(
    [securityToken] => MASKED***
    [customers_host_address] => OFFICE_IP_TO_HOST_ADDRESS
    [cartID] => 
    [cart] => shoppingCart Object
        (
            [contents] => Array
                (
                    [67797] => Array
                        (
                            [qty] => 1
                        )

                )

            [total] => 42.99
            [weight] => 1
            [cartID] => 
            [content_type] => physical
            [free_shipping_item] => 0
            [free_shipping_weight] => 0
            [free_shipping_price] => 0
        )

    [navigation] => navigationHistory Object
        (
            [path] => Array
                (
                    [0] => Array
                        (
                            [page] => index
                            [mode] => NONSSL
                            [get] => Array
                                (
                                    [inc_subcat] => 1
                                    [search_in_description] => 1
                                    [keyword] => read and share bible
                                    [sort] => 4d
                                    [action] => multiple_products_add_product
                                    [zenid] => MASKED***
                                )

                            [post] => Array
                                (
                                )

                        )

                    [1] => Array
                        (
                            [page] => shopping_cart
                            [mode] => NONSSL
                            [get] => Array
                                (
                                    [inc_subcat] => 1
                                    [search_in_description] => 1
                                    [keyword] => read and share bible
                                    [sort] => 4d
                                )

                            [post] => Array
                                (
                                )

                        )

                    [2] => Array
                        (
                            [page] => checkout_shipping
                            [mode] => SSL
                            [get] => 
                            [post] => Array
                                (
                                )

                        )

                    [3] => Array
                        (
                            [page] => checkout_payment
                            [mode] => SSL
                            [get] => 
                            [post] => Array
                                (
                                )

                        )

                    [4] => Array
                        (
                            [page] => checkout_confirmation
                            [mode] => SSL
                            [get] => 
                            [post] => Array
                                (
                                )

                        )

                    [5] => Array
                        (
                            [page] => checkout_process
                            [mode] => SSL
                            [get] => 
                            [post] => Array
                                (
                                )

                        )

                )

            [snapshot] => Array
                (
                )

        )

    [check_valid] => true
    [language] => english
    [languages_id] => 1
    [languages_code] => en
    [currency] => USD
    [today_is] => 2010-08-23
    [updateExpirations] => 1
    [recent_products] => Array
        (
        )

    [session_counter] => 1
    [customers_ip_address] => MASKED***
    [new_products_id_in_cart] => 67797
    [valid_to_checkout] => 1
    [cart_errors] => 
    [payment] => paypaldp
    [cot_gv] => 0.00
    [REWARD_POINTS_EARNED] => 43
    [cart_country_id] => 223
    [country_info] => Array
        (
            [countries_name] => United States
            [countries_iso_code_2] => US
            [countries_iso_code_3] => USA
        )

    [customer_id] => 92
    [customer_default_address_id] => 102
    [customers_authorization] => 0
    [customer_first_name] => Customer
    [customer_last_name] => Support
    [customer_country_id] => 223
    [customer_zone_id] => 19
    [sendto] => 102
    [shipping] => Array
        (
            [id] => usps_PRIORITY
            [title] => United States Postal Service (Priority Mail (2 - 3 days))
            [cost] => 5.25
        )

    [billto] => 102
    [shipping_tax_description] => GA Sales Tax
    [shipping_tax_amount] => 0.315
    [comments] => 
    [paypal_ec_markflow] => 1
    [payment_attempt] => 1
    [messageToStack] => Array
        (
            [0] => Array
                (
                    [class] => checkout_payment
                    [text] => 10413  <!--  -->  Transaction refused because of an invalid argument. See additional error messages for details. - The totals of the cart item amounts do not match order amounts.
                    [type] => error
                )

        )

)

=================================
23 Aug 2010, 5:04 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

What version of Zen Cart are you using?

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

23 Aug 2010, 5:18 PM
#3
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

That particular checkout was for Website Payments Pro and we are using Zen Cart 1.3.9f.

I will test the same thing in PayPal Express Checkout

Thanks!

3 Sep 2010, 9:51 PM
#4
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

I'd greatly appreciate if there is another code modification to try and resolve this issue.

Thanks!

8 Sep 2010, 2:01 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

In the example you gave, the problem is occurring when the taxes are backed out of the overall tax amount and the shipping-taxes combined with the shipping amount ... but the amount being adjusted isn't getting rounded early enough. The following should take care of that:

Try changing line 1482 in /includes/modules/payment/paypaldp.php from this:```
$taxAdjustmentForShipping = zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);

to this:```
  $taxAdjustmentForShipping = zen_round(zen_calculate_tax($order->info['shipping_cost'], $shipping_tax), $currencies->currencies[$_SESSION['currency']]['decimal_places']);

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

8 Sep 2010, 4:23 PM
#6
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

I am not sure that we have the same file version because line 1482 doesn't look like anything you referenced above.

The version information in the top of my file is: @version $Id: paypaldp.php 17043 2010-07-28 18:36:22Z drbyte $

Line 1482 is:

} else {
8 Sep 2010, 4:39 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

Wherever that line is found, give or take 100 lines, change it.

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

8 Sep 2010, 5:32 PM
#8
blessisaacola avatar

blessisaacola

Totally Zenned

Join Date:
Feb 2004
Location:
Georgia, USA
Posts:
1,875
Plugin Contributions:
1

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

DrByte:

In the example you gave, the problem is occurring when the taxes are backed out of the overall tax amount and the shipping-taxes combined with the shipping amount ... but the amount being adjusted isn't getting rounded early enough. The following should take care of that:

Try changing line 1482 in /includes/modules/payment/paypaldp.php from this:```
$taxAdjustmentForShipping = zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);

> to this:```
  $taxAdjustmentForShipping = zen_round(zen_calculate_tax($order->info['shipping_cost'], $shipping_tax), $currencies->currencies[$_SESSION['currency']]['decimal_places']);

This code changed fixed the problem. Thank you so much!

8 Sep 2010, 5:41 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done 1.3.9g] Website Payments Pro 10413 problem when calculating shipping taxes

Thanks for confirming.

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