mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-03-04 02:20:19 +01:00
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:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user