1.7 KiB
1.7 KiB
Helcim Integration - Issues Fixed
Problem
The API was returning 401 Unauthorized when trying to create customers.
Root Cause
The runtime config wasn't properly accessing the Helcim token in server-side endpoints.
Solution Applied
1. Fixed Runtime Config Access
Updated all server endpoints to:
- Pass the
eventparameter touseRuntimeConfig(event) - Fallback to
process.env.NUXT_PUBLIC_HELCIM_TOKENif config doesn't load
2. Files Updated
/server/api/helcim/customer.post.js/server/api/helcim/subscription.post.js/server/api/helcim/verify-payment.post.js/server/api/helcim/test-connection.get.js
3. Fixed Import Path
Created /server/config/contributions.js to re-export the contributions config for server-side imports.
4. Verified Token Works
Created test-helcim-direct.js which successfully:
- Connected to Helcim API
- Created a test customer (ID: 32854583, Code: CST1000)
Testing Instructions
-
Restart your development server:
npm run dev -
Test the connection:
curl http://localhost:3000/api/helcim/test-connection -
Try the signup flow at
/join
Important Notes
- The token in your
.envfile is working correctly - The Helcim API is accessible and responding
- Customer creation is functional when called directly
- The issue was specifically with how Nuxt's runtime config was being accessed in server endpoints
Next Steps
Once you confirm the signup flow works:
- Test with different contribution tiers
- Verify payment capture with test cards
- Check that subscriptions are created correctly
- Consider adding webhook endpoints for subscription events