环境: NodeJS
语言:打字稿
我正在尝试将税率添加到我的 InvoiceItems,但似乎 Stripe 包不遵循 API 文档。
这是我的代码:
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
});
文档说有一个tax_rates
字段可用,但该字段不在 Stripe 包中。
触发错误:
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'
InvoiceItemCreationOptions
在模块 Stripe (index.d.ts)中看到的可用字段:
amount?: number;
currency: string;
customer: string;
description?: string;
discountable?: boolean;
invoice?: string;
quantity?: number;
subscription?: string;
unit_amount?: number;
我当前的 Stripe 模块版本是 7.13.19(最新版本来自npm i @types/stripe
)
文档是错误的还是我做错了?