stripe / stripe-node

Node.js library for the Stripe API.
https://stripe.com
MIT License
3.9k stars 755 forks source link

`plan` is missing on `Stripe.Subscription` type #2139

Closed jlengstorf closed 4 months ago

jlengstorf commented 4 months ago

Describe the bug

The Stripe.Subscription type does not match the data returned from stripe.subscriptions.retrieve().

To Reproduce

import Stripe from 'stripe';

const stripe = new Stripe(import.meta.env.STRIPE_SECRET_KEY!);

// ... in a function
const subscription = await stripe.subscriptions.retrieve(subscriptionId);
const productId = subscription.plan.product;
/*                             ^^^^
                               TS error that plan doesn't exist on 
                               Stripe.Subscription, but it exists */

Expected behavior

The plan data is present, so the type should reflect that.

Code snippets

No response

OS

macOS

Node version

Node v22.1.0

Library version

stripe-node@^16.2.0

API version

n/a

Additional context

No response

remi-stripe commented 4 months ago

Hey @jlengstorf! The top-level plan and quantity properties on Subscription have been deprecated for many years. We recommend using items.data[0][price] instead. See my long explanation on a past issue here: https://github.com/stripe/stripe-node/issues/1794