---
title: Uzum Integration
description: Integrate Uzum Bank into a Python project with PayTechUZ — Biller open-service links, Basic-auth webhooks and a Django example.
source: https://pay-tech.uz/en/docs/integrations/uzum
---

# Uzum Integration

Uzum is a fast-growing payment system in Uzbekistan. This guide shows how to
integrate Uzum with PayTechUZ.

## Installation

```bash
pip install paytechuz
```

## Basic usage

### Create a gateway

```python
from paytechuz.gateways.uzum.client import UzumGateway

# Initialise the Uzum gateway (Biller/open-service)
uzum = UzumGateway(
    service_id="your_service_id",  # Uzum Service ID
    is_test_mode=True  # Set to False in production
)
```

### Create a payment

```python
# Build an Uzum Biller payment link
# URL format: https://www.uzumbank.uz/open-service?serviceId=...&order_id=...&amount=...&redirectUrl=...
uzum_link = uzum.create_payment(
    id="order_123",  # Order ID (the order_id parameter)
    amount=100000,  # Amount in so'm (converted to tiyin)
    return_url="https://example.com/callback"  # The redirectUrl parameter
)
# Result: https://www.uzumbank.uz/open-service?serviceId=your_service_id&order_id=order_123&amount=10000000&redirectUrl=https%3A%2F%2Fexample.com%2Fcallback
```

## Django integration

### Settings.py

Add the `UZUM` block to your `PAYTECHUZ` settings:

```python
# settings.py
INSTALLED_APPS = [
    # ...
    'paytechuz.integrations.django',
]

PAYTECHUZ = {
    # ... other gateways
    'UZUM': {
        'SERVICE_ID': 'your_service_id',  # Uzum Service ID for the Biller URL
        'USERNAME': 'your_uzum_username',  # For webhook Basic Auth
        'PASSWORD': 'your_uzum_password',  # For webhook Basic Auth
        'ACCOUNT_MODEL': 'your_app.models.Order',
        'ACCOUNT_FIELD': 'id',  # or 'order_id'
        'AMOUNT_FIELD': 'amount',
        'ONE_TIME_PAYMENT': True, # Set to False if you want to allow multiple payments for the same invoice
        'IS_TEST_MODE': True,  # Set to False in production
    }
}
```

### Views.py

Create a webhook view by subclassing `BaseUzumWebhookView`:

```python
# views.py
from paytechuz.integrations.django.views import BaseUzumWebhookView
from .models import Order

class UzumWebhookView(BaseUzumWebhookView):
    def successfully_payment(self, params, transaction):
        order = Order.objects.get(id=transaction.account_id)
        order.status = 'paid'
        order.save()

    def cancelled_payment(self, params, transaction):
        order = Order.objects.get(id=transaction.account_id)
        order.status = 'cancelled'
        order.save()
```

### URLs.py

Add the webhook URL. Note that Uzum webhooks carry an `action` parameter in the path:

```python
# urls.py
from django.urls import path
from .views import UzumWebhookView

urlpatterns = [
    # ...
    path('payments/webhook/uzum/<str:action>/', UzumWebhookView.as_view(), name='uzum_webhook'),
]
```

## Further reading

- [PayTechUZ GitHub repository](https://github.com/PayTechUz/paytechuz)
- [Django Integration](./django)
- [FastAPI Integration](./fastapi)
