2.9 KiB
2.9 KiB
Clavitor Admin - Local Development (Paddle Sandbox)
Quick Start
1. Get Sandbox API Key
- Go to https://sandbox-vendors.paddle.com
- Log in (create account if needed)
- Go to Developer Tools > Authentication
- Create API Key (server-side) - copy this
- Create Client Token (client-side) - copy this too
2. Set API Key
Edit admin/sync.go:
const DefaultAPIKey = "pdl_sandbox_apikey_..." // Your sandbox API key
3. Set Client Token
Edit admin/static/checkout.html:
const PADDLE_CLIENT_TOKEN = 'pdl_sandbox_clienttoken_...'; // Your sandbox client token
4. Create Products in Sandbox
- Go to https://sandbox-vendors.paddle.com
- Catalog > Products
- Create products:
- Clavitor Personal - $12/year
- Clavitor Family - $29/year
- Clavitor Pro - $49/year
- Copy the Price IDs (look like
pri_01xxx)
5. Update Price IDs
Edit admin/paddle_checkout.go:
var PriceIDs = map[string]string{
"personal_yearly_usd": "pri_01xxxxxx", // Replace with actual
"family_yearly_usd": "pri_02xxxxxx",
"pro_yearly_usd": "pri_03xxxxxx",
}
6. Run Admin Locally
cd /home/johan/dev/clavitor/clavitor.ai/admin
go run main.go
7. Test Checkout
- Go to http://localhost:8080/static/checkout.html
- Select a plan
- Enter email
- Click "Subscribe Now"
- Use Paddle's test card:
4242 4242 4242 4242- Any future expiry date
- Any 3-digit CVC
- Payment succeeds in sandbox
- Check webhook delivered to your local endpoint
Sandbox vs Production
| Sandbox | Production | |
|---|---|---|
| URL | sandbox-api.paddle.com | api.paddle.com |
| Money | Fake | Real |
| Cards | Test cards only | Real cards |
| Webhooks | Same format | Same format |
Webhook Testing
Paddle webhooks need to reach your local machine. Use one of:
- ngrok:
ngrok http 8080→ gives you public URL - localtunnel:
lt --port 8080 - Set webhook URL in Paddle to your tunnel URL +
/webhooks/paddle
Environment Variables (Alternative)
Instead of editing code, use env vars:
export PADDLE_API_KEY="pdl_sandbox_apikey_..."
export PADDLE_CLIENT_TOKEN="pdl_sandbox_clienttoken_..."
export PADDLE_SANDBOX="true"
go run main.go
Troubleshooting
"Invalid API key": You're using production key in sandbox (or vice versa)
"Product not found": Price ID is from wrong environment
"Client token invalid": Token expired or wrong environment
"Checkout doesn't open": Check browser console for JavaScript errors
Switching to Production
When ready for real payments:
- Get production API key from https://vendors.paddle.com
- Change
environment: 'sandbox'to'production'in checkout.html - Change sandbox URLs to production in sync.go
- Use real Price IDs from production dashboard
- Test with small real payment first