Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spree-paypal-express fails with "Gateway Error: translation missing: en.the_totals_of_the_cart_item_amounts_do_not_match_order_amounts "

I'm using spree 1-2-stable, and I'm using spree-paypap-express 1-2-stable branch (tried with master too but failed again). When I try to checkout an order and select PayPal express as the payment method it fails with an error: "Gateway Error: translation missing: en.the_totals_of_the_cart_item_amounts_do_not_match_order_amounts". For some reason the order total does not match cart item amounts. I spent whole weekend on this and still have no idea why this is happening.

The issue only happens if I include shipping with price > 0 (it works if I set the shipping price to 0). As soon as I change the shipping price to be a value >0 or some % it breaks. I tried with both "Shipment including VAT" true and false - same thing.

Any ideas? Is this a bug in ppx or I'm I missing something?


UPDATE: 12/12/12

Here are the values I'm using to reproduce the problem: I am using VAT (icnluded in the price - 25%), the price of the item I'm trying to purchase is 265 EUR (the currecy does not matter), item quantity is 1 and the shipping is 15EUR (again vat is included in shipping price) this is flat order tax.

I get the error that order total does not match summed items amount. After some debugging i found that indeed those are different before sending to PayPal.

Why are is my total calculated wrong? I'm using the 1-2-stable branch of spree. My gemfile:


gem 'spree', :git => 'git://github.com/spree/spree.git', :branch => '1-2-stable'
#gem 'spree_usa_epay'
#gem 'spree_skrill'
gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-2-stable'
gem 'spree_paypal_express', :github => 'spree/spree_paypal_express', :branch => '1-2-stable'

My real question is how do I recalculate shipping and taxes just before the payment step (after the delivery step) and also how do I override the calculators so that they calculate correctly?

like image 901
Pavel Nikolov Avatar asked Dec 10 '12 11:12

Pavel Nikolov


Video Answer


1 Answers

After lots of debugging I found few bugs with the spree_paypal_express gem.

  1. if the tax is negative (VAT is included in the price and is refunded for non-EU orders) then PayPal rejects the order because of invalid tax
  2. it turned out that the shipping method in spree_paypal_express is hard-coded. It always picks up the first inserted in the DB instead of the one selected by the customer (this bug would appear if you have multiple shipping options)

those issues combined were causing checkout problems.

For the first issue i set opts[:tax] = 0 when the tax is negative and for the second implemented logic which gets the selected shipping method (with the corresponding price) instead of the hard-coded one.

like image 69
Pavel Nikolov Avatar answered Oct 04 '22 23:10

Pavel Nikolov