A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/django-oscar/django-oscar-paypal/issues/98 below:

PayPal Express redirect fails when using DeferredTax mixin · Issue #98 · django-oscar/django-oscar-paypal · GitHub

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:
        ....

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4