Coverage for polar/integrations/stripe/schemas.py: 100%
31 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
1from enum import StrEnum 1a
2from typing import Literal 1a
3from uuid import UUID 1a
5from polar.kit.schemas import Schema 1a
8class PaymentIntentSuccessWebhook(Schema): 1a
9 id: str # A payment intent id (pi_) 1a
10 amount: int 1a
11 currency: str 1a
12 amount_received: int 1a
13 customer: str | None 1a
14 invoice: str | None # A invoice ID (in_) 1a
15 latest_charge: str # A charge ID (ch_ or py_) 1a
16 status: str # "succeeded" 1a
17 receipt_email: str | None = None 1a
20class ProductType(StrEnum): 1a
21 pledge = "pledge" 1a
22 product = "product" 1a
25class PaymentIntentMetadata(Schema): 1a
26 """
27 Stripe Metadata
29 Setting a value to an empty string will remove the field from Stripe.
30 Sending a empty metadata object will remove all metadata from Stripe.
32 This is why we always set polar_not_empty to an empty string, to prevent us from
33 accidentally un-setting all metadata.
34 """
36 # Safe guards us from accidentally sending an empty metadata object
37 polar_not_empty: str = "" 1a
39 type: ProductType 1a
42class PledgePaymentIntentMetadata(PaymentIntentMetadata): 1a
43 type: Literal[ProductType.pledge] = ProductType.pledge 1a
45 issue_id: UUID | None = None 1a
46 issue_title: str | None = None 1a
48 anonymous: bool = False 1a
49 anonymous_email: str | None = None 1a
51 user_id: UUID | None = None 1a
52 user_email: str | None = None 1a
53 organization_id: UUID | None = None 1a
54 organization_name: str | None = None 1a
56 # Set to empty string to unset the value
57 on_behalf_of_organization_id: UUID | Literal[""] | None = None 1a