Skip to content

StripeObject id attribute returns whole object #1516

Open
@suel2000

Description

@suel2000

Describe the bug

The id attribute on StripeObject instances, like an instance of the Subscription object, when accessed, doesn't return a str containing the id, but instead a copy of the whole object.

To Reproduce

  1. Set up a webhook on a customer.subscription.created event

  2. in webhook:

    >>> event = stripe.Webhook.construct_event(request.body(), sig_header, <Secret>)
    >>> subscription = stripe.Subscription(event["data"]["object"])
    >>> subscription.id
    <Subscription subscription id=sub_....>

Expected behavior

  1. Set up a webhook on a customer.subscription.created event

  2. in webhook:

    >>> event = stripe.Webhook.construct_event(request.body(), sig_header, <Secret>)
    >>> subscription = stripe.Subscription(event["data"]["object"])
    >>> subscription.id
    "sub_..."

Code snippets

OS

Docker

Language version

Python 3.11

Library version

stripe-python 12.1.0

API version

2025-04-30

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions