saving payment data

This commit is contained in:
2025-06-24 12:08:13 +02:00
parent 782be6bd38
commit d7f5809771
4 changed files with 314 additions and 2 deletions

View File

@@ -2599,6 +2599,32 @@ async function checkStackExists(stackName) {
// Add new function to deploy stack
async function deployStack(dockerComposeContent, stackName, port) {
try {
// Get the launch data from sessionStorage to access pricing tier info
const launchData = JSON.parse(sessionStorage.getItem('instanceLaunchData'));
// Fetch the pricing tier details to get the actual quota values
let pricingTierDetails = null;
if (launchData?.pricingTier?.id) {
try {
const pricingResponse = await fetch(`/api/admin/pricing-plans/${launchData.pricingTier.id}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
}
});
if (pricingResponse.ok) {
const pricingData = await pricingResponse.json();
if (pricingData.success) {
pricingTierDetails = pricingData.plan;
}
}
} catch (error) {
console.warn('Failed to fetch pricing tier details:', error);
}
}
// First, attempt to deploy the stack
const response = await fetch('/api/admin/deploy-stack', {
method: 'POST',
@@ -2633,6 +2659,35 @@ async function deployStack(dockerComposeContent, stackName, port) {
{
name: 'DEPLOYED_AT',
value: new Date().toISOString()
},
// Pricing tier environment variables with actual quota values
{
name: 'PRICING_TIER_ID',
value: launchData?.pricingTier?.id?.toString() || '0'
},
{
name: 'PRICING_TIER_NAME',
value: launchData?.pricingTier?.name || 'Unknown'
},
{
name: 'ROOM_QUOTA',
value: pricingTierDetails?.room_quota?.toString() || '0'
},
{
name: 'CONVERSATION_QUOTA',
value: pricingTierDetails?.conversation_quota?.toString() || '0'
},
{
name: 'STORAGE_QUOTA_GB',
value: pricingTierDetails?.storage_quota_gb?.toString() || '0'
},
{
name: 'MANAGER_QUOTA',
value: pricingTierDetails?.manager_quota?.toString() || '0'
},
{
name: 'ADMIN_QUOTA',
value: pricingTierDetails?.admin_quota?.toString() || '0'
}
]
})