Skip to main content

💳 UniPay UZ

PyPI version Python Versions License: MIT

UniPay UZ is an all-in-one, robust payment integration library designed specifically for Uzbekistan's leading payment gateways. Whether you're building a massive e-commerce platform or a scalable SaaS product, this tool streamlines the transaction workflows for Payme, Click, Uzum, Paynet, and Octo.

Built with scalability and developer experience in mind, it handles the heavy lifting of API communications, webhook verifications, and transaction state management so you can focus on your core product.


⚡ Why Choose UniPay UZ?

  • Unified Interface: Stop writing redundant API wrappers! Engage with multiple providers using a standardized, predictable API.
  • Battle-tested Security: Data integrity and security checks are baked right in.
  • Plug-and-Play Frameworks: First-class, out-of-the-box integration for Django, FastAPI, and Flask.
  • Effortless Webhooks: Handle complex asynchronous payment notifications (callbacks) with our elegant webhook base classes.
  • Architectural Flexibility: Easily extensible to accommodate new or niche payment gateways as your business targets grow.

🛠️ Installation Guide

Get up and running in seconds using pip.

Standard Installation:

pip install unipay-uz

Framework-Optimized Installation:

# Opt for Django-specific dependencies
pip install unipay-uz[django]

# Opt for FastAPI dependencies
pip install unipay-uz[fastapi]

# Opt for Flask dependencies
pip install unipay-uz[flask]

🚀 Jumpstart Your Integration

1. Generating Checkout Links

Drop in your merchant credentials and generate secure payment references instantly.

from unipay_uz.gateways.payme import PaymeGateway
from unipay_uz.gateways.click import ClickGateway
from unipay_uz.gateways.uzum.client import UzumGateway
from unipay_uz.gateways.paynet import PaynetGateway

# Setup Payme 
payme_client = PaymeGateway(
    payme_id="MERCHANT_ID_HERE",
    payme_key="SECRET_KEY_HERE",
    is_test_mode=True  # Toggle for production deployment
)

# Setup Click 
click_client = ClickGateway(
    service_id="APP_SERVICE_ID",
    merchant_id="APP_MERCHANT_ID",
    merchant_user_id="APP_USER_ID",
    secret_key="SECRET_HASH_KEY",
    is_test_mode=True 
)

# Create an invoice / checkout URL
checkout_url_payme = payme_client.create_payment(
    id="ORD-998877",
    amount=250000,  # Value in UZS (Som)
    return_url="https://your-platform.uz/checkout/success",
    account_field_name="order_id"  # Identifier key requested by Payme
)

# Generate Click invoice
checkout_url_click = click_client.create_payment(
    id="ORD-998877",
    amount=250000, 
    description="Subscription Renewal",
    return_url="https://your-platform.uz/checkout/success"
)

2. Provider-Specific Details

Paynet Interactions

Paynet processes invoices predominantly via mobile devices, rendering direct app redirection links.

# Create a Paynet invoice (amount in Tiyin: 1 UZS = 100 Tiyin)
paynet_url = paynet_client.create_payment(
    id="ORD-998877", 
    amount=25000000 
)
# Returns: https://app.paynet.uz/?m={merchant_id}&c=ORD-998877&a=25000000

Note: Paynet relies on JSON-RPC 2.0 Webhooks for fulfillment acknowledgment, not return URLs.

Uzum Biller Integration

Generate an open-service gateway redirect for the Uzum ecosystem.

uzum_url = uzum_client.create_payment(
    id="ORD-998877",  
    amount=50000,  # Value in UZS
    return_url="https://your-platform.uz/sync"  
)

🏗️ Deep Dive: Django Blueprint

Integrating real-time transaction state updates using Django is built into unipay-uz.

Configuration Requirements

First, add your credentials in settings.py:

INSTALLED_APPS = [
    # ...
    'unipay_uz.integrations.django',
]

TOLOV = {
    'PAYME': {
        'PAYME_ID': 'STORE_ID',
        'PAYME_KEY': 'STORE_KEY',
        'ACCOUNT_MODEL': 'shop.models.Transaction',
        'ACCOUNT_FIELD': 'ref_id',
        'AMOUNT_FIELD': 'total_amount',
        'ONE_TIME_PAYMENT': True,
    },
    'CLICK': {
        'SERVICE_ID': 'SRV_ID',
        'MERCHANT_ID': 'MCH_ID',
        'MERCHANT_USER_ID': 'USR_ID',
        'SECRET_KEY': 'SECRET',
        'ACCOUNT_MODEL': 'shop.models.Transaction',
        'ACCOUNT_FIELD': 'ref_id',
        'COMMISSION_PERCENT': 0.0,
        'ONE_TIME_PAYMENT': True,
    }
}

Listening to Webhooks

Create specialized views that inherit from our base webhook classes.

# views.py
from unipay_uz.integrations.django.views import BasePaymeWebhookView, BaseClickWebhookView
from shop.models import Transaction

class PaymeCallbackReceiver(BasePaymeWebhookView):
    def successfully_payment(self, params, transaction):
        order = Transaction.objects.get(ref_id=transaction.account_id)
        order.mark_as_paid()

    def cancelled_payment(self, params, transaction):
        order = Transaction.objects.get(ref_id=transaction.account_id)
        order.mark_as_failed()

class ClickCallbackReceiver(BaseClickWebhookView):
    def successfully_payment(self, params, transaction):
        order = Transaction.objects.get(ref_id=transaction.account_id)
        order.mark_as_paid()

    def cancelled_payment(self, params, transaction):
        order = Transaction.objects.get(ref_id=transaction.account_id)
        order.mark_as_failed()

Map these receivers in your urls.py:

from django.urls import path
from .views import PaymeCallbackReceiver, ClickCallbackReceiver

urlpatterns = [
    path('api/v1/webhooks/payme/', PaymeCallbackReceiver.as_view()),
    path('api/v1/webhooks/click/', ClickCallbackReceiver.as_view()),
]

👨‍💻 Meet the Author

Javlon Baxtiyorov (javlondevv)

"Building backend systems that think ahead—automating tasks, scaling APIs, and making code feel invisible when it's working right. The best code solves human problems, not just technical ones."

Javlon is a dedicated software engineer with a deep passion for designing scalable tools, mentoring fellow developers, and architecting high-quality systems. His expertise lies in backend technologies, relying heavily on Python, Django, FastAPI, Celery, and other modern frameworks to deliver robust solutions.

If this package has helped you or your company streamline payment integrations, feel free to connect!

📄 Licensing

Distributed under the MIT License. See LICENSE.txt for more information.

Metadata

Release files for unipay-uz 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unipay-uz 1.0.1
File Size Uploaded
unipay_uz-1.0.1.tar.gz 54.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unipay-uz 1.0.1
File Interpreter ABI Platform
unipay_uz-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 131.7 kB

Release files / unipay_uz-1.0.1.tar.gz

Download URL unipay_uz-1.0.1.tar.gz
Size 54.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2da175726cb6fccd8657eafdf184eaa50f3b4efbdd8a1afd719e0a05674eb4ba
BLAKE2b-256 checksum
How to use checksums
2ee267cc2a2d9defc22065aa5b628c18fe4d2b1575bccd3bd2476d9ac2cffb6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / unipay_uz-1.0.1-py3-none-any.whl

Download URL unipay_uz-1.0.1-py3-none-any.whl
Size 77.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2748bf6d235a637157149fff5f00e736b2b9b1471f3a4e2d7532caa5809b2bd3
BLAKE2b-256 checksum
How to use checksums
db214f9cac63cbf0af9c9c499d3a971315d78b1b9250784252349bd9b617cb42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page