-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* format * small fix * Finished vipps confimation * Fixed linting * Fixed linting again * change endpoint url, add permission check for endpoint * Fix enum spelling * fixed permission check, added test to make sure it works as it should * fix linting * added tests that verify only index members and members of the organizing group can update an order * changed response key from 'is_true' to detail, and made the description more explanatory * fikset skrivefeil --------- Co-authored-by: 1Cezzo <[email protected]>
- Loading branch information
1 parent
b695ee1
commit c07e432
Showing
8 changed files
with
137 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
VippsOrderSerialzer, | ||
OrderListSerializer, | ||
OrderUpdateSerializer, | ||
CheckPaymentSerializer, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from app.payment.views.vipps_util import check_vipps_payment | ||
from app.payment.serializers import CheckPaymentSerializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from rest_framework import status | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
|
||
from app.payment.models import Order | ||
from app.payment.serializers import CheckPaymentSerializer | ||
from app.payment.util.payment_utils import get_payment_order_status | ||
|
||
|
||
@api_view(["POST"]) | ||
def check_vipps_payment(self, request, *args, **kwargs): | ||
has_changed = False | ||
|
||
serializer = CheckPaymentSerializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
|
||
event_id = serializer.validated_data["event_id"] | ||
user_id = serializer.validated_data["user_id"] | ||
|
||
orders = self.queryset.filter(user_id=user_id, event_id=event_id) | ||
|
||
if not orders.exists(): | ||
return Response( | ||
{"detail": "Ingen ordre funnet for bruker og arrangement."}, | ||
status=status.HTTP_404_NOT_FOUND, | ||
) | ||
|
||
if not Order.has_update_permission(self.request): | ||
return Response( | ||
{"detail": "Du har ikke tilgang til å oppdatere denne ordren."}, | ||
status=status.HTTP_403_FORBIDDEN, | ||
) | ||
|
||
for order in orders: | ||
order_status = get_payment_order_status(order.order_id) | ||
if order_status != order.status: | ||
has_changed = True | ||
order.status = order_status | ||
order.save() | ||
|
||
if has_changed(order): | ||
return Response( | ||
{"detail": "Ordrestatusen var feil og har blitt endret."}, | ||
status=status.HTTP_200_OK, | ||
) | ||
return Response( | ||
{"detail": "Ordrestatusen er korrekt og har ikke blitt endret."}, | ||
status=status.HTTP_200_OK, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters