Ir para o conteúdo

tempest_fastapi_sdk.integrations.payment.stripe

Stripe, da chave de API ao webhook verificado.

« Integrações e pagamentos


StripeClient

StripeClient(client: HTTPClient)

Typed entry point for the Stripe resources a payments flow needs.

Build it with an :class:HTTPClient from :func:~tempest_fastapi_sdk.integrations.payment.stripe.stripe_http_client, so retries, the circuit breaker and the pinned Stripe-Version come from one place and tests can inject an httpx.MockTransport.

Attributes:

Name Type Description
customers StripeResource[StripeCustomer]

/v1/customers.

payment_intents StripeResource[StripePaymentIntent]

/v1/payment_intents.

refunds StripeResource[StripeRefund]

/v1/refunds.

products StripeResource[StripeProduct]

/v1/products.

prices StripeResource[StripePrice]

/v1/prices.

subscriptions StripeResource[StripeSubscription]

/v1/subscriptions.

invoices StripeResource[StripeInvoice]

/v1/invoices.

checkout_sessions StripeResource[StripeCheckoutSession]

/v1/checkout/sessions.

events StripeResource[StripeEventObject]

/v1/events.

Initialize the client.

Parameters:

Name Type Description Default
client HTTPClient

Configured transport. The caller owns its lifecycle, timeout, retry policy and auth headers.

required

request async

request(
    method: str,
    path: str,
    *,
    params: Mapping[str, Any] | None = None,
    data: Mapping[str, Any] | None = None,
    idempotency_key: str | None = None,
    expected_object: str | None = None,
) -> dict[str, Any]

Perform one Stripe call and return the decoded body.

Parameters:

Name Type Description Default
method str

HTTP method.

required
path str

Path starting with /v1.

required
params Mapping[str, Any] | None

Query parameters. Nested values are bracket-flattened the same way bodies are, so {"expand": ["customer"]} becomes expand[0]=customer.

None
data Mapping[str, Any] | None

Request body, form-encoded.

None
idempotency_key str | None

Value for the Idempotency-Key header on writes. None generates a UUID4 for every non-GET.

None
expected_object str | None

The object value a successful body must carry. None skips the check.

None

Returns:

Type Description
dict[str, Any]

dict[str, Any]: The decoded JSON body.

Raises:

Type Description
StripeError

On any non-2xx response.

StripeObjectMismatchError

When expected_object is given and the successful body's object differs or is missing.

Writes carry an idempotency key by default. Stripe replays the original response for a repeated key within 24 hours, which is what makes the SDK's own retry policy safe here: without it, a timeout on POST /v1/payment_intents followed by a retry can create two payments.

StripeResource

StripeResource(
    client: StripeClient,
    path: str,
    model: type[ResourceT],
    *,
    object_type: str | None = None,
)

Bases: Generic[ResourceT]

The five calls Stripe gives every resource, typed to one model.

Generic parameters

ResourceT: The model this resource returns.

Attributes:

Name Type Description
path str

Path segment under /v1 — "customers", "checkout/sessions".

model type[ResourceT]

The model responses validate into.

object_type str | None

The object value every single-object response must carry ("customer"). :meth:create, :meth:retrieve, :meth:update and :meth:delete raise :class:StripeObjectMismatchError on any other value. None skips the check.

The parametrized page model (StripeList[model]) is built once in the constructor: subscripting a generic Pydantic model creates a new class each time, so doing it per call would rebuild a model on every listing.

Initialize the resource.

Parameters:

Name Type Description Default
client StripeClient

The owning client.

required
path str

Path segment under /v1.

required
model type[ResourceT]

Model for responses.

required
object_type str | None

The object value single-object responses must carry. None skips the check.

None

create async

create(params: Mapping[str, Any], *, idempotency_key: str | None = None) -> ResourceT

Create the resource.

Parameters:

Name Type Description Default
params Mapping[str, Any]

The request body, nested freely — {"metadata": {"order": "1042"}} becomes metadata[order]=1042.

required
idempotency_key str | None

Key Stripe uses to collapse a retry onto the first attempt. None generates a UUID4, so a retried create never charges twice by accident.

None

Returns:

Name Type Description
ResourceT ResourceT

The created object.

Raises:

Type Description
StripeObjectMismatchError

When the body's object is not :attr:object_type.

StripeError

When Stripe rejects the request.

retrieve async

retrieve(resource_id: str, *, params: Mapping[str, Any] | None = None) -> ResourceT

Read one object by id.

Parameters:

Name Type Description Default
resource_id str

The object id.

required
params Mapping[str, Any] | None

Query parameters — {"expand": ["customer"]} to inline an expandable field.

None

Returns:

Name Type Description
ResourceT ResourceT

The object.

Raises:

Type Description
ValueError

When resource_id is empty, . or ...

StripeObjectMismatchError

When the body's object is not :attr:object_type.

StripeError

When Stripe rejects the request, including the 404 for an unknown id.

update async

update(
    resource_id: str, params: Mapping[str, Any], *, idempotency_key: str | None = None
) -> ResourceT

Update one object.

Parameters:

Name Type Description Default
resource_id str

The object id.

required
params Mapping[str, Any]

Fields to change.

required
idempotency_key str | None

See :meth:create.

None

Returns:

Name Type Description
ResourceT ResourceT

The updated object.

Raises:

Type Description
ValueError

When resource_id is empty, . or ...

StripeObjectMismatchError

When the body's object is not :attr:object_type.

StripeError

When Stripe rejects the request.

delete async

delete(resource_id: str) -> StripeDeleted

Delete one object.

Parameters:

Name Type Description Default
resource_id str

The object id.

required

Returns:

Name Type Description
StripeDeleted StripeDeleted

The id and the tombstone flag.

Raises:

Type Description
ValueError

When resource_id is empty, . or ...

StripeObjectMismatchError

When the body's object is not :attr:object_type — Stripe's tombstone keeps the deleted object's type.

StripeError

When Stripe rejects the request.

list async

list(params: Mapping[str, Any] | None = None) -> StripeList[ResourceT]

Read one page of objects.

Parameters:

Name Type Description Default
params Mapping[str, Any] | None

Query parameters — limit (1-100), starting_after, and the resource's own filters.

None

Returns:

Type Description
StripeList[ResourceT]

StripeList[ResourceT]: The page, with has_more telling you

StripeList[ResourceT]

whether to ask again.

Raises:

Type Description
StripeError

When Stripe rejects the request.

auto_paginate async

auto_paginate(
    params: Mapping[str, Any] | None = None, *, page_size: int = 100
) -> AsyncIterator[ResourceT]

Walk every page, yielding objects one at a time.

Parameters:

Name Type Description Default
params Mapping[str, Any] | None

Filters applied to every page.

None
page_size int

Objects per request. Stripe caps this at 100.

100

Yields:

Name Type Description
ResourceT AsyncIterator[ResourceT]

Each object, newest first, across every page.

Raises:

Type Description
StripeError

When Stripe rejects any of the page requests.

The cursor is the last item's id, not an offset, so pagination stays correct while objects are being created underneath it.

StripeError

StripeError(
    message: str,
    *,
    status_code: int,
    error_type: str = "",
    code: str = "",
    param: str = "",
    decline_code: str = "",
    request_id: str = "",
    payload: Mapping[str, Any] | None = None,
)

Bases: RuntimeError

Raised when Stripe answers with an error payload.

Stripe's error body is a small, stable envelope — error.type, error.code, error.message, and often error.param naming the field at fault. Surfacing those beats an HTTPStatusError whose text the caller has to re-parse.

Attributes:

Name Type Description
status_code int

The HTTP status.

error_type str

Stripe's error.type — card_error, invalid_request_error, api_error, idempotency_error, rate_limit_error.

code str

Stripe's error.code, e.g. card_declined.

param str

The parameter Stripe blames, when it names one.

decline_code str

For a declined card, the issuer's reason.

request_id str

Stripe's request id, the one their support asks for.

payload dict[str, Any]

The whole decoded error body.

Initialize the error.

Parameters:

Name Type Description Default
message str

Stripe's human-readable message.

required
status_code int

The HTTP status.

required
error_type str

Stripe's error.type.

''
code str

Stripe's error.code.

''
param str

The offending parameter, when named.

''
decline_code str

The issuer's decline reason.

''
request_id str

Stripe's request id.

''
payload Mapping[str, Any] | None

The decoded body.

None

StripeObjectMismatchError

StripeObjectMismatchError(
    *,
    expected_object: str,
    received_object: str,
    status_code: int,
    request_id: str = "",
    payload: Mapping[str, Any] | None = None,
)

Bases: StripeError

Raised when a 2xx body is not the kind of object the call asked for.

Every Stripe object carries its type in object ("customer", "payment_intent", "checkout.session"), and a deleted one keeps the same value next to deleted: true. A body whose object is missing or names another type did not come from the endpoint the resource addresses, so validating it into the resource's model would hand the caller another object's data under the wrong type.

Subclasses :class:StripeError, so except StripeError keeps catching it. status_code is the (successful) status the body came with; error_type and code stay empty, since Stripe raised nothing.

Attributes:

Name Type Description
expected_object str

The object value the resource expects.

received_object str

The object value in the body; empty when the key is missing or not a string.

Initialize the error.

Parameters:

Name Type Description Default
expected_object str

The object value the resource expects.

required
received_object str

The object value the body carried.

required
status_code int

The HTTP status of the response.

required
request_id str

Stripe's request id.

''
payload Mapping[str, Any] | None

The decoded body.

None

stripe_http_client

stripe_http_client(
    api_key: str,
    *,
    base_url: str = STRIPE_BASE_URL,
    api_version: str = STRIPE_API_VERSION,
    timeout: float = 30.0,
    retry_policy: RetryPolicy | None = None,
    extra_headers: Mapping[str, str] | None = None,
    transport: AsyncBaseTransport | None = None,
) -> HTTPClient

Build an :class:HTTPClient configured for Stripe.

Parameters:

Name Type Description Default
api_key str

The secret key (sk_live_... / sk_test_...). Sent as a bearer token, which is one of the two schemes the specification declares.

required
base_url str

API host. Override only to point at a proxy or a recorded fixture server.

STRIPE_BASE_URL
api_version str

Value for the Stripe-Version header. Change it deliberately, after checking what the newer version alters.

STRIPE_API_VERSION
timeout float

Total per-request timeout in seconds. Defaults to 30.0 rather than the SDK's usual 10.0: card authorization legitimately takes longer than a database read, and a client-side timeout on a charge leaves the caller not knowing whether money moved.

30.0
retry_policy RetryPolicy | None

Retry behaviour. None keeps the SDK default. Retries are safe on Stripe writes only with an idempotency key, which :class:~tempest_fastapi_sdk.integrations.payment.stripe.StripeClient attaches.

None
extra_headers Mapping[str, str] | None

Additional default headers — Stripe-Account for a Connect platform acting on behalf of a connected account, for instance.

None
transport AsyncBaseTransport | None

Transport override. Pass an httpx.MockTransport to exercise the whole client — headers, encoding and all — without a network call.

None

Returns:

Name Type Description
HTTPClient HTTPClient

A client with authentication, the pinned version and

HTTPClient

JSON accept headers already set.

STRIPE_API_VERSION module-attribute

STRIPE_API_VERSION: str = '2026-07-29.dahlia'

The API version this integration is written against.

Taken from info.version of the vendored specification facts (vendor/stripe-api-facts.yaml), and pinned into the Stripe-Version header of every request. tests/integrations/payment/stripe asserts the two agree, so refreshing the facts without revisiting the code fails a test instead of silently changing response shapes in production.

STRIPE_BASE_URL module-attribute

STRIPE_BASE_URL: str = 'https://api.stripe.com'

servers[0].url from Stripe's OpenAPI specification, without the slash.

There is no separate sandbox host: test mode is selected by the API key (sk_test_...), not by the URL.

to_minor_units

to_minor_units(amount: Decimal | int | float | str, currency: str) -> int

Convert a human amount into the integer Stripe charges.

Parameters:

Name Type Description Default
amount Decimal | int | float | str

The amount in major units — Decimal("10.50"), "10.50", 10.5. A string or a :class:~decimal.Decimal is preferred: binary floats cannot represent every cent exactly.

required
currency str

ISO-4217 code.

required

Returns:

Name Type Description
int int

The amount in the currency's smallest unit, half-up rounded.

Examples:

>>> to_minor_units(Decimal("10.50"), "BRL")
1050
>>> to_minor_units(Decimal("1050"), "JPY")
1050
>>> to_minor_units(Decimal("10.505"), "BHD")
10505

from_minor_units

from_minor_units(amount: int, currency: str) -> Decimal

Convert the integer Stripe reports back into a human amount.

Parameters:

Name Type Description Default
amount int

The amount in the currency's smallest unit, as it appears on a Stripe object.

required
currency str

ISO-4217 code.

required

Returns:

Name Type Description
Decimal Decimal

The amount in major units, exact — never a float, so it

Decimal

can go straight into an invoice or a ledger.

Examples:

>>> from_minor_units(1050, "BRL")
Decimal('10.50')
>>> from_minor_units(1050, "JPY")
Decimal('1050')

currency_exponent

currency_exponent(currency: str) -> int

Return how many decimal places a currency has on Stripe.

Parameters:

Name Type Description Default
currency str

ISO-4217 code, in any case ("BRL", "jpy").

required

Returns:

Name Type Description
int int

0 for a zero-decimal currency, 3 for a three-decimal

int

one, 2 for everything else.

format_amount

format_amount(amount: int, currency: str) -> str

Render a Stripe amount for a human, without a locale library.

Parameters:

Name Type Description Default
amount int

The amount in the currency's smallest unit.

required
currency str

ISO-4217 code.

required

Returns:

Name Type Description
str str

"<value> <CODE>" with the right number of decimals —

str

"10.50 BRL", "1050 JPY". Deliberately not localized: the

str

SDK does not know the reader's locale, and a wrong thousands

str

separator on an invoice is worse than a plain one.

ZERO_DECIMAL_CURRENCIES module-attribute

ZERO_DECIMAL_CURRENCIES: frozenset[str] = frozenset(
    {
        "bif",
        "clp",
        "djf",
        "gnf",
        "jpy",
        "kmf",
        "krw",
        "mga",
        "pyg",
        "rwf",
        "ugx",
        "vnd",
        "vuv",
        "xaf",
        "xof",
        "xpf",
    }
)

Currencies Stripe charges in whole units, with no subunit.

Ported from Stripe's "Zero-decimal currencies" table (https://docs.stripe.com/currencies#zero-decimal). tests pins the set, so an upstream change shows up as a failing test rather than as a hundredfold billing error. Lower-case, because Stripe returns and accepts currency codes in lower case.

THREE_DECIMAL_CURRENCIES module-attribute

THREE_DECIMAL_CURRENCIES: frozenset[str] = frozenset(
    {"bhd", "jod", "kwd", "omr", "tnd"}
)

Currencies with three decimal places rather than two.

Ported from Stripe's "Three-decimal currencies" table. Stripe requires the amount to be a multiple of 10 for these — the API rounds to the nearest ten itself, but building the value correctly here keeps the rounding visible to the caller instead of surprising them on the invoice.

verify_signature

verify_signature(
    body: bytes,
    header: str,
    secret: str,
    *,
    tolerance_seconds: int = DEFAULT_TOLERANCE_SECONDS,
    now: float | None = None,
) -> bool

Check a Stripe delivery against the endpoint's signing secret.

Parameters:

Name Type Description Default
body bytes

The raw request body, exactly as received. Any re-serialization changes the bytes and breaks the signature.

required
header str

The Stripe-Signature header value.

required
secret str

The endpoint signing secret (whsec_...).

required
tolerance_seconds int

Reject deliveries whose timestamp is further than this from now. 0 disables the window, which also disables replay protection.

DEFAULT_TOLERANCE_SECONDS
now float | None

Current epoch seconds. Injectable so tests pin time instead of sleeping.

None

Returns:

Name Type Description
bool bool

True when secret is non-empty, the timestamp is inside

bool

the window and at least one v1 signature matches, compared in

bool

constant time. An empty or blank secret always returns False.

The HMAC covers f"{t}.{body}", not the body — this is the documented Stripe scheme and the single most common mistake in a hand-rolled verification.

sign_payload

sign_payload(body: bytes, secret: str, *, timestamp: int) -> str

Build the header Stripe would send for a body.

Parameters:

Name Type Description Default
body bytes

The raw body to sign.

required
secret str

The endpoint signing secret.

required
timestamp int

Epoch seconds to stamp the delivery with.

required

Returns:

Name Type Description
str str

A Stripe-Signature header value.

Shipped rather than left to each test suite: writing this by hand is exactly where the f"{t}.{body}" detail gets re-derived wrong, and a test that signs the wrong thing passes against a verifier that checks the wrong thing.

parse_event

parse_event(body: bytes) -> StripeWebhookEvent

Decode a verified body into a typed event.

Parameters:

Name Type Description Default
body bytes

The raw, already-verified body.

required

Returns:

Name Type Description
StripeWebhookEvent StripeWebhookEvent

The parsed delivery. A body that is not JSON

StripeWebhookEvent

yields an event with empty fields rather than raising — it

StripeWebhookEvent

verified, so it came from Stripe, and discarding a delivery the

StripeWebhookEvent

provider considers sent is worse than handling an empty one.

parse_signature_header

parse_signature_header(header: str) -> tuple[int | None, tuple[str, ...]]

Split a Stripe-Signature header into timestamp and signatures.

Parameters:

Name Type Description Default
header str

The raw header value.

required

Returns:

Type Description
int | None

tuple[int | None, tuple[str, ...]]: The t value as an integer

tuple[str, ...]

(None when absent or unparseable) and every v1 signature.

tuple[int | None, tuple[str, ...]]

There can be more than one during a secret rotation, and accepting

tuple[int | None, tuple[str, ...]]

any of them is what makes rotation possible without dropping

tuple[int | None, tuple[str, ...]]

deliveries.

make_stripe_webhook_dependency

make_stripe_webhook_dependency(
    secret: str,
    *,
    tolerance_seconds: int = DEFAULT_TOLERANCE_SECONDS,
    error_message: str = "Invalid Stripe webhook signature",
) -> Callable[..., Coroutine[Any, Any, StripeWebhookEvent]]

Build a FastAPI dependency yielding a verified, parsed event.

Parameters:

Name Type Description Default
secret str

The endpoint signing secret (whsec_...). It is per endpoint, not per account: a service with a test and a live endpoint has two.

required
tolerance_seconds int

Replay window, in seconds.

DEFAULT_TOLERANCE_SECONDS
error_message str

Message on the raised :class:UnauthorizedException.

'Invalid Stripe webhook signature'

Returns:

Type Description
Callable[..., Coroutine[Any, Any, StripeWebhookEvent]]

Callable[..., Coroutine[Any, Any, StripeWebhookEvent]]: An async

Callable[..., Coroutine[Any, Any, StripeWebhookEvent]]

dependency returning a :class:StripeWebhookEvent.

Raises:

Type Description
ValueError

When secret is empty or only whitespace, so an unset STRIPE_WEBHOOK_SECRET fails at boot instead of serving an endpoint that verifies against an empty key.

UnauthorizedException

Raised by the returned dependency when the header is missing, malformed, outside the tolerance window, or signed with another secret.

An unknown event type does not fail the request: Stripe adds event types continuously, and a service that 500s on one it has never seen turns their release into its own outage. The type is kept as event_type with event left None.

StripeWebhookEvent dataclass

StripeWebhookEvent(
    event_type: str,
    event: StripeEvent | None = None,
    event_id: str = "",
    payload: dict[str, Any] = dict(),
    data_object: dict[str, Any] = dict(),
    body: bytes = b"",
)

A verified Stripe webhook delivery.

A dataclass rather than a :class:BaseSchema: this is the value a route receives, not a wire DTO. BaseSchema sets use_enum_values=True, which would store :attr:event as a bare str — and then delivery.event is StripeEvent.PAYMENT_INTENT_SUCCEEDED is silently always false.

Attributes:

Name Type Description
event_type str

The type field exactly as delivered, kept even when this SDK release does not know it.

event StripeEvent | None

The parsed event, or None for a type added after this release.

event_id str

Stripe's evt_... id. Use it to deduplicate: Stripe retries a delivery until you answer 2xx, so the same event id arrives more than once by design.

payload dict[str, Any]

The whole decoded body.

data_object dict[str, Any]

data.object — the resource the event is about, which is what handlers actually read.

body bytes

The raw body, byte-for-byte, for logging or a second verification.

StripeObject

Bases: BaseModel

Base for every Stripe resource.

Attributes:

Name Type Description
id str

The object id (cus_, pi_, sub_, …).

object str

Stripe's own type discriminator ("customer", "payment_intent", …), useful when a field can hold more than one kind of object.

livemode bool

Whether the object belongs to live mode.

metadata dict[str, str]

The key/value map Stripe stores verbatim. String-to-string, because that is all Stripe keeps.

StripeCustomer

Bases: StripeObject

A customer.

Attributes:

Name Type Description
email str | None

Billing email.

name str | None

Full name.

phone str | None

Phone number.

description str | None

Free-form internal description.

currency str | None

Default currency for invoices.

created int | None

Creation time, epoch seconds.

StripePaymentIntent

Bases: StripeObject

A payment intent — the object a card charge actually is.

Attributes:

Name Type Description
amount int

Amount in the currency's smallest unit. Convert with :func:~tempest_fastapi_sdk.integrations.payment.stripe.from_minor_units, never by dividing by 100 — some currencies have no subunit.

amount_received int

How much has been captured so far.

currency str

Lower-case ISO-4217 code.

status str

requires_payment_method, requires_action, processing, succeeded, canceled, …

client_secret str | None

The value the frontend confirms with. Treat it as a credential: it authorizes confirming this payment, so it belongs in the response to its own customer and nowhere else — not in a log line.

customer str | None

Customer id, or the expanded object in model_extra when expand asked for it.

payment_method str | None

Payment method id.

latest_charge str | None

Charge id, once there is one.

created int | None

Creation time, epoch seconds.

StripeRefund

Bases: StripeObject

A refund.

Attributes:

Name Type Description
amount int

Refunded amount in the smallest unit.

currency str

Lower-case ISO-4217 code.

status str

pending, succeeded, failed, canceled.

reason str | None

duplicate, fraudulent, requested_by_customer, or None.

payment_intent str | None

The payment being refunded.

charge str | None

The charge being refunded.

created int | None

Creation time, epoch seconds.

StripeProduct

Bases: StripeObject

A product — what is being sold, independent of what it costs.

Attributes:

Name Type Description
name str

Display name.

description str | None

Product description.

active bool

Whether it can be used in new purchases.

default_price str | None

Price id, when one is set.

created int | None

Creation time, epoch seconds.

StripePrice

Bases: StripeObject

A price — how much a product costs, and how often.

Attributes:

Name Type Description
product str

Product id.

active bool

Whether the price can be used.

currency str

Lower-case ISO-4217 code.

unit_amount int | None

Amount in the smallest unit. None for a tiered price, where the amount depends on quantity.

recurring dict[str, Any] | None

{"interval": "month", …} for a subscription price, None for a one-off.

nickname str | None

Internal label.

created int | None

Creation time, epoch seconds.

StripeSubscription

Bases: StripeObject

A subscription.

Attributes:

Name Type Description
customer str

Customer id.

status str

trialing, active, past_due, canceled, incomplete, incomplete_expired, unpaid, paused.

currency str

Lower-case ISO-4217 code.

cancel_at_period_end bool

Whether it stops at the end of the current period instead of renewing.

canceled_at int | None

When it was canceled, epoch seconds.

latest_invoice str | None

Invoice id, when there is one.

created int | None

Creation time, epoch seconds.

items dict[str, Any] | None

The subscription items list, as Stripe returns it.

StripeInvoice

Bases: StripeObject

An invoice.

Attributes:

Name Type Description
customer str | None

Customer id.

subscription str | None

Subscription id, for a recurring invoice.

status str

draft, open, paid, uncollectible, void.

currency str

Lower-case ISO-4217 code.

amount_due int

Amount still owed, smallest unit.

amount_paid int

Amount already paid, smallest unit.

total int

Invoice total, smallest unit.

hosted_invoice_url str | None

Stripe-hosted payment page.

created int | None

Creation time, epoch seconds.

StripeCheckoutSession

Bases: StripeObject

A Checkout session — the hosted payment page.

Attributes:

Name Type Description
url str | None

Where to send the customer. None once the session is completed or expired.

status str

open, complete, expired.

payment_status str

paid, unpaid, no_payment_required.

mode str

payment, setup or subscription.

amount_total int | None

Total in the smallest unit.

currency str | None

Lower-case ISO-4217 code.

customer str | None

Customer id, when one is attached.

payment_intent str | None

Payment intent id, in payment mode.

subscription str | None

Subscription id, in subscription mode.

expires_at int | None

When the session stops accepting payment.

StripeEventObject

Bases: StripeObject

An event, as read back from /v1/events.

The webhook path has its own type (:class:~tempest_fastapi_sdk.integrations.payment.stripe.StripeWebhookEvent), which also carries the verified raw body. This one is what a poll of the events endpoint returns.

Attributes:

Name Type Description
type str

The event type, e.g. "payment_intent.succeeded".

api_version str | None

The API version the payload is rendered in — not necessarily the one you pinned.

created int | None

Creation time, epoch seconds.

data dict[str, Any]

{"object": {...}}, the resource the event is about.

StripeDeleted

Bases: BaseModel

What a delete returns: the id and a tombstone flag.

Attributes:

Name Type Description
id str

The deleted object's id.

object str

Stripe's type discriminator.

deleted bool

Always True on a successful delete.

StripeList

Bases: BaseModel, Generic[ResourceT]

One page of a Stripe list response.

Stripe paginates by cursor, not by page number: ask for the next page with starting_after=<id of the last item>. :meth:~tempest_fastapi_sdk.integrations.payment.stripe.StripeResource.auto_paginate does that walk for you.

Attributes:

Name Type Description
object str

Always "list".

data list[ResourceT]

The page's items, newest first.

has_more bool

Whether another page exists after this one.

url str

The endpoint this page came from.

StripeEvent

Bases: BaseStrEnum

A Stripe webhook event type.

Members are named after the event string with dots and dashes turned into underscores, upper-cased. Use :meth:BaseStrEnum.from_value to parse a delivery, and :meth:BaseStrEnum.has_value to tell a known event from one Stripe added after this SDK release.