Jump to content

Cart Rules / Voucher Problems with Paypal


bungl

Recommended Posts

I've created a few cart rules or voucher and found out today that when a voucher is used on checkout that Paypal will collect the money but doesn't properly send the customer back to prestashop to communicate the successful transaction with the back office.

 

As admin, I never see the order yet I took the clients money which is quite bad for business. I've tried various configuration of a voucher and cannot get it working properly.

 

Using prestashop 1.5.3.1 and Paypal module 1.3.4

 

Any help would be most appreciated!

Bungl. 

Link to comment
Share on other sites

This only occurs when a voucher is used?  Can you describe what happens after the payment is complete on Paypal?  Are you clicking the "return to store" link?  Is Paypal configured to automatically return the customer to your store?

  • Like 1
Link to comment
Share on other sites

Hi - Yes this only happens when a voucher is added at check out time. Once the client is sent to Paypal on checkout, it doesn't display the item(s) purchased (which is unusual) and once paid, the client is sent back to the prestashop checkout page with the items still in the cart. Prestashop doesn't record the transaction.

 

If the voucher is removed - everything works as it should including the purchased item gets displayed on the paypal page.

 

Yes, I've clicked on return to store link - should we wait for paypal to automatically send the clients back?

 

Thank you! :)

Edited by bungl (see edit history)
Link to comment
Share on other sites

Hi - I've tested this issue on another installation of prestashop v1.5.6.0. The same error occurs and I also noticed something new. This version has paypal express enabled and when a voucher is added to checkout, Paypal express check out gives the error below (see italic text). If I go back and remove the voucher from the checkout option total, Paypal express checkout works fine.

 

I'm starting to think it's something more on the prestashop end as it seems that the voucher is adding code that Paypal doesn't like.

 

Short Error Message: Transaction refused because of an invalid argument. See additional error messages for details.
Detailed Error Message: The totals of the cart item amounts do not match order amounts.
Error Code: 10413
Please contact our Customer service and mention this error code to get this issue resolved.
Link to comment
Share on other sites

Another thing I noticed this morning - when a voucher is applied, the checkout total and Paypal total are not the same. So again, I'm tending to think it's a prestashop issue. Sadly, the version of the template I'm using doesn't allow me to upgrade to 1.6.

 

Hopefully there is a fix I can apply to a prestashop file..

Link to comment
Share on other sites

I tested this on PS 1.5.3.1 using paypalusa 1.3.4.  I tested 2 use cases, and there are numerous issues with this. 

 

Note 1: Since all of these issues I documented below are with the paypalusa module, I would expect these issues to occur on all versions of Prestashop

 

Note 2: Getting these issues addressed...

1) If you are familiar with php coding, then you can attempt to fix these issues yourself

2) Feel free to submit bug reports and wait for Prestashop developers to fix it (don't hold your breath). 

3) Alternatively, you can wait for a community member to attempt to fix these and commit the changes to github and hope prestashop developers accept the changes and release an updated module. 

4) Alternatively hire a professional (me included) to fix the issues for you.

 

 

Use cases to test

1) Using paypal standard (clicking paypal as the payment method during checkout)

2) Using paypal express checkout (clicking the express checkout button on product page or cart summary page)

 

 

1) When testing paypal standard I observe the following from the code

1.1) When a voucher is NOT used, then the paypal module functions as you would expect.  It sends the cart total as a single amount, and it also itemizes each 'cost' as a paypal 'item'.  Each product is sent as an 'item', shipping is sent as an 'item' and tax is also sent separately.  The total amount should equal the sum of all the items.

 

1.2) When a voucher is used, then the paypal module sends a single item to Paypal, which is the total cart amount.  It also sends the cart amount as the 'amount'.  Now these amounts equal, however the module is still sending tax as a separate line item, and paypal is taking the sum of all items plus tax.  This is forcing paypal to double tax

 

 

2) When testing paypal express, I observe the following from the code

2.1) When a voucher is NOT used, then the paypal module functions as you would expect, which is similar to paypal standard above.

 

2.2) When a voucher is used, then the paypal module acts just like paypal standard, but also sends the voucher amount as a single item to Paypal, as a positive number.  The sum of line items do not equal the total amount and you get the error "Detailed Error Message: The totals of the cart item amounts do not match order amounts."

 

 

 

 

Issue 1: An order is not being created when you are returned to your store

 

This is likely that the IPN from paypal is not being received, or it is being received but processing fails.  There are numerous reasons for this, some of which are...

1.1) You are in maintenance mode and the IPN is being rejected because the paypal ip addresses are not 'white listed'

1.2)You are testing on localhost and the Paypal IPN cannot reach your localhost server

1.3) You are receiving the IPN, but the module/prestashop fails to process it.  This could be an address issue, for example the address used in Paypal does not have a phone number.  By default, Prestashop requires a phone number (home or mobile) for each address.  Since the phone number is missing, prestashop throws an exception and the order is never created.

 

The result is that you click "return to store", and since the IPN was never received/processed, the cart was never converted to an order.  The order confirmation controller redirects you to the order history page, because it is too stupid to do otherwise. 

 

Resolution:  Ideally the Paypal USA module should use the same URL for both the IPN and Return URLs.  This way if the IPN is not received, or if the IPN is received AFTER the user clicks return, the module would still process the order when the customer clicks "return"

 

 

Issue 2: Paypal standard with the use of a voucher causes Paypal to double the tax. 

 

Assuming the IPN was received and processed and the order is created, then I would assume the order status is going to be "payment error".  This is because the amount paid via Paypal includes tax twice, causing the total paid to be greater than the cart amount.  Prestashop will detect this, create the order and use "payment error". 

 

Obviously if you do not collect taxes, then this should not be an issue.

 

Resolution:  The module needs to be smart enough to not send taxes to Paypal twice.  If taxes are included in the total amount, then do not send taxes as a separate line item.  If taxes are not included in the amount, then send it as a separate line item.

 

 

Issue 3: Paypal express with the use of a voucher

 

Prestshop developers just royally screwed this one up.  Like with standard, the module sends products and shipping as separate line items.  But when a voucher is used, the module also sends the voucher as a line item (a positive number).  This causes Paypal to sum the cost of all line items, it winds up adding the voucher to the order amount, instead of subtracting it (really prestashop... come on...).  The module also does not subtract the voucher amount from the sum of all line items.  Since it causes the amounts to be different, you wind up getting an error message "Detailed Error Message: The totals of the cart item amounts do not match order amounts."

 

Resolution: There are a few ways to resolve this.

3.1) The express checkout could work similar to standard, where the module just sends a single line item to Paypal which is the total order amount.

 

3.2) The express checkout needs to be fixed to send a negative coupon amount to Paypal.  The module also has to subtract that amount from the sum of all line items.  This would likely be the easier of the 2 fixes.

Edited by bellini13 (see edit history)
  • Like 1
Link to comment
Share on other sites

Thank you for this!

I've tried to created a new user account in my shop which included a valid phone number and checked out an item with a voucher and I still get the same issue. Seems that every time a voucher is added that the information sent to Paypal on check fails as it reverts to simply listing the total and in turn, doesn't complete the transaction once the payment is taken. 

 

it's kind of a shame since I had planned to use vouchers to help promote my shop. 

Link to comment
Share on other sites

The issue is not with the phone number in your Prestashop customers account, it is with the customers paypal profile

 

1) By default, your customers paypal profile will never send you a phone number.

2) By default, Prestashop requires a phone number for every address (phone or phone_mobile)

3) By default, the paypal modules never saves a phone number when creating an address from the customers paypal profile

 

Those 3 statements conflict with each other, and that is why you have an issue. 

1) You either need to change Prestashop so that a phone number is NEVER required

2) You need to change your paypal seller account so that a phone number is always required.  This will force a customer to provide you with a phone number when paying with paypal.  This also means that you have to change the paypal module to accept the paypal phone number and save it with the address the module will create.

Link to comment
Share on other sites

It does not need to be enabled in your Paypal profile.  The module will send Paypal the information required for IPN to be returned to your store.

 

If you understood what I explained, then did you attempt one of those 2 options to correct the issue with the phone number?

Link to comment
Share on other sites

Hi - sorry, I missed that! I've disabled the phone number requirement in the "preference > customers" section. I'm currently going through my paypal seller account to make sure I have phone disabled. Thank you!

Link to comment
Share on other sites

By default, I had prestashop set to not ask for a phone number and my paypal seller account had the phone requirement off. I just enabled both "on" in prestashop and Paypal then created a new account including a phone number and tested a transaction using a voucher. Unfortunately, I get the same issue?

Link to comment
Share on other sites

I'm thinking that it has something to do with how prestashop passes the voucher values to paypal. In theory, the voucher should come up as an item listed on the paypal payment time. I'm guessing because there is a missing parameter or error that paypal reverts into safe mode and only displays the total. 

 

just thinking outloud..

Link to comment
Share on other sites

I explained in extreme detail how the module works with Paypal, and how it works differently when there is a voucher and no voucher.

 

 

It is now for you to determine how you would like it to work, and what changes would be necessary to make it work that way. 

 

Unfortunately, I get the same issue?

 

elaborate...  what is "the same issue"

Link to comment
Share on other sites

Hi Bellini13 - I'd like it to work where I don't need to collect the clients phone number and once a voucher in added at checkout that Paypal completes the transaction. As for same issue: everytime a client adds a voucher at check out then checkout - paypal simply lists the items totals, take their money and doesn't register the transaction in my store's back office. 

 

Because I thought you stated that the potential issue with with phone numbers, I tried disabling the phone requirement on both prestashop and paypal and even tested enabling the phone requirement on both prestashop and paypal. None of these two option has resolved thr problem with Paypal returning to the back office correctly with a voucher in the checkout basket.

Link to comment
Share on other sites

Phone number and vouchers are completely separate issues.  What you need to determine is if you have both issues, or just one of them.  From the information you have provided I cannot assess that.

 

The paypalusa module does not function the way you would like it to function with respect to vouchers, so you would need to recode the module to support what you would like to accomplish.

 

If you are knowledgable with PHP coding, then certainly make the attempt to change the module, but you will lose the ability to update the module, without having to re-apply your changes each time.  You could also look to hire a professional to make these changes, but the same issue with future updates will apply.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

I tested this on PS 1.5.3.1 using paypalusa 1.3.4.  I tested 2 use cases, and there are numerous issues with this. 

 

Note 1: Since all of these issues I documented below are with the paypalusa module, I would expect these issues to occur on all versions of Prestashop

 

Note 2: Getting these issues addressed...

1) If you are familiar with php coding, then you can attempt to fix these issues yourself

2) Feel free to submit bug reports and wait for Prestashop developers to fix it (don't hold your breath). 

3) Alternatively, you can wait for a community member to attempt to fix these and commit the changes to github and hope prestashop developers accept the changes and release an updated module. 

4) Alternatively hire a professional (me included) to fix the issues for you.

 

 

Use cases to test

1) Using paypal standard (clicking paypal as the payment method during checkout)

2) Using paypal express checkout (clicking the express checkout button on product page or cart summary page)

 

 

1) When testing paypal standard I observe the following from the code

1.1) When a voucher is NOT used, then the paypal module functions as you would expect.  It sends the cart total as a single amount, and it also itemizes each 'cost' as a paypal 'item'.  Each product is sent as an 'item', shipping is sent as an 'item' and tax is also sent separately.  The total amount should equal the sum of all the items.

 

1.2) When a voucher is used, then the paypal module sends a single item to Paypal, which is the total cart amount.  It also sends the cart amount as the 'amount'.  Now these amounts equal, however the module is still sending tax as a separate line item, and paypal is taking the sum of all items plus tax.  This is forcing paypal to double tax

 

 

2) When testing paypal express, I observe the following from the code

2.1) When a voucher is NOT used, then the paypal module functions as you would expect, which is similar to paypal standard above.

 

2.2) When a voucher is used, then the paypal module acts just like paypal standard, but also sends the voucher amount as a single item to Paypal, as a positive number.  The sum of line items do not equal the total amount and you get the error "Detailed Error Message: The totals of the cart item amounts do not match order amounts."

 

 

 

 

Issue 1: An order is not being created when you are returned to your store

 

This is likely that the IPN from paypal is not being received, or it is being received but processing fails.  There are numerous reasons for this, some of which are...

1.1) You are in maintenance mode and the IPN is being rejected because the paypal ip addresses are not 'white listed'

1.2)You are testing on localhost and the Paypal IPN cannot reach your localhost server

1.3) You are receiving the IPN, but the module/prestashop fails to process it.  This could be an address issue, for example the address used in Paypal does not have a phone number.  By default, Prestashop requires a phone number (home or mobile) for each address.  Since the phone number is missing, prestashop throws an exception and the order is never created.

 

The result is that you click "return to store", and since the IPN was never received/processed, the cart was never converted to an order.  The order confirmation controller redirects you to the order history page, because it is too stupid to do otherwise. 

 

Resolution:  Ideally the Paypal USA module should use the same URL for both the IPN and Return URLs.  This way if the IPN is not received, or if the IPN is received AFTER the user clicks return, the module would still process the order when the customer clicks "return"

 

 

Issue 2: Paypal standard with the use of a voucher causes Paypal to double the tax. 

 

Assuming the IPN was received and processed and the order is created, then I would assume the order status is going to be "payment error".  This is because the amount paid via Paypal includes tax twice, causing the total paid to be greater than the cart amount.  Prestashop will detect this, create the order and use "payment error". 

 

Obviously if you do not collect taxes, then this should not be an issue.

 

Resolution:  The module needs to be smart enough to not send taxes to Paypal twice.  If taxes are included in the total amount, then do not send taxes as a separate line item.  If taxes are not included in the amount, then send it as a separate line item.

 

 

Issue 3: Paypal express with the use of a voucher

 

Prestshop developers just royally screwed this one up.  Like with standard, the module sends products and shipping as separate line items.  But when a voucher is used, the module also sends the voucher as a line item (a positive number).  This causes Paypal to sum the cost of all line items, it winds up adding the voucher to the order amount, instead of subtracting it (really prestashop... come on...).  The module also does not subtract the voucher amount from the sum of all line items.  Since it causes the amounts to be different, you wind up getting an error message "Detailed Error Message: The totals of the cart item amounts do not match order amounts."

 

Resolution: There are a few ways to resolve this.

3.1) The express checkout could work similar to standard, where the module just sends a single line item to Paypal which is the total order amount.

 

3.2) The express checkout needs to be fixed to send a negative coupon amount to Paypal.  The module also has to subtract that amount from the sum of all line items.  This would likely be the easier of the 2 fixes.

Where might I find the lines of code that need to be altered to make it send a negative coupon amount to paypal for express checkout?

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

So, YEARS later, there's STILL no solution to this problem with the Paypal USA module???  I too have the same problem of not being able to use a voucher with PP Standard or Express - it won't send the customer to Paypal and only gives them an error message.

 

I AM LOSING BUSINESS AND MONEY!

 

I am SO ready to completely ditch Prestashop.

 

Has anyone resolved this issue yet?  I even paid more money to Paypal for Advanced Payments and there's MORE issues with the module there!  This is so completely ridiculous!

Link to comment
Share on other sites

  • 1 month later...

i'm facing a worst scenario.

WIth paypal module activated (only paypal module for payment installed) the voucher field where customer can insert a promotional voucher code is not appearing at all!

and i find out that the paypal.js script remove the area from the screen plus the trashcan icon to remove items from cart:

/* 1.5 One page checkout*/
var qty = $('.qty-field.cart_quantity_input').val();
$('.qty-field.cart_quantity_input').after(qty);
$('.qty-field.cart_quantity_input, .cart_total_bar, .cart_quantity_delete, #cart_voucher *').remove();

I've opened a ticket with paypal module developer and after 1 week i've no answer!

Link to comment
Share on other sites

because the original module could not properly handle sending discounts to Paypal properly.  So their solution was to remove the ability, wasn't that so smart of them?  /sarcasm

 

have you tried to remove the javascript and see if the module will function properly when a discount is added to the cart?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...