Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/twenty-monkeys-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@clerk/clerk-js": patch
"@clerk/types": patch
---

Fix the "Plan starts at" date when a user downgrades from a paid plan to the free plan

12 changes: 3 additions & 9 deletions packages/clerk-js/src/core/resources/CommerceCheckout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ import type {
} from '@clerk/types';

import { commerceTotalsFromJSON } from '../../utils';
import {
BaseResource,
CommercePaymentSource,
CommercePlan,
CommerceSubscription,
isClerkAPIResponseError,
} from './internal';
import { BaseResource, CommercePaymentSource, CommercePlan, isClerkAPIResponseError } from './internal';

export class CommerceCheckout extends BaseResource implements CommerceCheckoutResource {
id!: string;
Expand All @@ -24,8 +18,8 @@ export class CommerceCheckout extends BaseResource implements CommerceCheckoutRe
paymentSource?: CommercePaymentSource;
plan!: CommercePlan;
planPeriod!: CommerceSubscriptionPlanPeriod;
planPeriodStart!: number | undefined;
status!: string;
subscription?: CommerceSubscription;
totals!: CommerceCheckoutTotals;
isImmediatePlanChange!: boolean;

Expand All @@ -47,8 +41,8 @@ export class CommerceCheckout extends BaseResource implements CommerceCheckoutRe
this.paymentSource = data.payment_source ? new CommercePaymentSource(data.payment_source) : undefined;
this.plan = new CommercePlan(data.plan);
this.planPeriod = data.plan_period;
this.planPeriodStart = data.plan_period_start;
this.status = data.status;
this.subscription = data.subscription ? new CommerceSubscription(data.subscription) : undefined;
this.totals = commerceTotalsFromJSON(data.totals);
this.isImmediatePlanChange = data.is_immediate_plan_change;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ export const CheckoutComplete = ({
? `${capitalize(checkout.paymentSource.paymentMethod)}`
: `${capitalize(checkout.paymentSource.cardType)} ⋯ ${checkout.paymentSource.last4}`
: '–'
: checkout.subscription?.periodStart
? formatDate(new Date(checkout.subscription.periodStart))
: checkout.planPeriodStart
? formatDate(new Date(checkout.planPeriodStart))
: '–'
}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/commerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ export interface CommerceCheckoutResource extends ClerkResource {
paymentSource?: CommercePaymentSourceResource;
plan: CommercePlanResource;
planPeriod: CommerceSubscriptionPlanPeriod;
planPeriodStart?: number;
status: string;
totals: CommerceCheckoutTotals;
subscription?: CommerceSubscriptionResource;
confirm: (params: ConfirmCheckoutParams) => Promise<CommerceCheckoutResource>;
isImmediatePlanChange: boolean;
}
2 changes: 1 addition & 1 deletion packages/types/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ export interface CommerceCheckoutJSON extends ClerkResourceJSON {
payment_source?: CommercePaymentSourceJSON;
plan: CommercePlanJSON;
plan_period: CommerceSubscriptionPlanPeriod;
plan_period_start?: number;
status: string;
subscription?: CommerceSubscriptionJSON;
totals: CommerceCheckoutTotalsJSON;
is_immediate_plan_change: boolean;
}