Implement multi-step registration process: Add step indicators, error handling, and payment processing for membership registration. Enhance form validation and user feedback with success and error messages. Refactor state management for improved clarity and maintainability.
This commit is contained in:
parent
a88aa62198
commit
2ca290d6e0
22 changed files with 1994 additions and 213 deletions
77
server/api/helcim/test-subscription.get.js
Normal file
77
server/api/helcim/test-subscription.get.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
// Test minimal subscription creation to understand required fields
|
||||
const HELCIM_API_BASE = 'https://api.helcim.com/v2'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const config = useRuntimeConfig(event)
|
||||
const helcimToken = config.public.helcimToken || process.env.NUXT_PUBLIC_HELCIM_TOKEN
|
||||
|
||||
// Generate a 25-character idempotency key
|
||||
const idempotencyKey = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`.substring(0, 25)
|
||||
|
||||
// Test with minimal fields first
|
||||
const testRequest1 = {
|
||||
customerCode: 'CST1020', // Use a recent customer code
|
||||
planId: 20162
|
||||
}
|
||||
|
||||
console.log('Testing subscription with minimal fields:', testRequest1)
|
||||
|
||||
try {
|
||||
const response1 = await fetch(`${HELCIM_API_BASE}/subscriptions`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
'content-type': 'application/json',
|
||||
'api-token': helcimToken,
|
||||
'idempotency-key': idempotencyKey + 'a'
|
||||
},
|
||||
body: JSON.stringify(testRequest1)
|
||||
})
|
||||
|
||||
const result1 = await response1.text()
|
||||
console.log('Test 1 - Status:', response1.status)
|
||||
console.log('Test 1 - Response:', result1)
|
||||
|
||||
if (!response1.ok) {
|
||||
// Try with paymentPlanId instead
|
||||
const testRequest2 = {
|
||||
customerCode: 'CST1020',
|
||||
paymentPlanId: 20162
|
||||
}
|
||||
|
||||
console.log('Testing subscription with paymentPlanId:', testRequest2)
|
||||
|
||||
const response2 = await fetch(`${HELCIM_API_BASE}/subscriptions`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
'content-type': 'application/json',
|
||||
'api-token': helcimToken,
|
||||
'idempotency-key': idempotencyKey + 'b'
|
||||
},
|
||||
body: JSON.stringify(testRequest2)
|
||||
})
|
||||
|
||||
const result2 = await response2.text()
|
||||
console.log('Test 2 - Status:', response2.status)
|
||||
console.log('Test 2 - Response:', result2)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Test error:', error)
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'Check server logs for test results'
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in test endpoint:', error)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: error.message
|
||||
})
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue