Jump to content

Paypal Payment Short - "Payment Error"


Recommended Posts

Just opened my on line store yesterday and had my first customer. She ordered several 'downloadable' images from my store then paid with paypal.

Her total order was $13.93 but somehow was only charged $13.92 so it left her order in a "Payment Error" status. I figured out how to "accept payment" and her order is OK now, but the question remains.

Why did her order process for a penny less? Could she have changed the amount? i thought when you click to pay, the amount due is automatically processed?

Share this post


Link to post
Share on other sites

Hi I have the same problem. Not sure but it seems that it has to do with the rounding of prices after adding the tax. Price with tax is xx.yyyyyy and not xx.yy so the extra amout is sent to PayPal. Any help in fixing this problem? :-)

Share this post


Link to post
Share on other sites

I haven't received a reply. Incidentally, I don't use the tax field - just the price of the products. It is really strange how that happened. Hopefully someone can tell us why this happened!

Share this post


Link to post
Share on other sites

having the same problem with my first order too cost of £23.33 and paypal account charged £23.32 "Payment Error" displayed in orders.

Any help greatfully received.

Share this post


Link to post
Share on other sites

This is actually a problem with fractions, prestashop uses 6 decimal internally, but when sending to paypal it uses only 2.

You can change prestashop to use 2 decimal points which should resolve this issue.

I'm not near a computer now so I can't look it up for you, if no one else will post it by the time I get to my computer, I'll look it up and let you know.

Share this post


Link to post
Share on other sites

This is indicative of a more fundamental problem which is the rounding used in price calculations. It can have consequences when looking at TAX and TAX calculations too. Different countries use different methods, although I'm not absolutely certain how PayPal handle it the following link shows that at least Google Checkout takes note of the different systems used in different countries:

http://code.google.com/apis/checkout/developer/Google_Checkout_HTML_API_Rounding_Policy.html

I would suggest that this is something that needs further thought rather than just messing about with code to get the numbers to work.

Paul

Share this post


Link to post
Share on other sites

How can I get prestashop to use 2 decimal internally instead of 6 decimal internally

As for tax issues, I will try to solv it later. Want to get my shop up and running first...

Thank ya all for your comments

:-)

Share this post


Link to post
Share on other sites

The problem though isn't necessarily the # of decimal places I don't think. It's the rounding policy used.

Firstly are you charging TAX in your store? In the UK your turnover has to be over a certain value before you are obliged to register (and you would be daft to register before you have to), it may be different in your country. If you're not charging TAX (and certainly for the UK it is illegal to do so if you aren't VAT registered) then your prices will likely have been entered as 2 decimal places anyway, and this problem will have nothing to do with Prestashop's internal precision.

I've seen many new UK store owners give themselves all sorts of problems when they were really just configuring their store incorrectly.


Paul

Share this post


Link to post
Share on other sites

Hi Paul,

ThanX for your attention :coolsmile:

I am in Denmark and I do charge VAT (tax) in my store. I enter the prices with two decimal places but after tax is calculated by PS i get a price with tax with 6 decimal places.

Most important for me is to get PayPal working properly and then I will handel "tha tax man"

Cheers

Dan

Share this post


Link to post
Share on other sites

Ok. I think the easiest solution would be for you to modify the paypal payment module to take account of the slight differences in the payment received versus the payment expected.

You could do this easily in the validation.php script within the PayPal module (when using the stardard, non-API version).

Basically in that script you'll see the following:

else
   $paypal->validateOrder($_POST['custom'], _PS_OS_PAYMENT_, floatval($_POST['mc_gross']), $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id']);



What we need to do is test the value of $_POST['mc_gross'] to check that it's within .01 of what we expect. If it is, then we use the amount we expect to get paid in place of it in the validateOrder function to trick Prestashop into thinking we did indeed receive the correct amount.

so you could try replacing the above code (in /modules/paypal/validation.php) with:

else {
   $cart = new Cart(intval($_POST['custom']));
   $currency = new Currency(intval($cart->id_currency));
   $expectedPayment = floatval(Tools::convertPrice(floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', '')), $currency));
   if (!paymentDiff($_POST['mc_gross'], $expectedPayment))
       $paypal->validateOrder($_POST['custom'], _PS_OS_PAYMENT_, $expectedPayment, $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id']);
   else
       $paypal->validateOrder($_POST['custom'], _PS_OS_PAYMENT_, floatval($_POST['mc_gross']), $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id']);
}

function paymentDiff($paypalAmt, $expectAmt)
{
   $diff = floatval($expectAmt - $paypalAmt);
   if ($diff<0) $diff = $diff * -1;

   if ($diff<0.02)
       return  TRUE;
   else
       return FALSE;
}



Please note that I haven't tested the above, so make sure you keep a backup to easily get back to where you started :cheese:

Paul

Share this post


Link to post
Share on other sites

Hi Paul,

Apriciate your help. I will backup and try your suggustion tomorrow ( i hope).

I guess I am not the only one with this problem since PS default (price with tax) is 6 decimal places. Wouldn't it be easier just to round all prices to 2 decimal places and send that to PayPal? (assuming that the tax man won't be too prticular)

:bug:

Share this post


Link to post
Share on other sites
Hi Paul,

Apriciate your help. I will backup and try your suggustion tomorrow ( i hope).

I guess I am not the only one with this problem since PS default (price with tax) is 6 decimal places. Wouldn't it be easier just to round all prices to 2 decimal places and send that to PayPal? (assuming that the tax man won't be too prticular)

:bug:


I have fixed this issue for a store using PS 1.1.0.5 in the past, try making the following change and let me know if it works for you (I don’t remember what the prices were set, so I can’t reproduce the error locally)

In /classes/Cart.php (around line # 570) you will see the following code

foreach ($products AS $product)
{
   $price = floatval(Product::getPriceStatic(intval($product['id_product']), $withTaxes, intval($product['id_product_attribute']), 6, NULL, false, true, $product['quantity']));
   $total_price = $price * intval($product['quantity']);
   $order_total += $total_price;
}



Comment out the $price = … line (add // in front of it) and add the new line below it.

foreach ($products AS $product)
{
   //$price = floatval(Product::getPriceStatic(intval($product['id_product']), $withTaxes, intval($product['id_product_attribute']), 6, NULL, false, true, $product['quantity']));
   $price = round(floatval(Product::getPriceStatic(intval($product['id_product']), $withTaxes, intval($product['id_product_attribute']), 6, NULL, false, true, $product['quantity'])),2);
   $total_price = $price * intval($product['quantity']);
   $order_total += $total_price;
}



This will round the price of each product (with taxes) to 2 decimal points and should resolve this issue.

If it doesn’t make a different just remove the new line, and un-comment the old one.

Let me know how it goes.

Share this post


Link to post
Share on other sites

Hi Tomerg,

Tried chaning the code as you suggested and it did not work. On PayPal page the price was right but the total price in the cart itself was grossly miscalculated.

Cheers :-)

Dan

Share this post


Link to post
Share on other sites

As I mentioned, it was made for V1.1

Does Paul C's solution work, if so that that's great, if not than try to catch me on a live chat on my site (should be there in about 1-2 hours) and I will try to help, I see quite a few people have the same issue and it should be solved with minimal core changes.


Hi Tomerg,

Tried chaning the code as you suggested and it did not work. On PayPal page the price was right but the total price in the cart itself was grossly miscalculated.

Cheers :-)

Dan

Share this post


Link to post
Share on other sites

Hi Paul

Sorry for not replying earlier, I was away. I tried the changes you suggested and it didn't go well. Order was not registered by PS no confirmation eMail to customers & shop owner BUT PayPal payment came through. I have a feeling that Tomerg3 approch to the problem has a better chance of working, that is limiting value in teh shop itself to 2 decimals.

As I undersatnd it, all items that have a value of cents only will yeald an error. I am surprised that this problem was not addressed in the forum, it is very basic.

In any case thatX very much for your help.

Regards

Dan

Share this post


Link to post
Share on other sites

Hi Tomer,

Unfortunatly Paul C's solution did not work well. As I undersatnd it, any articel that has a value of a few cents will creat problems with PayPal.

Hope you can adjust your solution for 1.1 to 1.2

TODA MEROSH


Dan

Share this post


Link to post
Share on other sites
Hi Tomer,

Unfortunatly Paul C's solution did not work well. As I undersatnd it, any articel that has a value of a few cents will creat problems with PayPal.

Hope you can adjust your solution for 1.1 to 1.2

TODA MEROSH


Dan


I need to be able to reproduce the error on my shop, can you visit my start and start a livezilla chat and help me set up a test case?

Share this post


Link to post
Share on other sites

Sadly I only had time to write that code off the top of my head, not test it, so chances are I've made a logic error somewhere, especially if the order is never created (i.e. even with an error state).

I'll try and have another go with it (with proper testing!) too and I'm sure between us we'll get something that will work!

Paul

Share this post


Link to post
Share on other sites

Hi Paul,

"Sadly I only had time to write that code...." Not so sad, as long as there is an effort going on I'm happy

:-)

Let me know if I can help testing or provide other information to fix this problem.

Bye

Dan

Share this post


Link to post
Share on other sites
  • 2 weeks later...

Well, this is just lovely. I have a load of orders in my store that are not processing correctly and my customers are getting annoyed. I have downloadable images for sale in my store. Most are for $1.99 and some are on sale for 25% off, making them $1.49. There are error messages all over in the store saying the customer either over paid or under paid.

There is no sales tax on these particular orders - it's just the initial cost of the photo.

I don't understand what's going on and I don't know how to fix it. I have a load of errors in the store and have no idea how to fix them.

Any help will be appreciated. Thanks.

Share this post


Link to post
Share on other sites

Hi Lizbit,

I have the same situation a dead-end.

My old shop PS1.1 is working but I have put a lot of work into the new one and can't get it running because of this PayPal error.


:-) let's hope...

Share this post


Link to post
Share on other sites

Are you sure my solution doesn't work, I posted it here http://www.prestashop.com/forums/viewthread/33467/help_configuration___use/cart_and_paypal_not_adding_up
and someone reported that it worked for him.

As I said, I would be able to debug it deeper if you can give me a test case and access to your server (I can do it on off peak hours).

But give my changes another shot....

Share this post


Link to post
Share on other sites
  • 2 months later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More