Create API webhook, endpoints for subscription payments using Stripe

- Add fields to mark users as subscribed to a specific plan and
  subscription renewal date in DB
- Add ability to unsubscribe a user using their email address
- Expose webhook for stripe to callback confirming payment
This commit is contained in:
Debanjum Singh Solanky
2023-11-07 10:15:21 -08:00
parent 156421d30a
commit 9aaf475c8a
5 changed files with 116 additions and 3 deletions

View File

@@ -14,7 +14,15 @@ class BaseModel(models.Model):
class KhojUser(AbstractUser):
class SubscriptionType(models.TextChoices):
TRIAL = "trial"
STANDARD = "standard"
uuid = models.UUIDField(models.UUIDField(default=uuid.uuid4, editable=False))
subscription_type = models.CharField(
max_length=20, choices=SubscriptionType.choices, default=SubscriptionType.TRIAL
)
subscription_renewal_date = models.DateTimeField(null=True, default=None)
def save(self, *args, **kwargs):
if not self.uuid: