Skip to content

Commit

Permalink
feat: add more fields related to Stripe (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonylucas74 authored Aug 29, 2024
1 parent c049805 commit 3ef271f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
14 changes: 13 additions & 1 deletion backend/apps/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,19 @@ def is_pro(self):
@property
def canceled_at(self):
if self.subscription:
return self.subscription.canceled_at.isoformat()
return self.subscription.cancel_at.isoformat()
return None

@property
def plan_interval(self):
if self.subscription:
return self.subscription.plan.interval
return None

@property
def next_billing_cycle(self):
if self.subscription:
return self.subscription.current_period_end.isoformat()
return None


Expand Down
10 changes: 9 additions & 1 deletion backend/custom/graphql_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,13 @@ def mutate(cls, *args, **kwargs):
email = response.payload.get("email")
user = Account.objects.get(email=email)
if user:
response.payload.update({"pro_subscription_status": user.pro_subscription_status})
subscription = user.pro_owner_subscription or user.pro_member_subscription
is_subscription_active = subscription.is_active if subscription else False

response.payload.update(
{
"pro_subscription_status": user.pro_subscription_status,
"is_subscription_active": is_subscription_active,
}
)
return response

0 comments on commit 3ef271f

Please sign in to comment.