Skip to content

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

@chladnefazole

Description

@chladnefazole

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions