Enhance application structure: Add runtime configuration for environment variables, integrate new dependencies for Cloudinary and UI components, and refactor member management features including improved forms and member dashboard. Update styles and layout for better user experience.

This commit is contained in:
Jennie Robinson Faber 2025-08-27 16:49:51 +01:00
parent 6e7e27ac4e
commit e4a0a9ab0f
61 changed files with 7902 additions and 950 deletions

140
server/utils/helcim.js Normal file
View file

@ -0,0 +1,140 @@
// Helcim Payment Integration Utilities
export const processHelcimPayment = async (paymentData) => {
const { amount, paymentToken, customerData } = paymentData;
// Check if Helcim is configured
const helcimAccountId = process.env.HELCIM_ACCOUNT_ID;
const helcimApiToken = process.env.HELCIM_API_TOKEN;
if (!helcimAccountId || !helcimApiToken) {
console.warn('Helcim not configured - skipping payment processing');
return {
success: false,
message: 'Payment processing not configured',
testMode: true
};
}
try {
// In production, you would make API calls to Helcim here
// Example structure:
const response = await fetch('https://api.helcim.com/v2/payment/purchase', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-token': helcimApiToken,
'account-id': helcimAccountId
},
body: JSON.stringify({
amount,
currency: 'CAD',
paymentToken,
customerCode: customerData.email,
contactName: customerData.name,
billingAddress: {
contactName: customerData.name,
email: customerData.email
}
})
});
const result = await response.json();
return {
success: result.success || false,
transactionId: result.transactionId,
customerId: result.customerCode,
message: result.message
};
} catch (error) {
console.error('Helcim payment error:', error);
return {
success: false,
message: error.message || 'Payment processing failed'
};
}
};
export const createHelcimSubscription = async (subscriptionData) => {
const { customerId, planId, amount } = subscriptionData;
const helcimAccountId = process.env.HELCIM_ACCOUNT_ID;
const helcimApiToken = process.env.HELCIM_API_TOKEN;
if (!helcimAccountId || !helcimApiToken) {
console.warn('Helcim not configured - skipping subscription creation');
return {
success: false,
message: 'Subscription processing not configured',
testMode: true
};
}
try {
// Create recurring payment plan
const response = await fetch('https://api.helcim.com/v2/payment/plan', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-token': helcimApiToken,
'account-id': helcimAccountId
},
body: JSON.stringify({
customerCode: customerId,
planName: `Ghost Guild ${planId}`,
amount,
currency: 'CAD',
frequency: 'MONTHLY',
startDate: new Date().toISOString().split('T')[0]
})
});
const result = await response.json();
return {
success: result.success || false,
subscriptionId: result.planId,
message: result.message
};
} catch (error) {
console.error('Helcim subscription error:', error);
return {
success: false,
message: error.message || 'Subscription creation failed'
};
}
};
export const cancelHelcimSubscription = async (subscriptionId) => {
const helcimApiToken = process.env.HELCIM_API_TOKEN;
if (!helcimApiToken) {
return {
success: false,
message: 'Subscription management not configured'
};
}
try {
const response = await fetch(`https://api.helcim.com/v2/payment/plan/${subscriptionId}/cancel`, {
method: 'POST',
headers: {
'api-token': helcimApiToken
}
});
const result = await response.json();
return {
success: result.success || false,
message: result.message
};
} catch (error) {
console.error('Helcim cancellation error:', error);
return {
success: false,
message: error.message || 'Subscription cancellation failed'
};
}
};