This project is a complete example application for the tapsilat-py Python SDK library. It demonstrates how to integrate Tapsilat payment system into a Docker-enabled e-commerce cart application using Flask.
Note: This is an official example application showcasing the capabilities and usage of the
tapsilat-pylibrary for Python developers.
This application uses the tapsilat-py library. With Tapsilat Python SDK, you can easily perform the following operations:
- Order creation, checkout, refund, and cancellation
- Elements sessions (create, get, cancel) for native mobile SDK card sheets
- External Order Item Payment (OIP) recording outside checkout
- Basket item management
- Customer and address information processing
- Installment and payment options management
- Subscription creation and tracking
- Organization, sub-organization, and user management
- Payment term and system metadata queries
- Payment status tracking and webhook signature verification
- Backend: Python 3.11 + Flask
- Payment SDK: Tapsilat Python SDK
- Frontend: Bootstrap 5, FontAwesome
- Containerization: Docker & Docker Compose
- Package Manager: pip
- Complete Tapsilat Python SDK integration example
- Flask web framework implementation exposing all SDK functionalities
- Bootstrap 5 responsive design for cart and checkout simulator
- Comprehensive API routes covering Orders, Subscriptions, Organization, Terms, and System queries
- Docker support for easy setup
- Automatic checkout redirection and webhooks logging
- API error handling and user-friendly error messages
-
Clone the repository:
git clone https://github.com/tapsilat/examples.git cd examples/python -
Configure Environment:
cp .env.example .env # Edit .env and set TAPSILAT_API_KEY and TAPSILAT_BASE_URL -
Run with Docker:
docker compose up --build
Access at http://localhost:5000 (Docker uses port 5000 by default).
-
Create Virtual Environment:
python3 -m venv venv source venv/bin/activate -
Install Dependencies:
pip install -r requirements.txt
-
Run Application:
python3 app.py
Open your browser and navigate to http://localhost:5001 (Manual execution defaults to port 5001).
- View products on the main page
- Add products to cart using "Add to Cart" button
- Complete the order with Address and Customer information
- Redirect to Tapsilat Checkout page automatically
The application exposes comprehensive routes under /api/... matching the SDK's functionalities:
- Order:
/api/order/create,/api/order/list,/api/order/refund,/api/order/cancel,/api/order/oip - Elements:
/api/elements/sessions(POST),/api/elements/sessions/<id>(GET),/api/elements/sessions/<id>/cancel(POST) - Subscription:
/api/subscription/create,/api/subscription/list, etc. - Organization:
/api/organization/settings,/api/organization/limits,/api/organization/suborganizations, etc. - Term:
/api/term/create,/api/term/refund, etc. - System:
/api/system/order-statuses,/api/system/error-codes, etc. - Webhooks:
/api/webhooks/logsand/api/webhook/verify(SDK HMAC signature verifier)
python/
├── .docker/
│ └── Dockerfile # Docker image definition
├── src/
│ ├── __init__.py
│ └── utils.py # Utility functions
├── static/ # Static assets (CSS, JS)
├── templates/
│ └── index.html # Main page (cart interface)
├── webhooks/ # Directory where webhook logs are saved
├── app.py # Flask application (Tapsilat integration)
├── requirements.txt # Python dependencies
├── docker-compose.yml # Docker configuration
├── .env.example # Environment example file
└── README.md
{
"amount": 299.99,
"currency": "TRY",
"buyer": {
"name": "Ahmet",
"surname": "Yılmaz",
"email": "ahmet@example.com",
"gsm_number": "+905551234567"
},
"basket_items": [
{
"id": "1",
"name": "Headphones",
"price": 299.99,
"quantity": 1
}
]
}{
"amount": 99.99,
"currency": "TRY",
"title": "Premium Membership",
"period": 1,
"user": {
"first_name": "Ahmet",
"last_name": "Yılmaz",
"email": "ahmet@example.com"
}
}- Flask development mode is active, automatic restart on code changes
- Uses the latest version of Tapsilat SDK
- Incoming Webhooks are stored as JSON files under
webhooks/directory. - Cart data and API inputs can be directly configured.
The application includes comprehensive error handling:
- API validation errors
- Tapsilat SDK errors
- Network errors
- Appropriate HTTP 400 responses on failures
- API key management with environment variables
- Webhook signature validation (SDK side)
- Request header based API credentials (
X-Api-KeyandX-Api-Url)
For any questions or suggestions: