-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
63 lines (49 loc) · 1.74 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import logging
from django.http import HttpResponseRedirect
from django.utils.decorators import method_decorator
from django.urls import reverse
from rest_framework import (
viewsets,
serializers,
)
from rest_framework.decorators import action
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from paybox_api import PayboxAPI
logger = logging.getLogger(__name__)
class PayboxViewSet(viewsets.ViewSet):
permission_classes = (AllowAny,)
@action(methods=['post'], detail=False)
@method_decorator(PayboxAPI.verify_paybox())
def check(self, request):
# Do smth here
return Response()
@action(methods=['post'], detail=False)
@method_decorator(PayboxAPI.verify_paybox())
def result(self, request):
body = PayboxAPI.parse_body(request.body)
if body['pg_result'] == '1':
# Handle success result
else:
# Handle failure result
return Response()
@action(methods=['post'], detail=False)
@method_decorator(PayboxAPI.verify_paybox())
def refund(self, request):
# Do smth here
return Response({'refund': 'refund'})
@action(methods=['post'], detail=False)
@method_decorator(PayboxAPI.verify_paybox())
def capture(self, request):
# Do smth here
return Response({'capture': 'capture'})
@action(methods=['post'], detail=False)
@method_decorator(PayboxAPI.verify_paybox())
def success(self, request):
# Do smth here
return HttpResponseRedirect('google.com')
@action(methods=['post'], detail=False)
@method_decorator(PayboxAPI.verify_paybox())
def failure(self, request):
# Do smth here
return HttpResponseRedirect('google.com')