Skip to content

Commit

Permalink
Fixes actual issue, noticed an issue with checkout callback, working …
Browse files Browse the repository at this point in the history
…through that
  • Loading branch information
jkachel committed Jan 3, 2025
1 parent 3615e6c commit 103a9be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 10 additions & 2 deletions payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,11 +919,19 @@ def _get_or_create(self, basket: Basket):
# (this re-uses a PendingOrder if it exists, so it might now be wrong)
order.tax_rate = basket.tax_rate
order.purchaser_ip = basket.user_ip
order.purchaser_taxable_country_code = basket.user_taxable_country_code
order.purchaser_taxable_country_code = (
basket.user_taxable_country_code
if basket.user_taxable_country_code
else ""
)
order.purchaser_taxable_geolocation_type = (
basket.user_taxable_geolocation_type
)
order.purchaser_blockable_country_code = basket.user_blockable_country_code
order.purchaser_blockable_country_code = (
basket.user_blockable_country_code
if basket.user_blockable_country_code
else ""
)
order.purchaser_blockable_geolocation_type = (
basket.user_blockable_geolocation_type
)
Expand Down
8 changes: 5 additions & 3 deletions payments/views/v0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View
from django_filters import rest_framework as filters
from drf_spectacular.utils import (
OpenApiParameter,
Expand All @@ -20,7 +19,7 @@
from mitol.payment_gateway.api import PaymentGateway
from rest_framework import status
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.viewsets import ReadOnlyModelViewSet
Expand Down Expand Up @@ -272,14 +271,17 @@ def start_checkout(request, system_slug: str):


@method_decorator(csrf_exempt, name="dispatch")
class CheckoutCallbackView(View):
class CheckoutCallbackView(APIView):
"""
Handles the redirect from the payment gateway after the user has completed
checkout. This may not always happen as the redirect back to the app
occasionally fails. If it does, then the payment gateway should trigger
things via the backoffice webhook.
"""

authentication_classes = [] # disables authentication
permission_classes = (AllowAny,) # disables permission

def _get_payment_process_redirect_url_from_line_items(self, request):
"""
Returns the payment process redirect URL
Expand Down

0 comments on commit 103a9be

Please sign in to comment.