feat(billing): add missing payment methods and configurations

- Added migration to include global payment method configurations for Stripe and PayPal (both disabled).
- Ensured existing payment methods like bank transfer and manual payment are correctly configured.
- Added database constraints and indexes for improved data integrity in billing models.
- Introduced foreign key relationship between CreditTransaction and Payment models.
- Added webhook configuration fields to PaymentMethodConfig for future payment gateway integrations.
- Updated SignUpFormUnified component to handle payment method selection based on user country and plan.
- Implemented PaymentHistory component to display user's payment history with status indicators.
This commit is contained in:
IGNY8 VPS (Salman)
2025-12-09 06:14:44 +00:00
parent 72d0b6b0fd
commit 4d13a57068
36 changed files with 4159 additions and 253 deletions

View File

@@ -233,8 +233,45 @@ export const useAuthStore = create<AuthState>()(
const tokens = responseData.tokens || {};
const userData = responseData.user || data.user;
const newToken = tokens.access || responseData.access || data.access || null;
const newRefreshToken = tokens.refresh || responseData.refresh || data.refresh || null;
// Extract tokens with multiple fallbacks
// Response format: { success: true, data: { user: {...}, tokens: { access, refresh } } }
const newToken =
tokens.access ||
responseData.access ||
data.access ||
data.data?.tokens?.access ||
data.tokens?.access ||
null;
const newRefreshToken =
tokens.refresh ||
responseData.refresh ||
data.refresh ||
data.data?.tokens?.refresh ||
data.tokens?.refresh ||
null;
console.log('Registration response parsed:', {
hasUserData: !!userData,
hasAccessToken: !!newToken,
hasRefreshToken: !!newRefreshToken,
userEmail: userData?.email,
accountId: userData?.account?.id,
tokensLocation: tokens.access ? 'tokens.access' :
responseData.access ? 'responseData.access' :
data.data?.tokens?.access ? 'data.data.tokens.access' : 'not found'
});
if (!newToken || !userData) {
console.error('Registration succeeded but missing critical data:', {
token: newToken,
user: userData,
fullResponse: data,
parsedTokens: tokens,
parsedResponseData: responseData
});
throw new Error('Registration completed but authentication failed. Please try logging in.');
}
// CRITICAL: Set auth state AND immediately persist to localStorage
// This prevents race conditions where navigation happens before persist
@@ -268,8 +305,11 @@ export const useAuthStore = create<AuthState>()(
if (newRefreshToken) {
localStorage.setItem('refresh_token', newRefreshToken);
}
console.log('Auth state persisted to localStorage successfully');
} catch (e) {
console.warn('Failed to persist auth state to localStorage:', e);
console.error('CRITICAL: Failed to persist auth state to localStorage:', e);
throw new Error('Failed to save login session. Please try again.');
}
// Return user data for success handling