The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

totals of the cart item amounts do not match order amounts

oskayoskay Member
in General edited April 2011
Just had a customer come up against an error: "Error: There was an error processing your payment: (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. "

This is a paypal error code, which gives further information "If you get this error, be sure the total of the payment detail item parameters, such as ItemTotal, HandlingTotal, TaxTotal, and so forth add up to the the order total."

This seems to me like it must be a bug either at foxycart or paypal, not with our store configuration. That is, either we're sending the wrong item amounts to paypal, or they aren't adding correctly. Thoughts?
Comments
  • Some additional possibly pertinent information: this order has one item with a quantity discount, one normal priced item, sales tax and free shipping. If it would be helpful to send you the specific products, let me know.
  • webmovementllcwebmovementllc Member, Integration Developer, FoxyPress
    Hi all, I'm having this same problem and plan on debugging it a bit tonight, will provide some details if I do find an answer.
    Per this thread: http://forum.foxycart.com/comments.php?DiscussionID=4537&page=1#Item_4
    Adam
  • lukeluke FoxyCart Team
    I've been looking into this issue a bit and I'm not quite sure what we can do to fix it. It looks like the line item tax amounts are rounding up in such a way that if you add them all up, you get $0.04 more than the real tax order total. Normally we fix these rounding challenges by include another line item to offset the difference. But in this case we'd have to send a line item with a negative tax total and when we try to do that we get this error:
    Error: There was an error processing your payment: (10001 Internal Error) Internal Error

    So... yeah. We're kinda stuck here. We'll keep exploring solutions, but it's not a simple one since PayPal expects the line items to have tax amounts associated with them (rounded to the nearest penny) but the true tax amount is done on the total.
  • oskayoskay Member
    Damn.

    So... PayPal wants us to overcharge for sales tax? Maybe we can offer two prices, one for regular checkout, one for paypal checkout? :P

    Is this something that you can ask PayPal about?
  • lukeluke FoxyCart Team
    Hey oskay. We're still trying to figure out the correct way to handle this. I thought we were able to send a negative line item to offset the rounding issue it but in this case the line item amount is 0 and the tax amount is negative. That seems to be blowing up PayPal. I'll look through our previous support tickets with PayPal and see if they already addressed this and if not, open another ticket. We've also tried reaching out to a third party tax service we plan to integrate with in the future to see how they recommend handling a situation like this. We'll keep you posted. Though we may not have a solution immediately, it's definitely at the top of our list and we're actively pursuing options.
  • Luke, thanks for the followup. I went through my error logs, and found half a dozen customers since January that have been affected by this. These are typically orders of a few hundred dollars, and most of the customers had to contact me for a workaround. Did something change in January?
  • lukeluke FoxyCart Team
    Hey Lenore. We've had support for PayPal line item details for quite some time, back to version 051. We've also made various improvements to catch this type of error since then but it looks like this is a new one we haven't addressed yet. I've submitted a support ticket to PayPal's merchant services technical support to see what suggestion they have for this.
  • lukeluke FoxyCart Team
    For further clarification, do you happen to know if this error is only coming up when customers click the pay with PayPal button on the cart? Looking through the system some more, it looks like we let these rounding errors go through because we allow for SuccessWithWarning messages. But... that only happens when the funds are captured. If it's blowing up before then, is it possible it's only blowing up on the cart -> paypal workflow?

    I've still got this on my list to do some more testing and tweaking. I got stuck down a rabbit trail for a while with the Internal Error message but it turns out the PayPal sandbox rejects things completely if the same test card number has been used too many times. Hurray for me wasting a day or two in confusion.
  • The ones that successfully made the purchase (after trying again and again and getting the error repeatedly) did so NOT through their Paypal account. A couple that really wanted to use Paypal had me send them an invoice, so it does seem to be tied to using Paypal as the payment method.

    I've seen a couple more over the last couple of days, which concerns me, as the rounding errors only seem to affect reasonably large orders.
  • lukeluke FoxyCart Team
    @Lenore: Thank you for the update. One last thing, do you know if they clicked on the Paypal button in the cart or the one on the checkout page? It's possible the Paypal payment option on the checkout page may work. We're still looking into this to figure out what (if anything) we can do on our side to fix this problem.
  • It had to have been on the checkout page, since we took the button out of the cart (it was ugly).
  • lukeluke FoxyCart Team
    Hmm... that confuses me even more, but thank you. That's valuable information.
  • oskayoskay Member
    This continues to be an issue for us-- another order refused today with the same error. From what we can see, this is going to continue to affect any in-state (taxable) orders with more than one line item.

    It seems like there should be some way to do this. Is there a method that other carts integrating with Paypal use?

    One possible workaround: Do not include per-line-item sales tax with each item, but include sales tax as a separate line item.

    Another possible workaround: pass only the order total to paypal, not the full line-item description. I'd rather that the order goes through and is not very descriptive, than that it is very descriptive but doesn't actually work.
  • lukeluke FoxyCart Team
    Hey @oskay and @Lenore.

    Sorry for the delay on this one... it was really driving me crazy. After a lot of back and forth with PayPal's support, I wasn't any further along than I was previously. The "Internal Error" I was getting earlier threw me off the trail I was originally on that did actually fix the problem. The issue was that I couldn't reproduce it myself until Lenore posted about using Paypal Express specifically and only on the checkout page. That's the first time I was able to reproduce the issue. It only appears to happen with PayPal Express (PayPal Pro is fine) and if you use the PayPal Express button on the cart, it works fine. It only errors when going directly to the checkout page and using the PayPal payment option from there.

    The fix involves adding a line item of a negative tax to make up for the rounding issue. I've been testing it and feel like it's a pretty specific change to this issue so we went ahead and rolled it out for both 070 and 071. Please let us know if you run into any other issues with this. We're really hoping this fixes it.
  • LenoreLenore Member
    Thanks! We'll keep watch for any more errors of that type.
  • oskayoskay Member
    Had that error again today. :(
  • oskayoskay Member
    While the present solution seems to (mostly) work, I have to say that I'd find it fishy if an order that I was placing showed a line item called "rounding error" that appeared to add a few cents to my order total. It seems like there must be a better way. One way would be to do exactly what paypal is doing, and to actually calculate sales tax per line item.
  • lukeluke FoxyCart Team
    To be clear, are you actually seeing a PayPal error? I see the rounding difference as well, but I have not been able to get PayPal to throw an error because it instead has a line item subtracting a single penny to make up for the rounding challenge. This is an issue we've gone back and forth on for a long time in that many of our customers charge for products to the fraction of a penny (much like we buy gas). The individual amount per item isn't what's important, it's the order total that matters. The problem here is that PayPal wants rounded-to-the-penny product line item amounts, so we have to round them which causes the order total to be incorrect based on the rounded line item amounts.

    I haven't been able to reproduce the 10413 error you mentioned. Can you walk me through the exact steps? I tried going to PayPal directly from the cart, from the checkout (via PayPal Pro) and from the checkout via Express.
  • oskayoskay Member
    Yes, we saw the paypal error again. It's in our error log. (Have I been able to reproduce it? No, absolutely not-- I haven't tried. We don't run live orders as tests unless absolutely necessary.)

    The customer that had that error is the same one who reported the rounding error difference between the cart and checkout page, suspecting that it was the cause of the problem. Are they related? I don't know. But I do know that it's incorrect behavior. And since it is quite incorrect, it is plausible that it is the cause of the paypal error, which only indicates that the order totals don't match up to the line items.

    And, to be clear, this is NOT just a paypal issue. The specific example that I reported (via whisper) is a difference between the order subtotal shown in the foxycart modal cart and the order subtotal shown on the foxycart checkout page. This is incorrect behavior, from any standpoint, visible well before paypal is involved.
  • lukeluke FoxyCart Team
    Thanks for posting back, oskay. We've posted here in the forums about this issue a few times but we don't have any obvious answers yet on how to fix things. Here's the issue as I understand it:

    If there is a line item discount or a category discount involved, an individual product could be priced at something like $0.10648 (as a random example). That gets displayed on the cart as "$0.11 each". When you add 100 to your cart, the total is not $11.00 but instead $10.65 (as it should be). The confusion here relates to the display of the "price each". Some of the options we've discussed is to display more precision instead of rounding to the nearest penny. In this case it would display as "$0.106 each", which (we hope) should eliminate some confusion. The issue is further confused by the fact that PayPal want's fully rounded line item amounts. So we can't send them 0.106, it has to be .11. That creates a problem for us because now the correct order total of 10.65 doesn't match the sum of the line items. We've asked PayPal tech support about this numerous times and they don't have a solid answer either (other than always rounding every product to a whole penny). The fix we came up with is to display the rounding adjustment that would subtract (in this case) the 35 cents of overpayment out as another line item.

    Do you have any suggestions on how we can improve this? Should we always force each individual line item to a whole penny? For stores that are selling large quantities of small priced items, this isn't a good option because they will greatly overcharge their customers (being sued for false advertising would be bad also). So what does that leave us? We could adjust the "price each" display in the cart as mentioned, but that only fixes part of the confusion and we still have the funky "rounding adjustment" line item in PayPal.

    Either way, with the line item adjustment, there should have been no 10413 error. We'll keep tinkering with until we can reproduce the error and solve it. We really do want to fix this issue from every angle and ensure it makes sense to the customer, but I'm just not aware of the correct solution at this point.
  • oskayoskay Member
    edited June 2011
    I think that you have (twice now) missed the issue that I'm trying to point out. YES, I understand that paypal wants rounded line items, which can lead to a cart-total rounding issue. That is NOT the issue that I am trying (for the third time now) to bring to your attention.

    1) Stop bringing up paypal. This isn't their fault.

    2) Look at this screenshot, same thing that I was trying to point out via whisper:

    fccart.png

    3) Notice that there is inconsistent rounding behavior on Foxycart's part. Is the total $8.08, or $8.07? This issue is completely independent of which payment processor is used.

    4) My assertion: You should fix this inconsistency. It's very sloppy to charge the incorrect amount. If you show two different prices for the same thing-- even on the same page --you can be sure that (at least) one of them is not correct.

    5) My wild guess with no data to back it up: The fact that our shopping cart can't decide on what the order total is-- due to inconsistent rounding algorithms --could possibly be related to our recurring 10413 error.
  • oskayoskay Member
    edited June 2011
    As for the paypal line-item rounding issue, my sugggestion is this (as I stated before):
    Pass only the order total to paypal, not the full line-item description. I'd rather that the order goes through and is not very descriptive, than that it is very descriptive but doesn't actually work.

    For many online stores where we make purchases by PayPal, the only "cart" information passed to Paypal about our order is the (1) the invoice number and (2) the order total, all up. This works, it's easy, it's self consistent, and it's used commonly. It's how everyone else deals with this, so far as I know.

    I'd certainly appreciate it if FoxyCart (1) used this behavior any time that a positive rounding correction were added to the cart-- that's ugly -- or (2) gave an option in the admin panel to select this behavior for all orders that go through paypal.
  • lukeluke FoxyCart Team
    edited June 2011
    @oskay Thank you for posting the screenshot, I think we're now on the same page. It's confusing because we are talking about multiple things here.

    I'll address the "$8.08" line item sub total first. It seems that display has something to do with the interaction between the objects and the database. For example, if you load up the cart after you add the items to the cart, you'll see $8.07 as expected. That's also what is displayed on the checkout page. Somewhere along the line of when it is saved to the database and pulled out again, things are adjusted and on initial page load from the add action, the total is incorrectly shown as $8.08. I say "incorrectly" because that leads me to the underlying issue I was trying to address.

    The product isn't actually $4.04 each. It's actually $4.0375. Even if we get the subtotal displaying correctly, how do you suggest we handle the "each" display? Should we extend it to one extra decimal and show "$4.038 each" which (hopefully) would explain to the customer why two of them equal $4.07? That's the primary issue I was focusing on and concerned with and I missed the more obvious problem with the line item total being one penny more than the order total.

    Now, on to the separate discussion of PayPal. We've added the line item details specifically at the (numerous) requests of our users. Many of our users are actually frustrated with how little detail is there currently because for PayPal Website Payments Pro we can't also pass the product option details (this is related to a bug in PayPal Pro which ignores the "Description" XML node, despite it being in earlier versions of the docs, but that's a separate issue, one mentioned on their forums). Many of our users want and need the line item details because their back-end systems are configured to integrate with PayPal, not with FoxyCart. that being said, I like your suggestion of being able to optionally configure not including the line items, but that seems (to me anyway) to be hack to get around the inability of PayPal to be flexible with line item totals as they compare to the order total. Many of the gateways we integrate with include line item details but PayPal is one of maybe two that actually tries to validate against the line item totals. The other gateways don't do that so there isn't a problem. As for the discussion of whether they should be there or not, it is the recommended integration (we're going through PayPal certification now) and it does have an effect on the cart abandonment rate (based on what I've read). When things are fully broken, cart abandonment doesn't mean a thing, though. I've asked PayPal's support about this issue numerous times and they haven't been very helpful as to the "correct" way to deal with it, other than adding a rounding line item hack as we have or ensure all your products and tax amounts per line item round to a full penny.

    What do you think about taking the approach that every product within FoxyCart has to have a full penny value? That way we would round up the $4.0375 to $4.04 and call it good. Is that level of rounding something you would like to see configurable in the store or would that just be more confusing for the customer? With enough items in the cart, the 15% discount would no longer be 15%... so that's probably a bad way to go. Also, if you're rounding down and something like $4.0325 becomes $4.03, now you as the merchant are losing a quarter penny on each item. We've actually had stores selling items in the thousands of quantities per order where this becomes a real problem.

    Maybe another option would be to display all the line item details unless there is going to be a per line item issue rolling them all up to the order total? Or maybe it's just better to have them all on or all off for consistency sake as you said. Either way, it's frustrating for us because the other gateways don't have a problem with orders that are made up of items that don't (individually) round up to the nearest penny. If you, as the merchant, prefer to not have line item details then it makes sense to me that you should be able to configure FoxyCart accordingly. We'll keep that in mind for a future release.
  • lukeluke FoxyCart Team
    Hey oksay. We're still testing some fixes for this related to rounding and precision differences between the code and the db and it looks like we'll be keeping those changes in an 072 release. We'll probably be making a small database modification sometime this week that may help for all versions as well. As for turning on or off the PayPal line item details, that will probably be a larger change that we'll have to think through for a future version.
Sign In or Register to comment.