From 4f9b01d11aa43a6011811ce45f6a0115f4c94028 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlovskyi Date: Tue, 26 Sep 2023 17:19:09 +0300 Subject: [PATCH] feat: add flag to line item on subscription update (#17) --- libs/stripe/package.json | 2 +- libs/stripe/src/lib/dto/update-subscription.dto.ts | 9 +++++++++ libs/stripe/src/lib/stripe.service.ts | 8 +++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/stripe/package.json b/libs/stripe/package.json index 84aec99..78d2c5b 100644 --- a/libs/stripe/package.json +++ b/libs/stripe/package.json @@ -1,6 +1,6 @@ { "name": "@valor/nestjs-stripe", - "version": "0.0.11", + "version": "0.0.12", "type": "commonjs", "private": false, "author": "opavlovskyi-valor-software", diff --git a/libs/stripe/src/lib/dto/update-subscription.dto.ts b/libs/stripe/src/lib/dto/update-subscription.dto.ts index 1346d84..2ae7927 100644 --- a/libs/stripe/src/lib/dto/update-subscription.dto.ts +++ b/libs/stripe/src/lib/dto/update-subscription.dto.ts @@ -60,6 +60,15 @@ export class SubscriptionUpdateItemDto { @IsOptional() @IsPositive() quantity?: number; + + @ApiPropertyOptional() + @IsOptional() + deleted?: boolean; + + @ApiPropertyOptional() + @IsOptional() + @IsString() + metadata?: Stripe.MetadataParam; } export class SubscriptionUpdateBillingThresholdsDto { diff --git a/libs/stripe/src/lib/stripe.service.ts b/libs/stripe/src/lib/stripe.service.ts index 2468ecc..508edeb 100644 --- a/libs/stripe/src/lib/stripe.service.ts +++ b/libs/stripe/src/lib/stripe.service.ts @@ -749,8 +749,10 @@ export class StripeService { id: i.id, price: i.priceId, plan: i.planId, - quantity: i.quantity - })), + quantity: i.quantity, + deleted: i.deleted, + metadata: i.metadata, + } as Stripe.SubscriptionUpdateParams.Item)), add_invoice_items: dto.addInvoiceItems?.map(i => ({ price: i.priceId, quantity:i.quantity, @@ -1356,7 +1358,7 @@ export class StripeService { //#endregion //#region Test Clocks - async createTestClock(frozenTime: number = Date.now(), name = ''): Promise> { + async createTestClock(frozenTime: number, name = ''): Promise> { try { const testClock = await this.stripe.testHelpers.testClocks.create({ name,