File size: 1,117 Bytes
2756f0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Billing request and response bodies. Webhook bodies are the stores' own shapes, so they ignore unknown fields."""

from typing import Literal

from pydantic import ConfigDict, Field

from app.common.schemas import RequestModel, ResponseModel
from app.modules.billing.entitlement import Entitlement


class ReceiptIn(RequestModel):
    platform: Literal["ios", "android"]
    product_id: str = Field(min_length=1, max_length=64)
    signed_transaction: str | None = Field(default=None, max_length=32_000)
    purchase_token: str | None = Field(default=None, max_length=4_096)


class ReceiptOut(ResponseModel):
    entitlement: Entitlement


class AppleWebhookIn(RequestModel):
    model_config = ConfigDict(extra="ignore", populate_by_name=True)

    signed_payload: str = Field(alias="signedPayload", max_length=200_000)


class PubSubMessage(RequestModel):
    model_config = ConfigDict(extra="ignore")

    data: str = Field(default="", max_length=100_000)


class PubSubPushIn(RequestModel):
    model_config = ConfigDict(extra="ignore")

    message: PubSubMessage


class WebhookAck(ResponseModel):
    pass