Skip to content

Commit

Permalink
Track payment number owner name
Browse files Browse the repository at this point in the history
  • Loading branch information
sravfeyn committed Nov 20, 2024
1 parent d9b1316 commit 6b3377c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions payments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('phone_number', phonenumber_field.modelfields.PhoneNumberField(max_length=128, region=None)),
('owner_name', models.TextField(max_length=150, blank=True)),
('telecom_provider', models.CharField(blank=True, max_length=50, null=True)),
('is_verified', models.BooleanField(default=False)),
('status', models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected')], default='pending', max_length=10)),
Expand Down
1 change: 1 addition & 0 deletions payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PaymentProfile(models.Model):
related_name='payment_profile'
)
phone_number = PhoneNumberField()
owner_name = models.TextField(max_length=150, blank=True)
telecom_provider = models.CharField(max_length=50, blank=True, null=True)
# whether the number is verified using OTP
is_verified = models.BooleanField(default=False)
Expand Down
2 changes: 2 additions & 0 deletions payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
def update_payment_profile_phone(request):
user = request.user
phone_number = request.data.get('phone_number')
owner_name = request.data.get('owner_name')
telecom_provider = lookup_telecom_provider(phone_number)
payment_profile, created = PaymentProfile.objects.update_or_create(
user=user,
defaults={
'phone_number': phone_number,
'owner_name': owner_name,
'telecom_provider': telecom_provider,
'is_verified': False,
'status': PaymentProfile.PENDING
Expand Down
3 changes: 2 additions & 1 deletion users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,13 @@ def user_payment_profile(user):
profile = user.payment_profile
return {"payment_profile": {
"phone_number": profile.phone_number,
"owner_name": profile.owner_name,
"telecom_provider": profile.telecom_provider,
"is_verified": profile.is_verified,
"status": profile.status,
}}
except ObjectDoesNotExist:
return {}
return {"payment_profile": {}}


@api_view(['POST'])
Expand Down

0 comments on commit 6b3377c

Please sign in to comment.