Test Mode allows you to build and test your Creem integration in a completely isolated environment. All API calls, payments, webhooks, and data are kept separate from your production environment, ensuring you can develop with confidence.
Always develop and test your integration in Test Mode before going live. This prevents accidental
charges and allows you to verify your entire payment flow safely.
Activating Test Mode
To switch to the test environment, click the Test Mode toggle at the bottom of the left sidebar.
Using Test Mode in Code
When building your integration, you’ll need to configure your code to use Test Mode. Here’s how to do it across different SDKs:
Next.js
TypeScript SDK
Better Auth
REST API
Use the testMode parameter when creating checkouts: // app/api/checkout/route.ts
import { Checkout } from "@creem_io/nextjs" ;
export const GET = Checkout ({
apiKey: process . env . CREEM_API_KEY ! ,
testMode: true , // Enable test mode
defaultSuccessUrl: "/success" ,
});
For production, use an environment variable: export const GET = Checkout ({
apiKey: process . env . CREEM_API_KEY ! ,
testMode: process . env . NODE_ENV !== "production" ,
defaultSuccessUrl: "/success" ,
});
Enable test mode when initializing the SDK: import { Creem } from "creem" ;
const creem = new Creem ({
apiKey: process . env . CREEM_API_KEY ! ,
server: "test" , // Enable test mode
});
const checkout = await creem . checkouts . create ({
productId: "prod_abc123" ,
successUrl: "https://yoursite.com/success" ,
});
For production, omit server; production is the default: const creem = new Creem ({
apiKey: process . env . CREEM_API_KEY ! ,
});
Configure test mode in your auth setup: // auth.ts
import { betterAuth } from "better-auth" ;
import { creem } from "@creem_io/better-auth" ;
export const auth = betterAuth ({
database: {
// your database config
},
plugins: [
creem ({
apiKey: process . env . CREEM_API_KEY ! ,
testMode: true , // Enable test mode
}),
],
});
When using the REST API directly, use the test API endpoint: # Test Mode
curl -X POST https://test-api.creem.io/v1/checkouts \
-H "x-api-key: YOUR_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"product_id": "prod_YOUR_PRODUCT_ID",
"success_url": "https://yoursite.com/success"
}'
# Production Mode
curl -X POST https://api.creem.io/v1/checkouts \
-H "x-api-key: YOUR_PRODUCTION_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"product_id": "prod_YOUR_PRODUCT_ID",
"success_url": "https://yoursite.com/success"
}'
API Endpoints
Creem uses separate API endpoints for test and production environments:
Environment Base URL Production https://api.creem.ioTest Mode https://test-api.creem.io
Make sure to use the correct API endpoint for your environment. Using the production endpoint with
test mode enabled (or vice versa) will result in errors.
API Keys
Test and production environments use different API keys. You can find both keys in the Developers section . Make sure to toggle Test Mode in the bottom of the left sidebar.
Store your API keys as environment variables and never commit them to version control.
# .env.local
CREEM_API_KEY = your_test_api_key_here
Testing Payments
Use these test card numbers to simulate different payment scenarios:
All test card numbers work with any future expiration date, any CVV, and any billing information.
Card Number Behavior Successful payment Card declined Insufficient funds Incorrect CVC
Webhook Testing
When in Test Mode, webhook events are sent to your test webhook URL. This allows you to:
Test your webhook endpoint locally using tools like ngrok
Verify webhook signature validation
Ensure your event handlers work correctly
If you want a more in-depth explanation about webhooks, check the guide below:
Learn More About Webhooks Set up webhooks to receive real-time payment notifications.
Switching to Production
When you’re ready to go live:
Complete Testing
Verify all payment flows work correctly in Test Mode
Update API Keys
Replace test API keys with production API keys in your environment variables
Update API Endpoint
Ensure direct API calls use https://api.creem.io. The TypeScript SDK uses production by
default when server is omitted.
Configure Production Webhooks
Register your production webhook URL in the live dashboard
Create Production Products
Switch to production mode in the dashboard and create your live products
Monitor First Transactions
Watch your first few production transactions carefully to ensure everything works as expected
Never use test API keys or the test API endpoint in production. This will cause all payments to
fail.
Next Steps
Checkout Learn how to create checkout sessions and payment links
One-Time Payments Accept single payments for products and services
Subscriptions Set up recurring billing and subscription management
Webhooks Set up webhooks to receive real-time payment notifications