From aecf64302f3579084885acbe69e7b7a0fcee8ab1 Mon Sep 17 00:00:00 2001 From: Keiran Flanigan Date: Tue, 8 Jul 2025 15:34:05 -0700 Subject: [PATCH 1/3] chore(clerk-js,types): Use `subscription_items` on commerce payments responses --- .changeset/short-stars-start.md | 4 ++++ .../src/core/resources/CommercePayment.ts | 2 -- .../ui/components/Statements/StatementPage.tsx | 16 ++++++++-------- packages/types/src/commerce.ts | 1 - 4 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 .changeset/short-stars-start.md diff --git a/.changeset/short-stars-start.md b/.changeset/short-stars-start.md new file mode 100644 index 00000000000..13a1f200d7e --- /dev/null +++ b/.changeset/short-stars-start.md @@ -0,0 +1,4 @@ +--- +'@clerk/clerk-js': patch +'@clerk/types': patch +--- diff --git a/packages/clerk-js/src/core/resources/CommercePayment.ts b/packages/clerk-js/src/core/resources/CommercePayment.ts index d299130799a..e59d6012857 100644 --- a/packages/clerk-js/src/core/resources/CommercePayment.ts +++ b/packages/clerk-js/src/core/resources/CommercePayment.ts @@ -17,7 +17,6 @@ export class CommercePayment extends BaseResource implements CommercePaymentReso paidAt?: Date; updatedAt!: Date; paymentSource!: CommercePaymentSource; - subscription!: CommerceSubscription; subscriptionItem!: CommerceSubscription; chargeType!: CommercePaymentChargeType; status!: CommercePaymentStatus; @@ -38,7 +37,6 @@ export class CommercePayment extends BaseResource implements CommercePaymentReso this.failedAt = data.failed_at ? unixEpochToDate(data.failed_at) : undefined; this.updatedAt = unixEpochToDate(data.updated_at); this.paymentSource = new CommercePaymentSource(data.payment_source); - this.subscription = new CommerceSubscription(data.subscription); this.subscriptionItem = new CommerceSubscription(data.subscription_item); this.chargeType = data.charge_type; this.status = data.status; diff --git a/packages/clerk-js/src/ui/components/Statements/StatementPage.tsx b/packages/clerk-js/src/ui/components/Statements/StatementPage.tsx index e473576376d..31d7ce85901 100644 --- a/packages/clerk-js/src/ui/components/Statements/StatementPage.tsx +++ b/packages/clerk-js/src/ui/components/Statements/StatementPage.tsx @@ -67,8 +67,8 @@ export const StatementPage = () => { {group.items.map(item => ( @@ -78,15 +78,15 @@ export const StatementPage = () => { ? localizationKeys( `${localizationRoot}.billingPage.statementsSection.itemCaption__paidForPlan`, { - plan: item.subscription.plan.name, - period: item.subscription.planPeriod, + plan: item.subscriptionItem.plan.name, + period: item.subscriptionItem.planPeriod, }, ) : localizationKeys( `${localizationRoot}.billingPage.statementsSection.itemCaption__subscribedAndPaidForPlan`, { - plan: item.subscription.plan.name, - period: item.subscription.planPeriod, + plan: item.subscriptionItem.plan.name, + period: item.subscriptionItem.planPeriod, }, ) } @@ -95,12 +95,12 @@ export const StatementPage = () => { valueTruncated valueCopyable /> - {item.subscription.credit && item.subscription.credit.amount.amount > 0 ? ( + {item.subscriptionItem.credit && item.subscriptionItem.credit.amount.amount > 0 ? ( ) : null} diff --git a/packages/types/src/commerce.ts b/packages/types/src/commerce.ts index e8d36d86573..be9275aa7b4 100644 --- a/packages/types/src/commerce.ts +++ b/packages/types/src/commerce.ts @@ -137,7 +137,6 @@ export interface CommercePaymentResource extends ClerkResource { failedAt?: Date; updatedAt: Date; paymentSource: CommercePaymentSourceResource; - subscription: CommerceSubscriptionResource; subscriptionItem: CommerceSubscriptionResource; chargeType: CommercePaymentChargeType; status: CommercePaymentStatus; From 2220f7495b7cea787722c81c77bfe662ce66b913 Mon Sep 17 00:00:00 2001 From: Keiran Flanigan Date: Thu, 10 Jul 2025 10:42:04 -0700 Subject: [PATCH 2/3] add back payment.subscription to avoid breaking --- packages/clerk-js/src/core/resources/CommercePayment.ts | 2 ++ packages/types/src/commerce.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/clerk-js/src/core/resources/CommercePayment.ts b/packages/clerk-js/src/core/resources/CommercePayment.ts index e59d6012857..d299130799a 100644 --- a/packages/clerk-js/src/core/resources/CommercePayment.ts +++ b/packages/clerk-js/src/core/resources/CommercePayment.ts @@ -17,6 +17,7 @@ export class CommercePayment extends BaseResource implements CommercePaymentReso paidAt?: Date; updatedAt!: Date; paymentSource!: CommercePaymentSource; + subscription!: CommerceSubscription; subscriptionItem!: CommerceSubscription; chargeType!: CommercePaymentChargeType; status!: CommercePaymentStatus; @@ -37,6 +38,7 @@ export class CommercePayment extends BaseResource implements CommercePaymentReso this.failedAt = data.failed_at ? unixEpochToDate(data.failed_at) : undefined; this.updatedAt = unixEpochToDate(data.updated_at); this.paymentSource = new CommercePaymentSource(data.payment_source); + this.subscription = new CommerceSubscription(data.subscription); this.subscriptionItem = new CommerceSubscription(data.subscription_item); this.chargeType = data.charge_type; this.status = data.status; diff --git a/packages/types/src/commerce.ts b/packages/types/src/commerce.ts index be9275aa7b4..3952a558436 100644 --- a/packages/types/src/commerce.ts +++ b/packages/types/src/commerce.ts @@ -138,6 +138,7 @@ export interface CommercePaymentResource extends ClerkResource { updatedAt: Date; paymentSource: CommercePaymentSourceResource; subscriptionItem: CommerceSubscriptionResource; + subscription: CommerceSubscriptionResource; chargeType: CommercePaymentChargeType; status: CommercePaymentStatus; } From 442a296a310cab023cbe19af0fc5258654a4a4cc Mon Sep 17 00:00:00 2001 From: Keiran Flanigan Date: Mon, 14 Jul 2025 09:34:49 -0700 Subject: [PATCH 3/3] changeset --- .changeset/short-stars-start.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.changeset/short-stars-start.md b/.changeset/short-stars-start.md index 13a1f200d7e..a49ba48448f 100644 --- a/.changeset/short-stars-start.md +++ b/.changeset/short-stars-start.md @@ -1,4 +1,2 @@ --- -'@clerk/clerk-js': patch -'@clerk/types': patch ---- +--- \ No newline at end of file