0

Environment : NodeJS

Language : Typescript

I am trying to add Tax Rates to my InvoiceItems, but it seems that the Stripe package does not follow the API doc.

Here is my code :

newInvoiceItem = await this.stripe.invoiceItems.create({
        customer: billingUser.billingData.customerID,
        currency: this.settings.currency.toLocaleLowerCase(),
        amount: Math.round(transaction.stop.roundedPrice * 100),
        description: description,
        tax_rates: defaultTax
      }, {
        idempotency_key: idemPotencyKey.keyNewInvoiceItem
      });

Documentation says a tax_rates field is available, but this field isn't in Stripe package.

Triggered error:

TS2769: No overload matches this call. 
Overload 1 of 2, '(data: InvoiceItemCreationOptions, options: HeaderOptions, response?: IResponseFn<InvoiceItem>): Promise<InvoiceItem>', gave the following error.     Argument of type '{ customer: string; currency: string; amount: number; description: string; tax_rates: ITaxRate; }' is not assignable to parameter of type 'InvoiceItemCreationOptions'.       Object literal may only specify known properties, and 'tax_rates' does not exist in type 'InvoiceItemCreationOptions'.   
Overload 2 of 2, '(data: InvoiceItemCreationOptions, response?: IResponseFn<InvoiceItem>): Promise<InvoiceItem>', gave the following error.     Argument of type '{ customer: string; currency: string; amount: number; description: string; tax_rates: ITaxRate; }' is not assignable to parameter of type 'InvoiceItemCreationOptions'.       Object literal may only specify known properties, and 'tax_rates' does not exist in type 'InvoiceItemCreationOptions'

Available fields in InvoiceItemCreationOptions seen in module Stripe (index.d.ts):

amount?: number;
currency: string;
customer: string;
description?: string;
discountable?: boolean;
invoice?: string;
quantity?: number;
subscription?: string;
unit_amount?: number;

My current Stripe module version is 7.13.19 (latest version from npm i @types/stripe)

Is the documentation erroneous or am I doing wrong ?

Ninjeneer
  • 76
  • 2
  • 6
  • 1
    `@types/stripe` is community maintained TS definitions on Stripe API which might not be up to date with latest Stripe API. Stripe frequently updates its API with new features. However, Stripe team is working on an official definition now matching the latest API version. – wsw Dec 31 '19 at 09:32
  • Thanks for the information. Is it possible to use the JS version in my TS project ? – Ninjeneer Dec 31 '19 at 09:34
  • definitely you can use stripe-node in your TypeScript project. – wsw Jan 03 '20 at 07:39

0 Answers0