Third-Party API Simulation
Mock payment gateways, social logins, and external services without rate limits or costs.
Your app integrates with payment gateways, email services, and third-party APIs. Testing against real services means rate limits, costs, and polluted test data. MockStation lets you simulate these services locally and in CI.
The Third-Party Problem
Real third-party APIs come with constraints:
- Rate limits: Hit limits during development, get blocked
- Costs: Payment API calls cost money, even in test mode
- Test data pollution: Real services accumulate test records
- Sandbox limitations: Test environments don't support all scenarios
- Network dependency: External service downtime blocks your work
Common Third-Party APIs to Mock
Payment Gateways
Stripe, PayPal, Braintree, Square
Email Services
SendGrid, Mailgun, AWS SES, Postmark
Cloud Services
AWS, GCP, Azure APIs
Auth Providers
OAuth, Auth0, Firebase Auth
Example: Mock Stripe API
Create Charge
POST/v1/charges
{
"id": "ch_{{$randomUUID}}",
"object": "charge",
"amount": "{{request.body.amount}}",
"currency": "{{request.body.currency}}",
"status": "succeeded",
"paid": true,
"captured": true,
"payment_method": "pm_{{$randomUUID}}",
"receipt_url": "https://pay.stripe.com/receipts/{{$randomUUID}}",
"created": {{$timestamp}}
}Card Declined Scenario
POST/v1/charges/declinedStatus: 402
{
"error": {
"type": "card_error",
"code": "card_declined",
"message": "Your card was declined.",
"decline_code": "insufficient_funds"
}
}Example: Mock SendGrid API
Send Email
POST/v3/mail/sendStatus: 202
{
"message_id": "{{$randomUUID}}",
"status": "accepted"
}Example: Mock OAuth Provider
Token Exchange
POST/oauth/token
{
"access_token": "{{$randomUUID}}-{{$randomUUID}}",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "{{$randomUUID}}",
"scope": "read write"
}User Info
GET/oauth/userinfo
{
"sub": "{{$randomUUID}}",
"email": "{{$faker.internet.email}}",
"email_verified": true,
"name": "{{$faker.person.fullName}}",
"picture": "{{$faker.image.avatar}}",
"locale": "en-US"
}Configuration Pattern
Use environment variables to switch between mock and real APIs:
config/services.ts
const config = {
stripe: {
development: 'https://api.mockstation.io/v1/my-app/stripe',
test: 'https://api.mockstation.io/v1/my-app/stripe',
production: 'https://api.stripe.com',
},
sendgrid: {
development: 'https://api.mockstation.io/v1/my-app/sendgrid',
test: 'https://api.mockstation.io/v1/my-app/sendgrid',
production: 'https://api.sendgrid.com',
},
};
const env = process.env.NODE_ENV || 'development';
export const STRIPE_API_URL = config.stripe[env];
export const SENDGRID_API_URL = config.sendgrid[env];Benefits
- Zero costs: No charges for payment API calls
- No rate limits: Test as much as you want
- Clean data: No test pollution in real services
- Test all scenarios: Declined cards, bounced emails, auth failures
- Offline capable: External service outages don't block you
- Fast: Mock responses in milliseconds
Get Started
Mock your third-party integrations:
- Create a free account
- Create endpoints matching the third-party API structure
- Add both success and error scenarios
- Point your app to mock URLs in development
- Test freely without costs or limits
Simulate Any Third-Party API
Create mock versions of Stripe, SendGrid, OAuth providers, and more.
Get Started FreeNo credit card required