mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: prevent access removal if user has paid for a product
This commit is contained in:
parent
0e97580747
commit
cdd893ca6f
7 changed files with 40 additions and 17 deletions
|
|
@ -43,7 +43,7 @@ async def create_payment_user(
|
|||
stripe_customer=provider_data if provider_data else None,
|
||||
)
|
||||
|
||||
# Check if user already has a payment user
|
||||
# Check if user already has a payment user for this product
|
||||
statement = select(PaymentsUser).where(
|
||||
PaymentsUser.user_id == user_id,
|
||||
PaymentsUser.org_id == org_id,
|
||||
|
|
@ -52,8 +52,12 @@ async def create_payment_user(
|
|||
existing_payment_user = db_session.exec(statement).first()
|
||||
|
||||
if existing_payment_user:
|
||||
if existing_payment_user.status == PaymentStatusEnum.PENDING:
|
||||
# Delete existing pending payment
|
||||
# If status is PENDING, CANCELLED, or FAILED, delete the existing record
|
||||
if existing_payment_user.status in [
|
||||
PaymentStatusEnum.PENDING,
|
||||
PaymentStatusEnum.CANCELLED,
|
||||
PaymentStatusEnum.FAILED
|
||||
]:
|
||||
db_session.delete(existing_payment_user)
|
||||
db_session.commit()
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue