tomash/spree-pp-website-standard — pull request #11 by hoverlover (2012-01-26 19:40:30+00:00)
Title: Don't destroy line items

I made a change in `base_controller_decorator.rb` to not destroy the line items. This was causing a problem if the user returns to the Spree site via some means other than the PayPal link, but after the IPN call is made.

As a result of the IPN call, the `order#payment_state` is set to `paid`. When the line items are destroyed in the `base_controller_decorator.rb`, it triggers the `order#update!` method. This in turn calls `order#update_totals`, and since there are no longer any line items, sets `order#total` to 0. It also triggers the `order#update_payment_state`. This method sees that `order#total` is now 0, and sets the `order#payment_state` to `credit_owed` since there is a payment with an amount greater than 0.

You can see how removing the line items is causing problems. I opted to simply set the `@current_order` to `nil`, and since you were already setting the `order_id` in the session to `nil`, the user no longer has a cart.