Author Topic: PayPal Order Detail Formatting  (Read 11394 times)

mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
PayPal Order Detail Formatting
« on: December 03, 2009, 20:17:18 pm »
In VM 1.1.4 the PayPal order detail is not quite correct when you are not including tax in prices and have shipping charges. Product price is incorrect.

Please view the following article that explains the potential problems and a fix.
Modified code is available for download.

http://www.exps.ca/solutions/virtuemart/61-virtuemart-paypal-fix.html

Also included is a reformatting of the cart prices display to support the same scenario.
Professional Joomla Development and Support
http://www.exps.ca

hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: PayPal Order Detail Formatting
« Reply #1 on: December 06, 2009, 23:44:06 pm »
You have almost fixed a problem that a lot of us have been having.
http://forum.virtuemart.net/index.php?topic=58724.0
http://forum.virtuemart.net/index.php?topic=63776.0
just type in tax discount paypal and see what happens.
Is there any chance with a few mods, this fix of yours could work for us?

mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
Re: PayPal Order Detail Formatting
« Reply #2 on: December 07, 2009, 12:05:37 pm »
I will take a look at this today.
Is there any specific scenario or is there just a general problem when coupons are used?
Professional Joomla Development and Support
http://www.exps.ca

hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: PayPal Order Detail Formatting
« Reply #3 on: December 07, 2009, 13:24:21 pm »
the scenario is a store that includes 10% tax on items and 10% tax on shipping.
I do NOT have "discount after shipping" ticked.
I want the information going to paypal to appear the same way it does in the customers order view eg: my customer sees this in the order view

4 x item    price (inc tax)  $20      
SUBTOTAL (INC TAX)             $80
coupon discount               -$8                                
Ship & handling fee (inc tax)  $10
TOTAL (INC TAX)                $82
----------------------------------
Total tax amt payable          $7.45

It looks like the information being sent to paypal is the same information that is shown in the backend view of customers orders.
(this is something I would also like to change so that it looks like the customer order view - but that is another story)

[attachment cleanup by admin]

mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
Re: PayPal Order Detail Formatting
« Reply #4 on: December 07, 2009, 14:37:21 pm »
Please clarify:
In Admin:
show "(including XX% tax) when applicable is checked
subtract payment discount before tax/shipping is unchecked

In Shopper Group
show Prices including tax is checked
Price Discount of default shopper group is 0.00

The order summary in VM is correct.

The order summary in Paypal is incorrect;
Price incl GST and subtotal should be 20.00
Extended line total should be $80.00
Shipping & Handling should be $10.00
Total should be $82.00

Discount (8.00) and GST (7.45) are correct
 
Professional Joomla Development and Support
http://www.exps.ca

hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: PayPal Order Detail Formatting
« Reply #5 on: December 07, 2009, 23:49:25 pm »
Yes yes yes.
The discount is applied to the goods, then shipping is added.
The order summary(customer order view) when looked at by the customer, is correct, (acount.order_details)
If i look at the order from the back end (backend order view) and try to print it for the customer (order.order_printdetails) the figures are messed up. These seem to be exactly the same figures sent to paypal, so they also do not add up.
I loved the layout you have done for paypal, I just wish the math worked for me (and if the discount code could also appear, that would be a bonus). This could be used by so many people.

mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
Re: PayPal Order Detail Formatting
« Reply #6 on: December 08, 2009, 01:09:40 am »
I've got the order detail calculating correctly now for coupons and in the format of my earlier fix. At the moment I'm looking into changing the PayPal code to use the _cart variable. Currently it uses _xclick, which similar to a buy now button. Unfortunately, it does not have a variables for discounts.

If I can switch PayPal handling to _cart we have a spots for discounts. Otherwise, we either have to apply the entire discount to the product (which it does now) or spread the discount over product, tax and shipping (ugly).

I'll keep you posted.
Professional Joomla Development and Support
http://www.exps.ca

hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: PayPal Order Detail Formatting
« Reply #7 on: December 08, 2009, 01:19:34 am »
Thank-you so much!!!
If you pull this off you will have many many happy virtuemart/paypal users.
I'm not sure if I need to tell you this or not.
I have 2 other payment methods, one is pay via phone with credit card and the other is pay via direct bank transfer.
Both of these have been set up in payment modules as Address only/cash on delivery.  I was just remembering back to some other forums where others with multiple payment methods were worried about any changes that might be made. It does not effect me though.

mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
Re: PayPal Order Detail Formatting
« Reply #8 on: December 11, 2009, 00:29:04 am »
HotelAtHome,

Have a look at this PayPal image. I believe it is what you need.

I have modified a few things  ;)so we can now have coupon discounts flow through to PayPal and all amounts (display in cart, order confirmation and PayPal) are in sync. Caveat: I discovered that VirtueMart does not support discounting on an order total (neither coupons or payment discounts). So the parameter to apply discounts BEFORE or AFTER does not do much. What does make a difference is whether prices include tax or not. Although, discounts are always applied on the subtotal of order lines. In your case I believe, with my mod's, you can set apply discounts Before and price including tax (same as attached image) to get what you need.

Let me know your thoughts

[attachment cleanup by admin]
Professional Joomla Development and Support
http://www.exps.ca

hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: PayPal Order Detail Formatting
« Reply #9 on: December 11, 2009, 02:24:19 am »
This looks really good.
Would I see the breakdown of the order at all, or just the invoice number and total of the invoice for goods ($80)
The tax should be $7.45 ( I know it is a cent but it would still differ from the invoice). I have a slight concern that the "prices shown include $7.46 tax, looks like just the items in the order include this tax amount, where in my case, $7.45 is the total tax payable. 
It would actually be better for me (and others using Aust G.S.T.) To have the tax figure (Total G.S.T payable) appear at the bottom of the page, like it appears in my customer order view jpg.
is there any way to have the words:
 "Item total" read "Subtotal inc G.S.T"
"Shipping and Handling inc G.S.T."
'TOTAL inc G.S.T."

I have seen on a few forums, the same problems I have been having but with other countries tax.
If there was a way of modifying the text so that people could put in the "tax code" that applies to them, that would be an absolute bonus.

I am worried about setting the "apply discounts before.."  When I do that, if the customer goes back into their account, the amounts are not the same that they saw in the check-out.
The amounts shown appear in the same configuration that was being sent to paypal (before your hack ;)) and as are currently being shown in the backend order view. The tax and discounts get all mixed up.

You mentioned that you now have the order detail calculating correctly. Do you mean the order view that I get in the back end or the customers order view?

 

mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
Re: PayPal Order Detail Formatting
« Reply #10 on: December 11, 2009, 15:37:37 pm »
In this version you will only see one line which is an aggregation of all order lines. This is a current limitation of the data in VM that is pulled into PayPal. The PayPal “_cart” option that I am using can handle order lines and will display them as you are suggesting. This is a logical next level for this fix – but requires more coding. I want to focus on getting the totals correct across VM and PayPal first.

The $7.46 is a rounding difference that I'll hunt down and fix.

I understand what you are asking for with the tax display and wanted to add this but was limited by the PayPal page itself. Currently it takes specific parameters for the display that limit what we can present. I am looking into overriding the detail display to display tax amounts in a better way. As it is now I've created a string for tax amounts that displays on the PayPal item line. I suppose it would be better to show product and shipping tax separately, which can be done (e.g. “Total includes $xx.xx GST (product) + $x.xx GST (s&h)”), the only limitations are length (127 characters) and formatting (can not force new line).

I see what you are saying about the back end detail. I'll fix that too....

At the end of the day all values will be in sync – cart , PayPal, confirmation and back end view, so setting discounts before will be ok.
Professional Joomla Development and Support
http://www.exps.ca

hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: PayPal Order Detail Formatting
« Reply #11 on: December 12, 2009, 03:46:27 am »
Brilliant!!
At the moment, I would just like the totals to add up with a bit more detail than I am getting by bundling the whole item/shipping/tax/coupon lot together.
As far as separating tax for shipping and tax for goods, that might be what other countries require, but for me just having the tax amount paid in total for the order is a bonus.
Thanks for looking at the backend detail, i was starting to think i might be the only one having this problem.
there was a fix for the figures done by hulagirl here:
http://forum.virtuemart.net/index.php?topic=54517.15
page 2 about halfway down. order.order_printdetails
I tried this on my site but the set out for me was a bit messy and a little confusing, for some reason the titles didnt line up. The figures added up though. Don't know if that helps you any.

I have also been following this post:
http://forum.virtuemart.net/index.php?topic=49535.0
It has some great ideas about the product names showing in paypal etc.

I am soooo greatful for the work you have done so far.
I know very little about coding, but have learnt an awful lot so far from these forums.  I will be sure to post you solution on any of the posts that I see, that could benefit from you work.


mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
Re: PayPal Order Detail Formatting
« Reply #12 on: December 15, 2009, 23:09:29 pm »
I finally have modified code that I believe fixes the issues.

Please go to my site an read the article regarding the solution I have developed for the discounts/coupons/paypal issues. The code for the solution is attached to the article.

http://www.exps.ca/solutions/virtuemart/62-virtuemart-114-discounts-fix.html

I consider this about 95% solved, as there are potential issues with login timing and session clearing that could make things behave strangely depending on your set up. However, it should be good enough to use as is.

Please test the code and let me know if it solves your issues and if there is anything missing.

regards,

Micah
Professional Joomla Development and Support
http://www.exps.ca

hotelathome

  • Jr. Member
  • **
  • Posts: 129
Re: PayPal Order Detail Formatting
« Reply #13 on: December 16, 2009, 02:14:04 am »
Sooo close
The paypal extra info is not including the tax paid on shipping so the final amount payable is incorrect.

I cannot use your ps_checkout as there were changes made to this for the GST set up.

I couldnt use the two basket files.  These correctly used the discount amount, but the discount did not show in the cart. i cant upload any more photo's to this post so I cannot show you.

The customer order view (account.order_details)did not include the tax on shipping and did not add this to the total tax payable, but the final amount payable was correct.

The back end order view is MUCH better, but like the customer order view, it did not include tax on shipping or add it to the total tax payable but the total amount payable is at least correct now.

It looks like I am back to just needing the paypal extra info and the order.order_printdetails files just needing a little bit more or a tweek and I will have it perfect.
I forgot to check if the paypal included the tax invoice number.

mwf

  • Jr. Member
  • **
  • Posts: 87
  • Ready to Code!
    • EXPS
Re: PayPal Order Detail Formatting
« Reply #14 on: December 16, 2009, 11:55:12 am »
If you do not use my modified ps_checkout it is not going to work.
All the files included in the fix MUST be used. If you have modification the the affected files you have to merge my changes with your modified code.

One more condition is that only tax "Based on Shipping Address" has been tested thus far, if you are using "Based on Vendor Address" or "EU Mode" there is a high probability that the calculation issues still exist. I can fix those cases as well (if there are issues) but that needs more time.
Professional Joomla Development and Support
http://www.exps.ca