Coverage for polar/payment_method/schemas.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 16:17 +0000

1from typing import Literal 1a

2 

3from pydantic import UUID4, AliasPath, Field, TypeAdapter 1a

4 

5from polar.enums import PaymentProcessor 1a

6from polar.kit.schemas import IDSchema, Schema, TimestampedSchema 1a

7 

8 

9class PaymentMethodBase(TimestampedSchema, IDSchema): 1a

10 processor: PaymentProcessor 1a

11 customer_id: UUID4 1a

12 

13 

14class PaymentMethodGeneric(PaymentMethodBase): 1a

15 type: str 1a

16 

17 

18class PaymentMethodCardMetadata(Schema): 1a

19 brand: str 1a

20 last4: str 1a

21 exp_month: int 1a

22 exp_year: int 1a

23 wallet: str | None = Field( 1a

24 default=None, validation_alias=AliasPath("wallet", "type") 

25 ) 

26 

27 

28class PaymentMethodCard(PaymentMethodBase): 1a

29 type: Literal["card"] 1a

30 method_metadata: PaymentMethodCardMetadata 1a

31 

32 

33PaymentMethod = PaymentMethodCard | PaymentMethodGeneric 1a

34PaymentMethodTypeAdapter: TypeAdapter[PaymentMethod] = TypeAdapter(PaymentMethod) 1a