docker.recipes

Paddle API Mock

intermediate

Mock server for Paddle payment testing.

Overview

MockServer is a powerful HTTP mocking framework that enables developers to simulate external APIs and services during development and testing. Originally created by James Bloom, MockServer has become the industry standard for API mocking, providing sophisticated request matching, response templating, and verification capabilities that go far beyond simple static mocks. MockServer excels at creating realistic API simulations with dynamic responses, request validation, and detailed logging of all interactions. This Paddle API mock implementation leverages MockServer's advanced capabilities to simulate Paddle's payment processing endpoints, subscription management APIs, and webhook delivery system. The configuration uses JSON-based expectations to define realistic responses for Paddle's checkout flows, subscription lifecycle events, and billing operations. This approach eliminates dependencies on Paddle's sandbox environment during development while providing consistent, predictable responses for automated testing. E-commerce development teams building subscription-based applications will find this stack invaluable for local development, continuous integration pipelines, and integration testing. The MockServer-based approach allows developers to test edge cases, simulate webhook failures, and validate payment flows without incurring sandbox API rate limits or dealing with external service dependencies during development cycles.

Key Features

  • JSON-based expectation configuration for Paddle subscription and checkout endpoints
  • Dynamic request matching with support for headers, query parameters, and request body validation
  • Webhook simulation with configurable delays and failure scenarios for testing retry logic
  • Request verification and call counting to validate API integration behavior
  • Template-based response generation supporting dynamic values and conditional logic
  • Built-in administration dashboard for real-time mock configuration and request monitoring
  • SSL/TLS support for testing secure payment flows and webhook delivery
  • Stateless operation with all mock definitions loaded from configuration files

Common Use Cases

  • 1Local development of subscription billing features without Paddle sandbox dependencies
  • 2Automated testing of payment flow edge cases and error handling scenarios
  • 3Integration testing for webhook processing and subscription lifecycle management
  • 4Load testing subscription APIs without impacting external payment services
  • 5Demonstration environments for sales teams showcasing payment functionality
  • 6CI/CD pipeline testing where external API calls would cause build instability
  • 7Development of Paddle webhook handlers with predictable test data

Prerequisites

  • Docker Engine 20.10+ and Docker Compose 2.0+ installed on the host system
  • Minimum 512MB RAM allocated for MockServer container operations
  • Port 1080 available on the host for MockServer administration and API endpoints
  • Understanding of Paddle API structure and webhook payload formats
  • JSON configuration knowledge for defining MockServer expectations and responses
  • Familiarity with HTTP request/response concepts and REST API testing

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 mockserver:
3 image: mockserver/mockserver:latest
4 container_name: paddle-mock
5 restart: unless-stopped
6 environment:
7 MOCKSERVER_INITIALIZATION_JSON_PATH: /config/paddle.json
8 volumes:
9 - ./paddle-config:/config
10 ports:
11 - "1080:1080"

.env Template

.env
1# Create paddle.json mock config

Usage Notes

  1. 1Docs: https://www.mock-server.com/
  2. 2MockServer at http://localhost:1080 for Paddle API testing
  3. 3Create paddle.json with expectations for /subscription, /checkout endpoints
  4. 4Test webhooks: configure mock responses for Paddle events
  5. 5Use for local development without hitting Paddle sandbox
  6. 6Stateless: define all mock responses in config file

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 mockserver:
5 image: mockserver/mockserver:latest
6 container_name: paddle-mock
7 restart: unless-stopped
8 environment:
9 MOCKSERVER_INITIALIZATION_JSON_PATH: /config/paddle.json
10 volumes:
11 - ./paddle-config:/config
12 ports:
13 - "1080:1080"
14EOF
15
16# 2. Create the .env file
17cat > .env << 'EOF'
18# Create paddle.json mock config
19EOF
20
21# 3. Start the services
22docker compose up -d
23
24# 4. View logs
25docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/paddle-mock/run | bash

Troubleshooting

  • MockServer returns 404 for Paddle endpoints: Verify paddle.json expectations file exists in ./paddle-config directory and contains proper endpoint definitions
  • Configuration changes not reflected: Restart the container as MockServer loads initialization JSON only on startup, or use the admin API to add expectations dynamically
  • Webhook delivery simulation fails: Check that webhook expectations include proper HTTP method matching and response headers required by your webhook handler
  • Memory issues with large expectation sets: Increase container memory limits and consider splitting complex expectations into smaller, focused mock definitions
  • SSL certificate errors in webhook testing: Configure MockServer with proper certificates or disable SSL verification in test environments
  • Request matching too strict or loose: Review expectation matchers in paddle.json and adjust regex patterns, exact matching, or parameter validation rules

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space