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/orange-doors-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/localizations': minor
'@clerk/clerk-js': patch
'@clerk/types': minor
---

Improve invalid plan change callout for monthly-only plans
2 changes: 1 addition & 1 deletion integration/tests/pricing-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withBilling] })('pricing tabl
page
.locator('.cl-checkout-root')
.getByText(
'You cannot subscribe to this plan by paying monthly. To subscribe to this plan, you need to choose to pay annually',
'You cannot subscribe to this plan by paying monthly. To subscribe to this plan, you need to choose to pay annually.',
),
).toBeVisible();

Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{ "path": "./dist/waitlist*.js", "maxSize": "1.5KB" },
{ "path": "./dist/keylessPrompt*.js", "maxSize": "6.5KB" },
{ "path": "./dist/pricingTable*.js", "maxSize": "4.02KB" },
{ "path": "./dist/checkout*.js", "maxSize": "8.4KB" },
{ "path": "./dist/checkout*.js", "maxSize": "8.45KB" },
{ "path": "./dist/up-billing-page*.js", "maxSize": "3.0KB" },
{ "path": "./dist/op-billing-page*.js", "maxSize": "3.0KB" },
{ "path": "./dist/up-plans-page*.js", "maxSize": "1.0KB" },
Expand Down
11 changes: 10 additions & 1 deletion packages/clerk-js/src/ui/components/Checkout/parts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export const InvalidPlanScreen = () => {
return _error?.meta?.plan;
}, [error]);

const isPlanUpgradePossible = useMemo(() => {
const _error = error?.errors.find(e => e.code === 'invalid_plan_change');
return _error?.meta?.isPlanUpgradePossible || false;
}, [error]);

if (!planFromError) {
return null;
}
Expand Down Expand Up @@ -85,7 +90,11 @@ export const InvalidPlanScreen = () => {
<Alert
variant='info'
colorScheme='info'
title={localizationKeys('commerce.cannotSubscribeMonthly')}
title={
isPlanUpgradePossible
? localizationKeys('commerce.cannotSubscribeMonthly')
: localizationKeys('commerce.cannotSubscribeUnrecoverable')
}
/>
</Box>
</Flex>
Expand Down
2 changes: 2 additions & 0 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export const enUS: LocalizationResource = {
cancelSubscriptionTitle: 'Cancel {{plan}} Subscription?',
cannotSubscribeMonthly:
'You cannot subscribe to this plan by paying monthly. To subscribe to this plan, you need to choose to pay annually.',
cannotSubscribeUnrecoverable:
'You cannot subscribe to this plan. Your existing subscription is more expensive than this plan.',
checkout: {
description__paymentSuccessful: 'Your payment was successful.',
description__subscriptionSuccessful: 'Your new subscription is all set.',
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export function parseError(error: ClerkAPIErrorJSON): ClerkAPIError {
identifiers: error?.meta?.identifiers,
zxcvbn: error?.meta?.zxcvbn,
plan: error?.meta?.plan,
isPlanUpgradePossible: error?.meta?.is_plan_upgrade_possible,
},
};
}
Expand All @@ -188,6 +189,7 @@ export function errorToJSON(error: ClerkAPIError | null): ClerkAPIErrorJSON {
identifiers: error?.meta?.identifiers,
zxcvbn: error?.meta?.zxcvbn,
plan: error?.meta?.plan,
is_plan_upgrade_possible: error?.meta?.isPlanUpgradePossible,
},
};
}
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface ClerkAPIError {
id: string;
name: string;
};
isPlanUpgradePossible?: boolean;
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/types/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ export interface ClerkAPIErrorJSON {
id: string;
name: string;
};
is_plan_upgrade_possible?: boolean;
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/types/src/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export type __internal_LocalizationResource = {
monthly: LocalizationValue;
annually: LocalizationValue;
cannotSubscribeMonthly: LocalizationValue;
cannotSubscribeUnrecoverable: LocalizationValue;
pricingTable: {
billingCycle: LocalizationValue;
included: LocalizationValue;
Expand Down
Loading