codegrunt Posted December 17, 2010 Share Posted December 17, 2010 Howdy. I was not sure which forum was best for this question so I am going to try here. Mods, please move this if I picked the wrong spot.I have encountered an issue with Prestashaop 1.3.1 which is affecting PayPal (and presumably any other processor). The issue is that orders are being marked as status "payment error" because "$cart->getOrderTotal()" is not handling taxes the same way during the validation step.In "modules/paypal/redirect.php" the order total cost is set like this:'total' => floatval($cart->getOrderTotal(true, 3)),In "classes/PaymentModule.php" the following two values are used:$order->total_paid_real = $amountPaid;$order->total_paid = floatval(Tools::ps_round(floatval($cart->getOrderTotal(true, 3)), 2));So theoretically, both should return the same amount. Now in our case, some mods have been made to support Canadian taxes better. Prestashop currently does not apply provincial based taxes to carriers so a mod was done to Cart::getOrderShippingCost() to default to the tax associated with $cart->id_address_delivery if none was explicitly set for the carrier. // Select carrier tax $provincialTax=floatval(Tax::getApplicableTax(0,0)); if ($useTax AND ($carrier->id_tax || $provincialTax>0)) { if($carrier->id_tax) { if (!isset(self::$_taxes[$carrier->id_tax])) { self::$_taxes[$carrier->id_tax] = new Tax(intval($carrier->id_tax)); } $tax = self::$_taxes[$carrier->id_tax]; if (Validate::isLoadedObject($tax) AND Tax::zoneHasTax(intval($tax->id), intval($id_zone)) AND !Tax::excludeTaxeOption()) $carrierTax = $tax->rate; } else { $carrierTax=$provincialTax; } } This works fine on the way out, even when viewing carts under the admin customers menu. On the way back however, neither tax is being applied and thus the total mismatch.I am hoping someone might have an idea as to what might be different about the $cart state during validation versus the original order process? Unfortunately, Prestashop uses globals in a number of spots which can make it difficult to immediately tell whether something higher up in the code is important further down. It feels like "$cart->id_address_delivery" is not behaving as expected during the validation stage but so far I cannot see why this would occur in the code. Presumably the problem happens in Tax::getApplicableTax() but again, it is not clear yet why the state is different.Any help or pointers much appreciated.Cheers Link to comment Share on other sites More sharing options...
salvadom Posted July 21, 2014 Share Posted July 21, 2014 (edited) I had a similar issue and I want to see if this is the same problem your having. Here is what is assumed: You have shipping carriers with tax on. You go to checkout using paypal but after completing the order it fails. Can you please check some values for me? Can you check the shipping cost, tax, and total before going to paypal (so check the values on the prestashop checkout page). Then check the same values on the paypal page once checking out with paypal. I noticed on our system that paypal was receiving the shipping cost with tax included, whereas prestashop takes the tax off and includes that in the tax field. So our shipping tax was being re-applied to the total order on paypals side. To fix this, you can simply edit the paypal module. Do this by going to: modules > paypalusa > views > templates > hook > standard.tpl Line 48 should look something like {assign var="paypal_usa_total_shipping" value=$cart->getOrderTotal(true, Cart::ONLY_SHIPPING)} Change the flag to false. This will stop tax from being added to your shipping. Your new code should look like {assign var="paypal_usa_total_shipping" value=$cart->getOrderTotal(false, Cart::ONLY_SHIPPING)} Hope this helps others! EDIT: This was for Prestashop 1.6.0.6. Edited July 22, 2014 by salvadom (see edit history) Link to comment Share on other sites More sharing options...
Blessy_Preferred Posted June 1, 2017 Share Posted June 1, 2017 This works for me! Using PS 1.6.1.11. Paypal module version 1.3.9. Thank you so much! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now