Python SDK
Backend integration for Waffy payment processing with modular architecture, OAuth2 authentication, and production-ready API servers.
SDK Components
Modern modular architecture with clean separation of concerns
Modern Modular SDK
Clean separation with dedicated modules for each functionality
- auth.py - Authentication & tokens
- contracts.py - Contract management
- sdk.py - Main SDK class
- config.py - Configuration
Production API Servers
Ready-to-deploy servers with Docker support
- Production API server
- Development Flask server
- Docker containerization
- Docker Compose setup
Quick Start
Get started with Waffy Python SDK in minutes
1Installation
# Install dependencies
pip install -r requirements.txt
# Or install individual packages
pip install requests python-dotenv
2Basic Usage
from waffy_sdk import WaffySDK
# Initialize SDK
sdk = WaffySDK(environment="dev")
sdk.setup_credentials(
client_id="your_client_id",
client_secret="your_client_secret",
admin_username="admin@example.com",
admin_password="password"
)
# Create payment
result = sdk.create_contract_with_payment(
contract_data={
"title": "Payment Contract",
"description": "Service payment"
},
milestone_data={
"title": "Payment Milestone",
"amount": 100.00
},
parties=[
{
"role": "CUSTOMER",
"phone": "+966555555555"
},
{
"role": "PROVIDER",
"phone": "+966555555556"
}
],
redirect_url="https://yoursite.com/success"
)
print(f"Payment URL: {result['payment_url']}")
3Start Development Server
# Start Flask development server
cd api/
python flask_backend_server.py
# Server starts on http://localhost:5001
# Endpoints:
# GET /api/waffy/health
# POST /api/waffy/create-payment
# GET /api/waffy/payment-status/<contract_id>/<milestone_id>
# POST /api/waffy/cancel-payment/<contract_id>/<milestone_id>
Key Features
Everything you need for robust payment processing
๐OAuth2 Authentication
Secure token-based authentication
- Client credentials flow
- Automatic token refresh
- User token generation
๐Contract Management
Full contract lifecycle management
- Contract creation
- Milestone management
- Party assignment
โกBatch Processing
Handle multiple payments efficiently
- Batch payment creation
- Bulk operations
- Performance optimization
๐ณDocker Support
Production-ready containerization
- Docker containers
- Docker Compose
- Easy deployment
API Endpoints
RESTful API endpoints for seamless integration
Payment Operations
System Operations
Docker Deployment
Deploy with Docker for production environments
๐ณQuick Docker Setup
# Clone the repository
git clone https://github.com/waffyapp/waffy-python-sdk.git
cd waffy-python-sdk/backend
# Build and run with Docker Compose
cd docker/
docker-compose up --build
# Or build individual container
docker build -t waffy-python-sdk .
docker run -p 5001:5001 waffy-python-sdk
# Environment variables
export WAFFY_CLIENT_ID="your_client_id"
export WAFFY_CLIENT_SECRET="your_client_secret"
export WAFFY_ENVIRONMENT="dev"
Testing & Development
Comprehensive testing suite and development tools
๐งชUnit Tests
# Run test suite
python -m pytest tests/
# Run specific test files
python -m pytest tests/unit/test_auth.py
python -m pytest tests/unit/test_sdk.py
โกUtilities
Perfect Integration with JavaScript SDK
Works seamlessly with our JavaScript SDK for complete frontend-backend integration
Ready to Get Started?
Start building secure payment processing with Python SDK
Need Help?
Check out our documentation and examples