tangentlabs/django-oscar-paypal — pull request #41 by marcofucci (2013-09-25 16:24:49+00:00)
Title: Fixes self.basket not found in SuccessResponseView in case of paypal payment exceptions

This fixes the error *AttributeError: 'SuccessResponseView' object has no attribute 'basket'* generated by `SuccessResponseView.get_context_data` in case of paypal exceptions during the payment.

**Description**

Take a look at the `SuccessResponseView`

* the `post` method calls `submit` with `basket` as argument
* `submit` calls `handle_payment` and catches different exceptions
* if `handle_payment` raises an Exception (e.g. `PayPalError`), `submit` calls `self.render_to_response(self.get_context_data(error=msg))` rendering the template with an extra variable `error`
* the method `get_context_data` tries to access to `self.basket` which doesn't exist so it raises an `AttributeError`

**Solution**

The solution consists of setting `self.basket` in `post` as it happens in `get` so that `get_context_data` can find it.