Stripe Integration
Connect your Stripe account to enable payment and billing workflows.Prerequisites
Before setting up the Stripe integration, you’ll need:- A Stripe account (create one at stripe.com)
- Access to the Stripe Dashboard
Getting Your API Key
Stripe uses API keys to authenticate requests. You’ll need a secret key to connect your Stripe account.API Key Types
| Key Type | Prefix | Description |
|---|---|---|
| Test mode secret key | sk_test_ | Use for testing and development. Doesn’t process real payments. |
| Live mode secret key | sk_live_ | Use in production. Processes real payments. |
| Restricted key | rk_test_ or rk_live_ | Limited permissions for specific use cases. |
Creating a Secret API Key
- Log in to the Stripe Dashboard
- Navigate to Developers → API keys (direct link)
- Click Create secret key
- Enter a verification code sent to your email or phone
- Give your key a name (e.g., “Serval Integration”)
- Click Create
- Important: Copy and save the key immediately — you won’t be able to see it again
Creating a Restricted API Key (Recommended)
For better security, you can create a restricted key with only the permissions needed:- On the API keys tab, click Create restricted key
- Enter a name for the key
- Set permissions for the resources you need:
- Charges: Read (for viewing payment history)
- Customers: Read/Write (for customer management)
- Balance: Read (for balance information)
- Balance Transactions: Read (for transaction history)
- Click Create key
- Copy and save the key immediately
Connecting Stripe
- In Serval, navigate to Applications and select your application
- Go to the API Integration tab
- Search for and select Stripe
- Enter your Stripe API key (starts with
sk_test_orsk_live_) - Click Save
Testing vs Production
- Test Mode: Use keys starting with
sk_test_for development and testing. No real payments are processed. - Live Mode: Use keys starting with
sk_live_when you’re ready to process real payments.
Security Best Practices
- Never expose secret keys in client-side code, GitHub, or public repositories
- Use restricted keys when possible to limit access to only necessary resources
- Rotate keys regularly if you suspect they may have been compromised
- Store keys securely using environment variables or a secrets manager
- Go to Developers → API keys in the Stripe Dashboard
- Click the menu (⋯) next to the key
- Select Rotate key
- Update your integration with the new key
Troubleshooting
Invalid API Key
- Ensure you’re using a secret key (starts with
sk_) - Verify the key hasn’t been deleted or rotated
- Check you’re using the correct mode (test vs live)
Permission Denied
- If using a restricted key, verify it has the required permissions
- Check that your Stripe account has access to the requested resources

