portal, platform, and server fixes

This commit is contained in:
Timur Gordon
2025-06-30 17:01:40 +02:00
parent 1c96fa4087
commit a5b46bffb1
59 changed files with 9158 additions and 1057 deletions

View File

@@ -68,8 +68,10 @@
let elements;
let paymentElement;
// Stripe publishable key - replace with your actual key from Stripe Dashboard
// Configuration - replace with your actual keys
const STRIPE_PUBLISHABLE_KEY = 'pk_test_51MCkZTC7LG8OeRdIcqmmoDkRwDObXSwYdChprMHJYoD2VRO8OCDBV5KtegLI0tLFXJo9yyvEXi7jzk1NAB5owj8i00DkYSaV9y';
// Note: API key authentication is now handled by Rust code
// Initialize Stripe when the script loads
document.addEventListener('DOMContentLoaded', function() {
@@ -84,74 +86,7 @@
}
});
// Create payment intent on server (supports both company and resident registration)
window.createPaymentIntent = async function(formDataJson) {
console.log('💳 Creating payment intent...');
try {
// Parse the JSON string from Rust
let formData;
if (typeof formDataJson === 'string') {
formData = JSON.parse(formDataJson);
} else {
formData = formDataJson;
}
// Determine endpoint based on registration type
const isResidentRegistration = formData.type === 'resident_registration';
const endpoint = isResidentRegistration
? 'http://127.0.0.1:3001/resident/create-payment-intent'
: 'http://127.0.0.1:3001/company/create-payment-intent';
console.log('📋 Registration type:', isResidentRegistration ? 'Resident' : 'Company');
console.log('🔧 Server endpoint:', endpoint);
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData)
});
console.log('📡 Server response status:', response.status);
if (!response.ok) {
const errorText = await response.text();
console.error('❌ Payment intent creation failed:', errorText);
let errorData;
try {
errorData = JSON.parse(errorText);
} catch (e) {
errorData = { error: errorText };
}
const errorMsg = errorData.error || 'Failed to create payment intent';
console.error('💥 Error details:', errorData);
throw new Error(errorMsg);
}
const responseData = await response.json();
console.log('✅ Payment intent created successfully');
console.log('🔑 Client secret received:', responseData.client_secret ? 'Yes' : 'No');
const { client_secret } = responseData;
if (!client_secret) {
throw new Error('No client secret received from server');
}
return client_secret;
} catch (error) {
console.error('❌ Payment intent creation error:', error.message);
console.error('🔧 Troubleshooting:');
console.error(' 1. Check if server is running on port 3001');
console.error(' 2. Verify Stripe API keys in .env file');
console.error(' 3. Check server logs for detailed error info');
throw error;
}
};
// Note: Payment intent creation is now handled by Rust code in multi_step_resident_wizard.rs
// Initialize Stripe Elements with client secret
window.initializeStripeElements = async function(clientSecret) {