Paypal standard fix - allows showing of items in cart

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
By the way... where is this discount coming from? Is it a gift certificate or reward points?

Because the "discount" that I have in there to send to Paypal was just supposed to be a way for customers to be able to pay for stuff with Gift Certificates or reward points...

And... how can I duplicate this?
13 years ago
Barry,

I created a discount from the admin/promotions/discounts and add new discount. Then, I did a test purchase and went through checkout. In the checkout page, I put in the discount code and then apply discount. After going through checkout and passing to paypal sandbox, the difference will be seen (just remember to copy down the amounts on the nopcommerce side and compare it to the paypal side).

Thanks for checking into it.
13 years ago
bfranklin825 wrote:

Another fix I would like (which I'll probably have to do myself) is that when you hit "confirm" (the last button before being sent to Paypal) the order is automatically placed with nopCommerce and an email is sent to the admin and the customer about the order that isn't even finished yet.

What happens if the customer closes out the browser before completing the transaction with Paypal? Now you have an order that is not paid for but has been created and emails have been sent out... a mess! I would like to see the order creation in nopCommerce happen after the customer is sent back to the site on the return link or after the payment has been confirmed with Paypal - I'll have to look into the best way.

Also... if the customer changes his/her mind on something and hits the "cancel and return" link on Paypal then they are taken back to the main page of the site and their cart is empty! What if they wanted to change their order? Now they have to do the order ALL OVER AGAIN - lost sale! I'd like to see the "cancel and return" link on Paypal return the user to their cart which still contains their not-yet-processed order. I'll have to look into that as well...

Hope this code helps some people... if you find it doesn't support something that it should, or is doesn't work like it should then please let me know (post here) and I'll see what I can do.
B


Hi b !! thank you for this code ;)
I have faced the same problem that happens when the customer changes his mind and return back on the store. Shopping Cart is empty because (as you mentioned) the order are placed and shopping cart is cleared just before PostPayment call. I would like to know why it's not done after success payment ?? and if some one has solution to fix this ??
13 years ago
krimos wrote:
and if some one has solution to fix this ??


I'm going to look into this when I get the chance... I'm just swamped right now.
13 years ago
ttun76 wrote:
Barry,

I created a discount from the admin/promotions/discounts and add new discount. Then, I did a test purchase and went through checkout. In the checkout page, I put in the discount code and then apply discount. After going through checkout and passing to paypal sandbox, the difference will be seen (just remember to copy down the amounts on the nopcommerce side and compare it to the paypal side).

Thanks for checking into it.


This doesn't sound like a reward point/gift cert issue... I'll have to fix this. Possibly this weekend...
13 years ago
ttun76 wrote:
Barry,

I created a discount from the admin/promotions/discounts and add new discount. Then, I did a test purchase and went through checkout. In the checkout page, I put in the discount code and then apply discount. After going through checkout and passing to paypal sandbox, the difference will be seen (just remember to copy down the amounts on the nopcommerce side and compare it to the paypal side).

Thanks for checking into it.


Damn!!!

I fixed it... sort of... there STILL could be a one cent difference! I have to figure out why... then it will be truly fixed. There is just a slight difference in rounding between nopCommerce and Paypal. Damn! I could end up being on penny less in Paypal (possibly one penny more - not sure yet).

The way that nopCommerce does discounts and tax is that is takes everything in the cart and figures tax... then it takes the disount off... leaving the customer having to pay tax for the discount. That doesn't seem right to me. I've tried to factor in the discount when the tax is totaled, but the rounding is off just a hair....

The fix I have has several changes in ShoppingCartManager, OrderManager, TaxManager, and a module OrderTotals.ascx....

I'm sure this is not the way that Andrei would do it, but it (almost) works. If I can just get that penny!

I'll let you know when I'm finished. I'm VERY close. It all depends on how nopCommerce rounds as compared to Paypal. Sometimes the total matches EXACTLY... but then sometimes the rounding makes that penny difference.
13 years ago
Well this might explain it...

nopCommerce uses Math.Round to round the tax off, and Math.Round does this:

"If the value of the first digit in (tax total) to the right of the decimals decimal position is 5, the digit in the decimals position is rounded up if it is odd, or left unchanged if it is even. If the precision of d is less than decimals, d is returned unchanged."

Obvisouly Paypal rounds it all up...

How can I change that? Jeez!
13 years ago
Haha. Nice job. Thanks for looking into it.
13 years ago
I figured it out... each item as being rounded BEFORE it was being added to the tax total and then the tax total is rounded too, so:

Item price: $2.09
Item price with tax: $2.24 (rounded)
Item tax: $0.15 (should be $0.1463, but was rounded)

As you can see $0.15 is not the same as $0.1463 and if you have a lot of items in the cart then it can add up...

So I changed it so it won't round each item before being added to the tax total and just rounded the tax total.

What I had to do was add a boolean flag to the GetPrice method to tell it not to round the price, which forced me to add the same flag to GetCheckoutAttributePrice.

I also made a bunch of other changes to the TaxManager, OrderManager, ShoppingCartManager, PaypalStandardPaymentProcessor, CheckoutAttributes.cs, CheckoutAttributeHelper.cs, and OrderTotals.cs... I basically had to change the way nopCommerce delt with tax.

This is pretty complex fix... but I fixed it.

Do you want me to try to explain it?

This may be an issue that needs to be brought up to the nopCommerce team... tax should be calculated AFTER any discounts are taken off - at least that is the way that I've always understood it to be.
13 years ago
Don't you need to open a issue for this? There is not a lot of feedback from the forum.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.