Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create customer portal session with flow subscription_update - property 'subscription_update' does not exist in type 'FlowData' #2197

Open
chladnefazole opened this issue Oct 2, 2024 · 1 comment
Assignees
Labels

Comments

@chladnefazole
Copy link

chladnefazole commented Oct 2, 2024

Describe the bug

TS complains about missing property 'subscription_update' on interface FlowData

To Reproduce

I want customers to be able to upgrade their subscriptions, so I followed the docs to create a portal session: https://docs.stripe.com/api/customer_portal/sessions/create

I try to call the function like this:

                Stripe.billingPortal.sessions.create({
                    customer: req.session.user.customerId,
                    return_url: `${domain}account/${req.session.user.id}`,
                    flow_data: {
                        type: 'subscription_update' as stripe.BillingPortal.SessionCreateParams.FlowData.Type,
                        subscription_update: {
                            subscription: stripeSubscriptionId,
                        }
                    }
                }).then((stripeSession) => {
                    res.redirect(303, stripeSession.url);
                });

But I get a TS error:
image

And in the FlowData interface I can see there is no property 'subscription_update':
image

I can get around the error by declaring the flow data object separately, but it's messier than passing the object in directly:

                const flow_data = {
                    type: 'subscription_update' as stripe.BillingPortal.SessionCreateParams.FlowData.Type,
                    subscription_update: {
                        subscription: stripeSubscriptionId,
                    }
                };
                Stripe.billingPortal.sessions.create({
                    customer: req.session.user.customerId,
                    return_url: `${domain}account/${req.session.user.id}`,
                    flow_data
                }).then((stripeSession) => {
                    res.redirect(303, stripeSession.url);
                });

Expected behavior

Property 'subscription_update' should exist on interface FlowData.

Code snippets

No response

OS

Windows 11

Node version

v20.11.0

Library version

1.21.6

API version

2024-09-30.acacia

Additional context

No response

@remi-stripe remi-stripe self-assigned this Oct 2, 2024
@remi-stripe
Copy link
Contributor

@chladnefazole I looked at the code and I see it defined here as expected.
You said you are on the SDK version 1.21.6 which doesn't make sense as it was years before we added Typescript support. But my guess is that you are either using external types or you are on a version of stripe-node that is too old and predates the addition of that feature in the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants