Coverage for polar/payment_method/schemas.py: 100%
11 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
1from typing import Literal
3from pydantic import UUID4, AliasPath, Field, TypeAdapter
5from polar.enums import PaymentProcessor
6from polar.kit.schemas import IDSchema, Schema, TimestampedSchema
9class PaymentMethodBase(TimestampedSchema, IDSchema):
10 processor: PaymentProcessor
11 customer_id: UUID4
14class PaymentMethodGeneric(PaymentMethodBase):
15 type: str
18class PaymentMethodCardMetadata(Schema):
19 brand: str
20 last4: str
21 exp_month: int
22 exp_year: int
23 wallet: str | None = Field(
24 default=None, validation_alias=AliasPath("wallet", "type")
25 )
28class PaymentMethodCard(PaymentMethodBase):
29 type: Literal["card"]
30 method_metadata: PaymentMethodCardMetadata
33PaymentMethod = PaymentMethodCard | PaymentMethodGeneric
34PaymentMethodTypeAdapter: TypeAdapter[PaymentMethod] = TypeAdapter(PaymentMethod)