diff --git a/api/donate/donate_serializer.py b/api/donate/donate_serializer.py index 3ce7e743..c9d9d5fb 100644 --- a/api/donate/donate_serializer.py +++ b/api/donate/donate_serializer.py @@ -8,10 +8,11 @@ class DonorSerializer(serializers.ModelSerializer): + currency = serializers.CharField(allow_null=True, allow_blank=True, default='INR') class Meta: model = Donor - exclude = ['created_by', 'created_at', 'id'] + exclude = ['created_by', 'created_at', 'id', 'payment_id', 'payment_method'] def create(self, validated_data): validated_data["created_by_id"] = settings.SYSTEM_ADMIN_ID diff --git a/api/donate/views.py b/api/donate/views.py index e5705727..ef32bd7c 100644 --- a/api/donate/views.py +++ b/api/donate/views.py @@ -103,10 +103,8 @@ def post(self, request): request.data.get("razorpay_payment_id") ) transaction_details = { - "Payment ID": data['id'], - "Payment Method": data['method'], "Amount": float(data['amount']) / 100, - "Currency": data['currency'], + "Currency": data['currency', None], "Name": data['notes']['name'], "Email": data['notes']['email'], } @@ -115,12 +113,12 @@ def post(self, request): if extra_data := data['notes'].get('phone_number', None): transaction_details["Phone Number"] = extra_data if extra_data := data['notes'].get('pan_number', None): - transaction_details["PAN number"] = extra_data + transaction_details["PAN number"] = extra_data serializer = DonorSerializer(data=data['notes']['validated_data']) - # if serializer.is_valid(): - # serializer.save() + if serializer.is_valid(): + serializer.save() return create_receipt(transaction_details) except razorpay.errors.SignatureVerificationError as e: - return CustomResponse(message=str(e)).get_failure_response() + return CustomResponse(general_message = "Payment Verification Failed").get_failure_response() diff --git a/api/launchpad/launchpad_views.py b/api/launchpad/launchpad_views.py index 8a9527ca..d757732b 100644 --- a/api/launchpad/launchpad_views.py +++ b/api/launchpad/launchpad_views.py @@ -101,9 +101,9 @@ def get(self, request): district_name=F("user_organization_link_user__org__district__name"), state=F("user_organization_link_user__org__district__zone__state__name"), level=F("user_role_link_user__role__title"), - time_=Max("karma_activity_log_user__created_at"), + time_=Max("karma_activity_log_user__created_at") ).filter( - level__in=allowed_levels + Q(level__in=allowed_levels) | Q(level__isnull=True) ).distinct() paginated_queryset = CommonUtils.get_paginated_queryset( @@ -431,4 +431,4 @@ def post(self, request): errors[data.get('email')]["not_found_colleges"] = not_found_colleges if error: return CustomResponse(message=errors).get_failure_response() - return CustomResponse(general_message="Successfully added users").get_success_response() \ No newline at end of file + return CustomResponse(general_message="Successfully added users").get_success_response() diff --git a/api/launchpad/serializers.py b/api/launchpad/serializers.py index 92386593..0fe5bdf5 100644 --- a/api/launchpad/serializers.py +++ b/api/launchpad/serializers.py @@ -72,7 +72,7 @@ class LaunchpadParticipantsSerializer(serializers.ModelSerializer): org = serializers.CharField(allow_null=True, allow_blank=True) district_name = serializers.CharField(allow_null=True, allow_blank=True) state = serializers.CharField(allow_null=True, allow_blank=True) - level = serializers.CharField() + level = serializers.CharField(allow_null=True, allow_blank=True) class Meta: model = User