Environment Modes
Polar operates in different environment modes:Production
Live environment with real payments and customer data.API Base URL:
https://api.polar.shSandbox
Test environment with simulated payments for safe testing.API Base URL:
https://sandbox.polar.sh (same as production during testing)The sandbox environment uses the same API endpoints as production. The key difference is in the Stripe configuration and organization settings, not the API URL.
How Sandbox Mode Works
Sandbox mode is configured at the organization level, not through a separate API endpoint:-
Stripe Test Mode: Organizations in sandbox use Stripe’s test mode, which means:
- No real money is processed
- You can use Stripe test card numbers
- Webhooks are triggered with test data
-
Isolated Data: Each organization’s sandbox data is isolated:
- Separate customers, subscriptions, and orders
- Test payments don’t affect production metrics
- Safe to experiment with any API operations
-
Same API: Use the same API endpoints and SDKs:
- Authentication works the same way
- All API features are available
- Webhooks function identically
Setting Up Sandbox Testing
Configure Stripe test mode
Connect your organization to Stripe using test mode credentials:
- Use Stripe test API keys
- Configure test webhook endpoints
- All payments will use Stripe’s test environment
Get API credentials
Generate an Organization Access Token or Personal Access Token for your test organization.
Test Payment Methods
When your organization is connected to Stripe in test mode, you can use Stripe’s test card numbers:Successful Payments
Successful Payments
Failed Payments
Failed Payments
3D Secure Authentication
3D Secure Authentication
Special Scenarios
Special Scenarios
Testing Subscriptions
Test the complete subscription lifecycle in sandbox mode:Testing Webhooks
Webhooks work the same way in sandbox mode:Set up local webhook endpoint
Use a tool like ngrok or localtunnel to expose your local server:
Test events
Trigger events by performing actions in your sandbox organization:
- Create a customer
- Start a subscription
- Process a test payment
- Cancel a subscription
For more details on webhook setup and testing, see our Webhooks documentation.
Testing Customer State
Verify customer entitlements and subscriptions using the Customer State API:Testing Usage-Based Billing
Test meters and event ingestion in sandbox mode:Common Test Scenarios
New Customer Onboarding
New Customer Onboarding
- Create a test customer
- Create a checkout session
- Use a test card to complete payment
- Verify subscription activation
- Check webhook delivery
- Query customer state
Subscription Lifecycle
Subscription Lifecycle
- Create active subscription
- Test usage tracking (if applicable)
- Simulate subscription renewal
- Test subscription cancellation
- Verify cancellation webhooks
- Check benefit revocation
Payment Failures
Payment Failures
- Create subscription with failing card
- Observe payment failure webhooks
- Test payment retry logic
- Update payment method
- Verify successful retry
Upgrades & Downgrades
Upgrades & Downgrades
- Create subscription on lower tier
- Upgrade to higher tier mid-cycle
- Verify prorated billing
- Check updated benefits
- Test downgrade scenario
SDK Configuration for Testing
Configure your SDKs to use test credentials:Debugging Tips
Check Stripe Dashboard
View test payments and events in your Stripe test dashboard to verify payment processing.
Monitor Webhooks
Use the webhook logs in Polar dashboard to see delivery status and payloads.
API Logs
Enable detailed logging in your application to track API requests and responses.
Network Inspector
Use browser dev tools or tools like Postman to inspect API calls.
Moving to Production
When ready to go live:Complete Polar account review
Ensure your production organization is approved by Polar’s compliance team.
Connect production Stripe account
Switch from Stripe test mode to live mode in your organization settings.
Deploy with production tokens
Update your application environment variables with production credentials.
Next Steps
Authentication
Learn about API authentication methods
Customer State
Check customer entitlements and subscriptions
Webhooks
Set up real-time event notifications
API Reference
Explore the complete API documentation