feat(topup): add payment_type field and update AdminTopupCreateView to handle payment type

This commit is contained in:
2025-07-27 12:17:12 +05:00
parent cdef5ed27c
commit 80fc27fd74
3 changed files with 37 additions and 6 deletions
+8 -6
View File
@@ -624,14 +624,16 @@ class AdminTopupCreateView(StaffEditorPermissionMixin, generics.CreateAPIView):
{"message": "User not found."},
status=status.HTTP_404_NOT_FOUND,
)
topup = Topup.objects.create(amount=amount, user=user)
description = f"Topup of {amount} MVR (Cash)"
WalletTransaction.objects.create(
user=user,
topup = Topup.objects.create(
amount=amount,
transaction_type="TOPUP",
description=description,
user=user,
paid=True,
paid_at=timezone.now(),
payment_type="CASH",
status="PAID",
)
description = f"Topup of {amount} MVR (Cash)"
user.add_wallet_funds(amount, description, topup.id)
serializer = TopupSerializer(topup)
return Response(serializer.data, status=status.HTTP_201_CREATED)