Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PayPal Express redirect fails when using DeferredTax mixin #98

Closed
nfletton opened this issue Apr 14, 2015 · 3 comments
Closed

PayPal Express redirect fails when using DeferredTax mixin #98

nfletton opened this issue Apr 14, 2015 · 3 comments

Comments

@nfletton
Copy link

The following error occurs when clicking the PayPal icon at the payment step of the checkout process when using the DeferredTax mixin:

Can't calculate price.incl_tax as tax isn't known
Request Method: GET
Request URL:    http://127.0.0.1:5000/checkout/paypal/payment/
Django Version: 1.7.7
Exception Type: TaxNotKnown
Exception Value:    Can't calculate price.incl_tax as tax isn't known

Bearing in mind this is the first time I've used Oscar, the problem appears to be that the PayPal Express RedirectView uses the basket in the request object rather than the basket after it has had tax applied by the the overridden build_submission() method in CheckoutSessionMixin.

The solution that works in my scenario is to call build_submission() directly to get the basket with deferred taxes calculated.

Old code:

class RedirectView(CheckoutSessionMixin, RedirectView):
    ....
    def get_redirect_url(self, **kwargs):
        try:
            basket = self.request.basket
            url = self._get_redirect_url(basket, **kwargs)
        except PayPalError:
        ....

Patched code:

class RedirectView(CheckoutSessionMixin, RedirectView):
    ....
    def get_redirect_url(self, **kwargs):
        try:
            basket = self.build_submission()['basket']
            url = self._get_redirect_url(basket, **kwargs)
        except PayPalError:
        ....
@fghaas
Copy link
Contributor

fghaas commented Jan 10, 2016

Wow, I just wasted an entire day on this same exact problem, thinking something was wrong with my own CheckoutSessionMixin. @nfletton, thanks oodles for tracking it down. @maikhoepfel, it looks like this breaks pretty critical functionality -- any chance to get this issue reviewed?

fghaas added a commit to fghaas/django-oscar-paypal that referenced this issue Jan 10, 2016
When the RedirectView is used in combination with another
CheckoutSessionMixin defined for a DeferredTax taxation strategy, then
submission's basket object has critical tax information, whereas
request.basket does not. Change RedirectView's basket reference to
point to build_submission()['basket'].

Fixes django-oscar#98, reported by Nigel Fletton.
@fghaas
Copy link
Contributor

fghaas commented Jan 10, 2016

I've added PR #121 which implements @nfletton's suggested fix, which I can confirm fixes the problem for me — unfortunately I don't really know what would be a good way to unit-test this.

fghaas added a commit to fghaas/django-oscar-paypal that referenced this issue Jan 12, 2016
When the RedirectView is used in combination with another
CheckoutSessionMixin defined for a DeferredTax taxation strategy, then
submission's basket object has critical tax information, whereas
request.basket does not. Change RedirectView's basket reference to
point to build_submission()['basket'].

Fixes django-oscar#98, reported by Nigel Fletton.
@calvinkcc
Copy link

Still a problem. Because using Express checkout means your not doing shipping parameters and when you don't do that means taxes isnt calculated. That's if your using an USstrategy. So what can we do about this situation?

youngwarrior126 pushed a commit to youngwarrior126/Django_Angular that referenced this issue Dec 25, 2019
When the RedirectView is used in combination with another
CheckoutSessionMixin defined for a DeferredTax taxation strategy, then
submission's basket object has critical tax information, whereas
request.basket does not. Change RedirectView's basket reference to
point to build_submission()['basket'].

Fixes django-oscar/django-oscar-paypal#98, reported by Nigel Fletton.
youngwarrior126 pushed a commit to youngwarrior126/Django_Angular that referenced this issue Dec 26, 2019
When the RedirectView is used in combination with another
CheckoutSessionMixin defined for a DeferredTax taxation strategy, then
submission's basket object has critical tax information, whereas
request.basket does not. Change RedirectView's basket reference to
point to build_submission()['basket'].

Fixes django-oscar/django-oscar-paypal#98, reported by Nigel Fletton.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants