mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add course checkout UI and stripe integration and webhook wip
This commit is contained in:
parent
d8913d1a60
commit
1bff401e73
18 changed files with 1086 additions and 131 deletions
|
|
@ -2,12 +2,14 @@ from sqlmodel import SQLModel, Field, Column, BigInteger, ForeignKey
|
|||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
class PaymentCourseBase(SQLModel):
|
||||
class PaymentsCourseBase(SQLModel):
|
||||
course_id: int = Field(sa_column=Column(BigInteger, ForeignKey("course.id", ondelete="CASCADE")))
|
||||
payment_product_id: int = Field(sa_column=Column(BigInteger, ForeignKey("paymentsproduct.id", ondelete="CASCADE")))
|
||||
org_id: int = Field(sa_column=Column(BigInteger, ForeignKey("organization.id", ondelete="CASCADE")))
|
||||
|
||||
class PaymentCourse(PaymentCourseBase, table=True):
|
||||
|
||||
class PaymentsCourse(PaymentsCourseBase, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
payment_product_id: int = Field(sa_column=Column(BigInteger, ForeignKey("paymentsproduct.id", ondelete="CASCADE")))
|
||||
org_id: int = Field(
|
||||
sa_column=Column(BigInteger, ForeignKey("organization.id", ondelete="CASCADE"))
|
||||
)
|
||||
creation_date: datetime = Field(default=datetime.now())
|
||||
update_date: datetime = Field(default=datetime.now())
|
||||
|
|
@ -1,19 +1,37 @@
|
|||
from enum import Enum
|
||||
from sqlmodel import SQLModel, Field, Column, BigInteger, ForeignKey
|
||||
from openai import BaseModel
|
||||
from sqlmodel import SQLModel, Field, Column, BigInteger, ForeignKey, JSON
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
|
||||
class PaymentUserStatusEnum(str, Enum):
|
||||
class PaymentStatusEnum(str, Enum):
|
||||
PENDING = "pending"
|
||||
COMPLETED = "completed"
|
||||
ACTIVE = "active"
|
||||
INACTIVE = "inactive"
|
||||
|
||||
CANCELLED = "cancelled"
|
||||
FAILED = "failed"
|
||||
REFUNDED = "refunded"
|
||||
|
||||
|
||||
class ProviderSpecificData(BaseModel):
|
||||
stripe_customer: dict | None = None
|
||||
custom_customer: dict | None = None
|
||||
|
||||
class PaymentsUserBase(SQLModel):
|
||||
user_id: int = Field(sa_column=Column(BigInteger, ForeignKey("user.id", ondelete="CASCADE")))
|
||||
status: PaymentUserStatusEnum = PaymentUserStatusEnum.ACTIVE
|
||||
payment_product_id: int = Field(sa_column=Column(BigInteger, ForeignKey("paymentsproduct.id", ondelete="CASCADE")))
|
||||
org_id: int = Field(sa_column=Column(BigInteger, ForeignKey("organization.id", ondelete="CASCADE")))
|
||||
status: PaymentStatusEnum = PaymentStatusEnum.PENDING
|
||||
provider_specific_data: dict = Field(default={}, sa_column=Column(JSON))
|
||||
|
||||
class PaymentsUser(PaymentsUserBase, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
user_id: int = Field(
|
||||
sa_column=Column(BigInteger, ForeignKey("user.id", ondelete="CASCADE"))
|
||||
)
|
||||
org_id: int = Field(
|
||||
sa_column=Column(BigInteger, ForeignKey("organization.id", ondelete="CASCADE"))
|
||||
)
|
||||
payment_product_id: int = Field(
|
||||
sa_column=Column(BigInteger, ForeignKey("paymentsproduct.id", ondelete="CASCADE"))
|
||||
)
|
||||
creation_date: datetime = Field(default=datetime.now())
|
||||
update_date: datetime = Field(default=datetime.now())
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ class AnonymousUser(SQLModel):
|
|||
user_uuid: str = "user_anonymous"
|
||||
username: str = "anonymous"
|
||||
|
||||
class InternalUser(SQLModel):
|
||||
id: int = 0
|
||||
user_uuid: str = "user_internal"
|
||||
username: str = "internal"
|
||||
|
||||
|
||||
class User(UserBase, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue