Capture emaill when the license is default or invalid (#4998)

Stripe checkout captures email if the license is the default or invalid.
This commit is contained in:
ConnorYoh
2025-11-25 14:33:19 +00:00
committed by GitHub
parent a8db2fda18
commit 2ab7945130
4 changed files with 56 additions and 24 deletions

View File

@@ -88,8 +88,13 @@ const AdminPlanSection: React.FC = () => {
const handleManageClick = useCallback(async () => {
try {
// Only allow PRO or ENTERPRISE licenses to access billing portal
if (!licenseInfo?.licenseType || licenseInfo.licenseType === 'NORMAL') {
throw new Error('No valid license found. Please purchase a license before accessing the billing portal.');
}
if (!licenseInfo?.licenseKey) {
throw new Error('No license key found. Please activate a license first.');
throw new Error('License key missing. Please contact support.');
}
// Create billing portal session with license key

View File

@@ -159,13 +159,14 @@ const StripeCheckout: React.FC<StripeCheckoutProps> = ({
const checkExistingLicense = async () => {
try {
const licenseInfo = await licenseService.getLicenseInfo();
if (licenseInfo && licenseInfo.licenseKey) {
// Has existing license - skip email stage
console.log('Existing license detected - skipping email stage');
checkoutState.setCurrentLicenseKey(licenseInfo.licenseKey);
// Only skip email if license is PRO or ENTERPRISE (not NORMAL/free tier)
if (licenseInfo?.licenseType && licenseInfo.licenseType !== 'NORMAL') {
// Has valid premium license - skip email stage
console.log('Valid premium license detected - skipping email stage');
checkoutState.setCurrentLicenseKey(licenseInfo.licenseKey || null);
checkoutState.setState({ currentStage: 'plan-selection', loading: false });
} else {
// No license - start at email stage
// No valid premium license - start at email stage
checkoutState.setState({ currentStage: 'email', loading: false });
}
} catch (error) {

View File

@@ -42,13 +42,14 @@ export const useCheckoutSession = (
}
// Fetch current license key for upgrades
// Only include if it's a valid PRO/ENTERPRISE license (not NORMAL/free tier)
let existingLicenseKey: string | undefined;
try {
const licenseInfo = await licenseService.getLicenseInfo();
if (licenseInfo && licenseInfo.licenseKey) {
if (licenseInfo?.licenseType && licenseInfo.licenseType !== 'NORMAL' && licenseInfo.licenseKey) {
existingLicenseKey = licenseInfo.licenseKey;
setCurrentLicenseKey(existingLicenseKey);
console.log('Found existing license for upgrade');
console.log('Found existing valid license for upgrade');
}
} catch (error) {
console.warn('Could not fetch license info, proceeding as new license:', error);