application request create
This commit is contained in:
parent
d57d40ffa7
commit
11154086fd
2 changed files with 4 additions and 4 deletions
|
|
@ -8,5 +8,5 @@ urlpatterns = [
|
||||||
path('page/charge/<uuid>/', PaymentRequestView.as_view(), name='payment-request-view'),
|
path('page/charge/<uuid>/', PaymentRequestView.as_view(), name='payment-request-view'),
|
||||||
path('page/pna_callback/<uuid>/', PaymentConfirmView.as_view(), name='payment-confirm-view'),
|
path('page/pna_callback/<uuid>/', PaymentConfirmView.as_view(), name='payment-confirm-view'),
|
||||||
path('api/charge_create/', PaymentRequestCreateApiView.as_view(), name='charge-request-create-api-view'),
|
path('api/charge_create/', PaymentRequestCreateApiView.as_view(), name='charge-request-create-api-view'),
|
||||||
path('api/application/charge_create/', ApplicationPaymentRequestCreateApiView.as_view(), name='application-user-charge-request-create-api-view'),
|
path('api/application/charge_create/<uuid>', ApplicationPaymentRequestCreateApiView.as_view(), name='application-user-charge-request-create-api-view'),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,13 @@ class PaymentRequestCreateApiView(generics.CreateAPIView):
|
||||||
|
|
||||||
class ApplicationPaymentRequestCreateApiView(generics.CreateAPIView):
|
class ApplicationPaymentRequestCreateApiView(generics.CreateAPIView):
|
||||||
permission_classes = [IsAuthenticatedOrTokenHasScope]
|
permission_classes = [IsAuthenticatedOrTokenHasScope]
|
||||||
serializer_class = ApplicationPaymentRequestSerializer
|
serializer_class = PaymentRequestSerializer
|
||||||
required_scopes = ['ipg.application:request_user_charge'] # TODO: is it good scope?
|
required_scopes = ['ipg.application:request_user_charge'] # TODO: is it good scope?
|
||||||
model = PaymentRequest
|
model = PaymentRequest
|
||||||
|
|
||||||
def perform_create(self, serializer):
|
def perform_create(self, serializer):
|
||||||
user_id = serializer.validated_data['user']
|
user_uuid = self.kwargs.get('uuid')
|
||||||
user, created = User.objects.get_or_create(id=user_id)
|
user, created = User.objects.get_or_create(uuid=user_uuid)
|
||||||
application = get_application(self.request)
|
application = get_application(self.request)
|
||||||
charge_request: PaymentRequest = serializer.save(user=user, application=application)
|
charge_request: PaymentRequest = serializer.save(user=user, application=application)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue