stripe-node icon indicating copy to clipboard operation
stripe-node copied to clipboard

Bug with node stripe types when creating a new token

Open seblemeur opened this issue 6 years ago • 1 comments

Hi, we use stripe types from https://www.npmjs.com/package/@types/stripe and we need to create a new stripe token for updating document verification in account, we do :

        return stripe.tokens
            .create({
                account: {
                    individual: {
                        verification: {
                            document: {
                                back: identityCard
                            }
                        }
                    },
                }
            })
            .then((token) => {
                return token;
            })

But we have this error : No overload matches this call. Overload 1 of 6, '(data: ICardTokenCreationOptions, response?: IResponseFn<ICardToken>): Promise<ICardToken>', gave the following error. Argument of type '{ account: { individual: { verification: { document: { back: any; }; }; }; }; }' is not assignable to parameter of type 'ICardTokenCreationOptions'. Object literal may only specify known properties, and 'account' does not exist in type 'ICardTokenCreationOptions'. Overload 2 of 6, '(data: IBankAccountTokenCreationOptions, response?: IResponseFn<IBankAccountToken>): Promise<IBankAccountToken>', gave the following error. Argument of type '{ account: { individual: { verification: { document: { back: any; }; }; }; }; }' is not assignable to parameter of type 'IBankAccountTokenCreationOptions'. Object literal may only specify known properties, and 'account' does not exist in type 'IBankAccountTokenCreationOptions'. Overload 3 of 6, '(data: IPiiTokenCreationOptions, response?: IResponseFn<IToken>): Promise<IToken>', gave the following error. Argument of type '{ account: { individual: { verification: { document: { back: any; }; }; }; }; }' is not assignable to parameter of type 'IPiiTokenCreationOptions'.

Any help ? Thanks

seblemeur avatar Jan 30 '20 15:01 seblemeur

@seblemeur The types in DefinitelyTyped are maintained by the owners of the library itself and not Stripe. Some of those types are incomplete or incorrect and it seems they don't support this one properly.

We recently shipped Typescript definitions in our library though that are automatically generated from our API spec, like our library. You can use those as of 8.0.1 as documented [here|https://github.com/stripe/stripe-node#usage-with-typescript].

On our end, we don't support those either today. The reason is that this call should never be made server-side. Account Tokens were built to collect connected account's information securely client-side with Stripe.js. If you have the information server-side, where you use stripe-node, then you should send this information directly in the API and not through a token.

remi-stripe avatar Jan 30 '20 16:01 remi-stripe