From ace9b392edd4f2ddeb19e12f3ba10fa3d080ebfd Mon Sep 17 00:00:00 2001 From: panteliselef Date: Fri, 17 Oct 2025 14:37:35 +0300 Subject: [PATCH] chore(clerk-js,types): Remove `paymentMethodId` from subscription item --- .changeset/good-buckets-cry.md | 6 ++++++ .../src/core/resources/BillingSubscription.ts | 2 -- .../PricingTable/__tests__/PricingTable.test.tsx | 4 ---- .../PricingTable/utils/pricing-footer-state.spec.ts | 1 - .../__tests__/SubscriptionDetails.test.tsx | 13 ------------- .../__tests__/SubscriptionsList.test.tsx | 6 ------ packages/types/src/billing.ts | 5 ----- packages/types/src/json.ts | 1 - 8 files changed, 6 insertions(+), 32 deletions(-) create mode 100644 .changeset/good-buckets-cry.md diff --git a/.changeset/good-buckets-cry.md b/.changeset/good-buckets-cry.md new file mode 100644 index 00000000000..7483018062b --- /dev/null +++ b/.changeset/good-buckets-cry.md @@ -0,0 +1,6 @@ +--- +'@clerk/clerk-js': minor +'@clerk/types': minor +--- + +[Billing Beta]: Dropping `paymentMethodId` from subscription item. diff --git a/packages/clerk-js/src/core/resources/BillingSubscription.ts b/packages/clerk-js/src/core/resources/BillingSubscription.ts index 1e0a9f9c846..3c9e973336f 100644 --- a/packages/clerk-js/src/core/resources/BillingSubscription.ts +++ b/packages/clerk-js/src/core/resources/BillingSubscription.ts @@ -60,7 +60,6 @@ export class BillingSubscription extends BaseResource implements BillingSubscrip export class BillingSubscriptionItem extends BaseResource implements BillingSubscriptionItemResource { id!: string; - paymentMethodId!: string; plan!: BillingPlan; planPeriod!: BillingSubscriptionPlanPeriod; status!: BillingSubscriptionStatus; @@ -87,7 +86,6 @@ export class BillingSubscriptionItem extends BaseResource implements BillingSubs } this.id = data.id; - this.paymentMethodId = data.payment_method_id; this.plan = new BillingPlan(data.plan); this.planPeriod = data.plan_period; this.status = data.status; diff --git a/packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx b/packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx index 1d6790a80c9..7c01dee15ff 100644 --- a/packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx +++ b/packages/clerk-js/src/ui/components/PricingTable/__tests__/PricingTable.test.tsx @@ -68,7 +68,6 @@ describe('PricingTable - trial info', () => { id: 'si_1', plan: trialPlan, createdAt: new Date('2021-01-01'), - paymentMethodId: 'src_1', pastDueAt: null, canceledAt: null, periodStart: new Date('2021-01-01'), @@ -213,7 +212,6 @@ describe('PricingTable - trial info', () => { id: 'si_1', plan: nonTrialPlan, createdAt: new Date('2021-01-01'), - paymentMethodId: 'src_1', pastDueAt: null, canceledAt: null, periodStart: new Date('2021-02-01'), @@ -332,7 +330,6 @@ describe('PricingTable - plans visibility', () => { id: 'si_active', plan: testPlan, createdAt: new Date('2021-01-01'), - paymentMethodId: 'src_1', pastDueAt: null, canceledAt: null, periodStart: new Date('2021-01-01'), @@ -458,7 +455,6 @@ describe('PricingTable - plans visibility', () => { id: 'si_active', plan: testPlan, createdAt: new Date('2021-01-01'), - paymentMethodId: 'src_1', pastDueAt: null, canceledAt: null, periodStart: new Date('2021-01-01'), diff --git a/packages/clerk-js/src/ui/components/PricingTable/utils/pricing-footer-state.spec.ts b/packages/clerk-js/src/ui/components/PricingTable/utils/pricing-footer-state.spec.ts index 34259ce6ed7..16fec2236be 100644 --- a/packages/clerk-js/src/ui/components/PricingTable/utils/pricing-footer-state.spec.ts +++ b/packages/clerk-js/src/ui/components/PricingTable/utils/pricing-footer-state.spec.ts @@ -30,7 +30,6 @@ const makeSub = (overrides: Partial): BillingSu planPeriod: 'month', status: 'active', createdAt: new Date('2021-01-01'), - paymentMethodId: 'src_1', pastDueAt: null, periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-01-31'), diff --git a/packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx b/packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx index c8770d18a58..bb0dbffce26 100644 --- a/packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx +++ b/packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx @@ -85,7 +85,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_123', planPeriod: 'month', status: 'active', }, @@ -189,7 +188,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2022-01-01'), canceledAt: null, - paymentMethodId: 'src_123', planPeriod: 'annual' as const, status: 'active' as const, }, @@ -285,7 +283,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_123', planPeriod: 'month' as const, status: 'active' as const, }, @@ -414,7 +411,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2022-01-01'), canceledAt: new Date('2021-04-01'), - paymentMethodId: 'src_annual', planPeriod: 'annual' as const, status: 'active' as const, }, @@ -425,7 +421,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2022-02-01'), periodEnd: new Date('2022-03-01'), canceledAt: null, - paymentMethodId: 'src_monthly', planPeriod: 'month' as const, status: 'upcoming' as const, }, @@ -568,7 +563,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: new Date('2021-01-03'), - paymentMethodId: 'src_free_active', planPeriod: 'month' as const, status: 'active' as const, }, @@ -578,7 +572,6 @@ describe('SubscriptionDetails', () => { createdAt: new Date('2021-01-03'), periodStart: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_free_upcoming', planPeriod: 'month' as const, status: 'upcoming' as const, }, @@ -675,7 +668,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_123', planPeriod: 'month' as const, status: 'active' as const, cancel: cancelSubscriptionMock, @@ -774,7 +766,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2022-01-01'), canceledAt: new Date('2021-04-01'), - paymentMethodId: 'src_annual', planPeriod: 'annual' as const, status: 'active' as const, cancel: vi.fn(), @@ -875,7 +866,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2022-01-01'), canceledAt: null, - paymentMethodId: 'src_annual', planPeriod: 'annual' as const, status: 'active' as const, cancel: vi.fn(), @@ -993,7 +983,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_123', planPeriod: 'month' as const, status: 'past_due' as const, pastDueAt: new Date('2021-01-15'), @@ -1077,7 +1066,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_123', planPeriod: 'month', status: 'active', isFreeTrial: true, @@ -1188,7 +1176,6 @@ describe('SubscriptionDetails', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_123', planPeriod: 'month', status: 'active', isFreeTrial: true, diff --git a/packages/clerk-js/src/ui/components/Subscriptions/__tests__/SubscriptionsList.test.tsx b/packages/clerk-js/src/ui/components/Subscriptions/__tests__/SubscriptionsList.test.tsx index 4813d6f7704..75940db1673 100644 --- a/packages/clerk-js/src/ui/components/Subscriptions/__tests__/SubscriptionsList.test.tsx +++ b/packages/clerk-js/src/ui/components/Subscriptions/__tests__/SubscriptionsList.test.tsx @@ -91,7 +91,6 @@ describe('SubscriptionsList', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-01-15'), canceledAt: null, - paymentMethodId: 'src_free', planPeriod: 'month' as const, isFreeTrial: false, pastDueAt: null, @@ -156,7 +155,6 @@ describe('SubscriptionsList', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-01-15'), canceledAt: null, - paymentMethodId: 'src_trial', planPeriod: 'month' as const, status: 'active' as const, isFreeTrial: true, // This subscription is in a free trial @@ -220,7 +218,6 @@ describe('SubscriptionsList', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_past_due', planPeriod: 'month' as const, status: 'past_due' as const, isFreeTrial: false, @@ -285,7 +282,6 @@ describe('SubscriptionsList', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: null, - paymentMethodId: 'src_active', planPeriod: 'month' as const, status: 'active' as const, isFreeTrial: false, @@ -349,7 +345,6 @@ describe('SubscriptionsList', () => { periodStart: new Date('2021-02-01'), periodEnd: new Date('2021-03-01'), canceledAt: null, - paymentMethodId: 'src_upcoming', planPeriod: 'month' as const, status: 'upcoming' as const, isFreeTrial: false, @@ -385,7 +380,6 @@ describe('SubscriptionsList', () => { periodStart: new Date('2021-01-01'), periodEnd: new Date('2021-02-01'), canceledAt: new Date('2021-01-15'), - paymentMethodId: 'src_active_canceled', planPeriod: 'month' as const, status: 'active' as const, isFreeTrial: false, diff --git a/packages/types/src/billing.ts b/packages/types/src/billing.ts index 139511c38be..9f97a66df45 100644 --- a/packages/types/src/billing.ts +++ b/packages/types/src/billing.ts @@ -491,11 +491,6 @@ export interface BillingSubscriptionItemResource extends ClerkResource { * The unique identifier for the subscription item. */ id: string; - /** - * The unique identifier for the payment method being used for the subscription item. - */ - //TODO(@COMMERCE): should this be nullable ? - paymentMethodId: string; /** * The plan associated with the subscription item. */ diff --git a/packages/types/src/json.ts b/packages/types/src/json.ts index 4a71431fb0a..aff67668362 100644 --- a/packages/types/src/json.ts +++ b/packages/types/src/json.ts @@ -730,7 +730,6 @@ export interface BillingSubscriptionItemJSON extends ClerkResourceJSON { credit?: { amount: BillingMoneyAmountJSON; }; - payment_method_id: string; plan: BillingPlanJSON; plan_period: BillingSubscriptionPlanPeriod; status: BillingSubscriptionStatus;