Modern Python SDK

Python SDK

Backend integration for Waffy payment processing with modular architecture, OAuth2 authentication, and production-ready API servers.

Quick Start Guide

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

1
Installation

# Install dependencies
pip install -r requirements.txt

# Or install individual packages
pip install requests python-dotenv

2
Basic 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']}")

3
Start 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

POST/api/waffy/create-payment
GET/api/waffy/payment-status
POST/api/waffy/cancel-payment

System Operations

GET/api/waffy/health
POST/api/waffy/create-batch-payments
GET/api/waffy/batch-status

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

โ€ข batch_payments.py - Batch processing
โ€ข quick_payment.py - Single payment utility
โ€ข python_backend_example.py - Integration example

Perfect Integration with JavaScript SDK

Works seamlessly with our JavaScript SDK for complete frontend-backend integration

1
Backend generates payment links
2
Frontend displays payments
3
User tokens handled automatically
View JavaScript SDK v2.0

Ready to Get Started?

Start building secure payment processing with Python SDK

Need Help?

Check out our documentation and examples