stripe / stripe-node

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

Stripe docs are a mistake #2191

Closed andrecasal closed 5 hours ago

andrecasal commented 5 hours ago

Describe the bug

I didn't see a docs repo, so I'm guessing this is the right place for this. Please correct me if I'm wrong.

The subscription_pause key doesn't seem to be part of the feature object.

The TS typings also don't exist for it.

Screenshot 2024-09-27 at 20 25 10

To Reproduce

Notice the error with this code:

import { type PlanId } from '../plans'

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
    apiVersion: '2024-06-20',
    typescript: true,
})

type BillingPortalProducts = {
    product: PlanId
    prices: string[]
}

export async function configureStripeCustomerPortal(
    products: BillingPortalProducts[],
) {
    if (!products)
        throw new Error(
            'Missing required parameters to configure Stripe Customer Portal.',
        )

    return stripe.billingPortal.configurations.create({
        business_profile: {
            headline: 'Organization Name - Customer Portal',
        },
        features: {
            customer_update: {
                enabled: true,
                allowed_updates: ['address', 'shipping', 'tax_id', 'email'],
            },
            invoice_history: { enabled: true },
            payment_method_update: { enabled: true },
            subscription_cancel: { enabled: true },
            subscription_pause: { // 👈 Error here 
                enabled: false
            },
            subscription_update: {
                enabled: true,
                default_allowed_updates: ['price'],
                proration_behavior: 'always_invoice',
                products: products.filter(({ product }) => product !== 'free'),
            },
        },
    })
}

Expected behavior

No TS error.

Code snippets

No response

OS

macOS

Node version

v20.11.0

Library version

stripe-node 16.12.0

API version

2024-06-20

Additional context

No response

remi-stripe commented 5 hours ago

@andrecasal Thanks for the report! I'll flag internally to get this fixed! I'll close this issue as this isn't really a bug with our SDK itself but I'll make sure this gets resolved!

andrecasal commented 5 hours ago

Alright, thanks!