Coverage for polar/integrations/stripe/schemas.py: 100%
22 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 enum import StrEnum
2from typing import Literal
3from uuid import UUID
5from polar.kit.schemas import Schema
8class PaymentIntentSuccessWebhook(Schema):
9 id: str # A payment intent id (pi_)
10 amount: int
11 currency: str
12 amount_received: int
13 customer: str | None
14 invoice: str | None # A invoice ID (in_)
15 latest_charge: str # A charge ID (ch_ or py_)
16 status: str # "succeeded"
17 receipt_email: str | None = None
20class ProductType(StrEnum):
21 pledge = "pledge"
22 product = "product"
25class PaymentIntentMetadata(Schema):
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 = ""
39 type: ProductType
42class PledgePaymentIntentMetadata(PaymentIntentMetadata):
43 type: Literal[ProductType.pledge] = ProductType.pledge
45 issue_id: UUID | None = None
46 issue_title: str | None = None
48 anonymous: bool = False
49 anonymous_email: str | None = None
51 user_id: UUID | None = None
52 user_email: str | None = None
53 organization_id: UUID | None = None
54 organization_name: str | None = None
56 # Set to empty string to unset the value
57 on_behalf_of_organization_id: UUID | Literal[""] | None = None