-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PayPal failed. The totals of the cart item amounts do not match order amounts. #129
Comments
Ok, on further inspection, choosing not to 'include Tax In Prices' means I can get through the process, but I'd really not like to be displaying ex VAT pricing and adding it on at checkout. |
I am experiencing this exact issue, where unchecking 'INCLUDED IN PRICE' in Very grateful for any help on this :) |
same here ... I'm using the 2-3 stable branch and for a quick fix I have juste commented this section in paypal_controller :
It's working because I don't have other taxes and they are included in product price but it's not a good solution. |
These are the changes I made to have inclusive VAT work on 2-2-stable. Ignore my reference to |
@Hates - Ah wow. Thank you. This is my first Spree project, so please excuse the stupidity that's about to come from my keyboard. Could I theoretically take a copy of paypal_controller.rb and drop it into /app/spree/controllers/ and it will override the gem's copy? I expect it's not best practice but deadlines are looming and better launched than not! |
...But I should really fork the Gem based on the branch I'm using and bundle from my fork... |
@peterfealey Putting something like this in |
Thank you so much @Hates |
anyone figured out what actually happened here and the proper way to fix this? |
maybe this commit? 057973b /c @gmacdougall |
AFAIK this gem has never worked when tax is included in the price. |
uhm, looks like this was fixed month ago on d446645 but this never reached 2-3-stable and master. |
I'm running the 2-2-stable branch with that change and was still running into problems with inclusive tax rates. It's possible that the problem I'm having is un-related. My issue occurs when shipping to a tax zone where the inclusive rate should not be applied. |
So I'm not sure if this has been fixed and explained somewhere else but the following worked for me. For those of you needing to fix it yourself you can modify the paypal controller and make sure that the tax adjustments include the line item taxes. The issue seemed to be that the line item tax adjustments were being added as order items (this is for 2.3-stable). So for line 6 I changed it to: tax_adjustments = order.adjustments.tax.additional + order.line_item_adjustments.tax.additional The reason there is this issue is because there are two places where the cart item totals are added up: line 137 and line 148. Line 137 uses current_order.total - shipment_sum - current_order.additional_tax_total to calculate the total, and line 148 sums up the items in the item array, and the tax for the line items is included as an item. I hope this helps! |
I just ran into this, curious, why was it closed by tests? |
+1 Also experiencing this bug. @alepore can this be re-opened? I'm getting this message when a line item has a promotion adjustment, shipping to a location without taxes. |
@mleglise on which version? are you up2date? |
@alepore I was on 69fd18c although I later figured out my issue was caused by tax adjustments from https://github.com/railsdog/spree_avatax_certified |
@alepore I'm running latest |
Thanks, the problem here is always the same : PayPal checks if the sum of all items and adjustments matches the total amount. So we must be very careful to include (or exclude) all kinds of spree adjustments and taxes |
hi mleglise, After line 22, I also added (you may don't need it) Now it works. |
@albertliu-nwb found the right place. I dug deeper and discovered that this is because of a change in Spree::Core 3.0. PR submitted: spree/spree#6695 Theoretically, that PR should solve this issue, with no changes needed in the PayPal gem. |
I have applied the PR to spree branch 3-0-stable and I still experience the issue. Changing line 8 of paypal_controller.rb as @albertliu-nwb suggested solved it. In my case the error was caused beacuse an order adjustment was not included and not beacuse of a tax adjustment. |
uhm, this spree |
Hi there, i was getting the same error and fixed it with this gist mentioned above (https://gist.github.com/Hates/fb67e791c5d239efdbff). Now this works for most of my orders but we have a special discounting system. if someone places an order in our store he must enter a unique ID, some of them are linked to a discount. so for every order including a discount I am still getting this error. I guess that happens because the discount is applied to the whole order and not to the single items. as I am not the developer of that discounting system and my rails knowledge is very limited: do you know a quick way to disable this "security mechanism" in this paypal plugin here? Which line of code is responsible for that? Hope you understand my problem! |
@mmintel It should be added as an adjustment, which AFAIK can be a negative value. You can see where it builds them up on line 11 of the gist you linked to. Apart from that I don't think it can be disabled as all the values need to add up otherwise Paypal reject the order. |
@Hates as an adjustments works but the promotions won't be collected in the additional_adjustments = order.all_adjustments.additional
tax_adjustments = additional_adjustments.tax
shipping_adjustments = additional_adjustments.shipping
promotion_adjustments = order.all_adjustments.promotion
(additional_adjustments.eligible + promotion_adjustments.eligible).each do |adjustment|
next if (shipping_adjustments + tax_adjustments).include?(adjustment)
items << {
:Name => adjustment.label,
:Quantity => 1,
:Amount => {
:currencyID => order.currency,
:value => adjustment.amount
}
}
end Hope this helps Note: I had to add the tax adjustments since paypal was capturing the taxonomies apart from the items |
Having a problem integrating this. Gemfile attached, if that helps.
At checkout the above message prevents even getting to the PayPal form.
The text was updated successfully, but these errors were encountered: