Skip to content

Commit

Permalink
send payment valid status message
Browse files Browse the repository at this point in the history
  • Loading branch information
sravfeyn committed Nov 7, 2024
1 parent 5923600 commit f0ac6d2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion payments/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.http import JsonResponse, HttpResponse, Http404
from django.views.decorators.http import require_POST
from messaging.views import send_bulk_message
from messaging.serializers import MessageData
from oauth2_provider.decorators import protected_resource
from utils.rest_framework import ClientProtectedResourceAuth
from rest_framework.decorators import api_view
Expand Down Expand Up @@ -60,12 +62,32 @@ class ValidatePhoneNumber(APIView):
def post(self, request, *args, **kwargs):
username = request.data["username"]
phone_number = request.data["phone_number"]
is_valid = request.data["is_valid"]
user = ConnectUser.objects.get(username=username)
profile = getattr(user, "payment_profile")

if not profile or profile.phone_number != phone_number:
raise Http404("Payment number not found")

profile.is_validated = True
profile.is_validated = is_valid
profile.save()
if is_valid:
message = MessageData(
usernames=["username"],
title="Your Payment Phonenumber is approved",
body="Your payment phone number is approved and future payments will be made to this number",
data={
"action": "ccc_payment_info_confirmation",
"confirmation_status": True
})
else:
message = MessageData(
usernames=["username"],
title="Your Payment Phonenumber did not work",
body="Your payment number did not work. Please try to change to a different payment phone number",
data={
"action": "ccc_payment_info_confirmation",
"confirmation_status": True
})
send_bulk_message(message)
return HttpResponse()

0 comments on commit f0ac6d2

Please sign in to comment.