Metadata-Version: 2.4
Name: paytechuz
Version: 0.5.0
Summary: Unified Python package for Uzbekistan payment gateways (Payme, Click, Uzum, Paynet, Octo)
Author-email: Muhammadali Akbarov <muhammadali17abc@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/Muhammadali-Akbarov/paytechuz
Project-URL: Documentation, https://pay-tech.uz
Project-URL: Source, https://github.com/Muhammadali-Akbarov/paytechuz
Project-URL: Issues, https://github.com/Muhammadali-Akbarov/paytechuz/issues
Keywords: paytechuz,payme,click,uzum,paynet,octo,uzbekistan,payment,gateway,payment-gateway,payment-processing,django,fastapi
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests<3.0,>=2.0
Provides-Extra: django
Requires-Dist: django<7.0,>=3.2; extra == "django"
Provides-Extra: fastapi
Requires-Dist: fastapi<1.0.0,>=0.68.0; extra == "fastapi"
Requires-Dist: sqlalchemy<3.0,>=1.4; extra == "fastapi"
Requires-Dist: python-multipart>=0.0.5; extra == "fastapi"
Requires-Dist: pydantic<3.0,>=2.0; extra == "fastapi"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-django>=4.5; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# PayTechUZ — Payme, Click, Uzum, Paynet and Octo payments for Python

[![PyPI version](https://badge.fury.io/py/paytechuz.svg)](https://pypi.org/project/paytechuz/)
[![Python Versions](https://img.shields.io/pypi/pyversions/paytechuz.svg)](https://pypi.org/project/paytechuz/)
[![CI](https://github.com/PayTechUz/paytechuz/actions/workflows/ci.yml/badge.svg)](https://github.com/PayTechUz/paytechuz/actions/workflows/ci.yml)
[![Documentation](https://img.shields.io/badge/docs-pay--tech.uz-blue.svg)](https://pay-tech.uz)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

One library for the payment gateways used in Uzbekistan — **Payme, Click,
Uzum, Paynet and Octo** — with the same interface for each, and webhook
handlers for Django and FastAPI that you subclass instead of writing.

Fully open source: pure Python, no compiled extensions. Everything the
package does at runtime is in this repository.

📖 **[Documentation](https://pay-tech.uz)** &nbsp;|&nbsp; 💬 **[Telegram](https://t.me/paytechuz)** &nbsp;|&nbsp; 📋 **[Changelog](CHANGELOG.md)**

```bash
pip install paytechuz
```

<sub>🇺🇿 Payme, Click, Uzum, Paynet va Octo integratsiyasi — Django va FastAPI uchun bitta Python kutubxonasi.<br/>
🇷🇺 Интеграция Payme, Click, Uzum, Paynet и Octo — одна Python-библиотека для Django и FastAPI.</sub>

## Contents

- [Features](#features)
- [Compatibility](#compatibility)
- [Installation](#installation)
- [Quick Start](#quick-start)
  - [Generate payment links](#generate-payment-links)
  - [Provider notes](#provider-notes)
- [Django Integration](#django-integration)
  - [Several kassas on one URL](#several-kassas-on-one-url)
  - [Hooks run in the payment's transaction](#hooks-run-in-the-payments-transaction)
- [FastAPI Integration](#fastapi-integration)
- [The transaction table](#the-transaction-table)
- [Project layout](#project-layout)
- [Development](#development)
- [Contributing](#contributing)
- [License](#license)

## Features

- **Unified API**: consistent interface for multiple payment providers
- **Framework integration**: native support for Django and FastAPI
- **Webhook handling**: ready-to-use webhook handlers for payment notifications
- **Transaction management**: automatic transaction tracking in a single table
- **Extensible**: adding a new provider means adding one gateway and one webhook class

## Compatibility

| | Supported |
| --- | --- |
| Python | 3.8 – 3.12 |
| Django | 3.2 – 6.0 (tested on 4.2, 5.2, 6.0) |
| FastAPI | 0.68 – 0.x, with SQLAlchemy 1.4 – 2.x and pydantic 2.x |
| Gateways | Payme, Click, Uzum, Paynet, Octo |

Webhook handlers for Uzum, Paynet and Octo are currently Django only. Payme and
Click are available on both frameworks.

## Installation

```bash
pip install paytechuz

# For Django
pip install "paytechuz[django]"

# For FastAPI
pip install "paytechuz[fastapi]"
```

## Quick Start

### Generate payment links

```python
from paytechuz.gateways.payme import PaymeGateway
from paytechuz.gateways.click import ClickGateway
from paytechuz.gateways.uzum import UzumGateway
from paytechuz.gateways.paynet import PaynetGateway
from paytechuz.gateways.octo import OctoGateway

# Payme
payme = PaymeGateway(
    payme_id="your_payme_id",
    payme_key="your_payme_key",
    is_test_mode=True,  # Set to False in production
)

# Click
click = ClickGateway(
    service_id="your_service_id",
    merchant_id="your_merchant_id",
    merchant_user_id="your_merchant_user_id",
    secret_key="your_secret_key",
    is_test_mode=True,
)

# Uzum (Biller / open-service)
uzum = UzumGateway(
    service_id="your_service_id",
    is_test_mode=True,
)

# Paynet
paynet = PaynetGateway(
    merchant_id="your_merchant_id",  # accepts both str and int
    is_test_mode=False,
)

# Octo
octo = OctoGateway(
    octo_shop_id=123,
    octo_secret="your_octo_secret",
    notify_url="https://example.com/payments/webhook/octo/",
    is_test_mode=True,
)
```

```python
# Payme — amount in som. account_field_name is the field name used in the
# payment URL (e.g. ac.id=123). Default: "order_id".
payme_link = payme.create_payment(
    id="order_123",
    amount=150000,
    return_url="https://example.com/return",
    account_field_name="id",
)

# Click — amount in som
click_link = click.create_payment(
    id="order_123",
    amount=150000,
    description="Test payment",
    return_url="https://example.com/return",
)

# Uzum — amount in som, converted to tiyin in the URL
uzum_link = uzum.create_payment(
    id="order_123",
    amount=100000,
    return_url="https://example.com/callback",
)
# https://www.uzumbank.uz/open-service?serviceId=...&order_id=order_123&amount=10000000&redirectUrl=...

# Paynet — amount in tiyin, optional
paynet_link = paynet.create_payment(id="order_123", amount=15000000)
# https://app.paynet.uz/?m=your_merchant_id&c=order_123&a=15000000

paynet_link_no_amount = paynet.create_payment(id="order_123")
# https://app.paynet.uz/?m=your_merchant_id&c=order_123

# Octo — amount in som, one-stage (auto_capture)
octo_link = octo.create_payment(
    id="order_123",
    amount=50000,
    return_url="https://example.com/payment/done/",
    description="Order #123",
)
```

You can also build a gateway by name:

```python
from paytechuz import create_gateway

payme = create_gateway("payme", payme_id="...", payme_key="...", is_test_mode=True)
```

### Provider notes

**Payme `account_field_name`** — only Payme uses this parameter. It sets the account
key inside the payment URL (`ac.<account_field_name>=<id>`). Other gateways ignore it.

**Paynet** — URL-based, mobile-first:

- URL format: `https://app.paynet.uz/?m={merchant_id}&c={payment_id}&a={amount}`
- `merchant_id` accepts both `str` and `int`
- `amount` is optional and expressed in tiyin
- no return URL support
- desktop users scan a QR code, mobile users open the Paynet app
- payment status arrives through JSON-RPC 2.0 webhooks

## Django Integration

1. Create your order model:

```python
# models.py
from django.db import models
from django.utils import timezone


class Order(models.Model):
    STATUS_CHOICES = (
        ('pending', 'Pending'),
        ('paid', 'Paid'),
        ('cancelled', 'Cancelled'),
        ('delivered', 'Delivered'),
    )

    product_name = models.CharField(max_length=255)
    amount = models.DecimalField(max_digits=12, decimal_places=2)
    status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
    created_at = models.DateTimeField(default=timezone.now)

    def __str__(self):
        return f"{self.id} - {self.product_name} ({self.amount})"
```

2. Add the app and configure the settings:

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

PAYTECHUZ = {
    'PAYME': {
        'PAYME_ID': 'your_payme_id',
        'PAYME_KEY': 'your_payme_key',
        'ACCOUNT_MODEL': 'orders.models.Order',
        'ACCOUNT_FIELD': 'id',              # = account_field_name of the payment link
        'AMOUNT_FIELD': 'amount',
        'ONE_TIME_PAYMENT': True,
    },
    'CLICK': {
        'SERVICE_ID': 'your_service_id',
        'MERCHANT_ID': 'your_merchant_id',
        'MERCHANT_USER_ID': 'your_merchant_user_id',
        'SECRET_KEY': 'your_secret_key',
        'ACCOUNT_MODEL': 'orders.models.Order',
        'ACCOUNT_FIELD': 'id',
        'AMOUNT_FIELD': 'amount',
        'COMMISSION_PERCENT': 0.0,
        'ONE_TIME_PAYMENT': True,
    },
    'UZUM': {
        'SERVICE_ID': 'your_service_id',
        'USERNAME': 'your_uzum_username',   # webhook Basic auth
        'PASSWORD': 'your_uzum_password',   # webhook Basic auth
        'ALLOWED_IPS': ['...'],             # Uzum's addresses; omit to accept any
        # 'IP_HEADER': 'HTTP_X_REAL_IP',    # behind nginx
        'ACCOUNT_MODEL': 'orders.models.Order',
        'ACCOUNT_FIELD': 'order_id',        # or 'id'
        'AMOUNT_FIELD': 'amount',
        'ONE_TIME_PAYMENT': True,
    },
    'PAYNET': {
        'SERVICE_ID': 'your_paynet_service_id',
        'USERNAME': 'your_paynet_username',
        'PASSWORD': 'your_paynet_password',
        'ACCOUNT_MODEL': 'orders.models.Order',
        'ACCOUNT_FIELD': 'id',              # the key Paynet sends in params.fields
        'AMOUNT_FIELD': 'amount',
        'ONE_TIME_PAYMENT': True,
    },
    'OCTO_BANK': {
        'OCTO_SHOP_ID': 42125,
        'OCTO_SECRET': 'your_octo_secret',
        'OCTO_UNIQUE_KEY': 'your_octo_unique_key',  # required in production
        'NOTIFY_URL': 'https://example.com/payments/webhook/octo/',
        'ACCOUNT_MODEL': 'orders.models.Order',
        'ACCOUNT_FIELD': 'id',
        'AMOUNT_FIELD': 'amount',
        'ONE_TIME_PAYMENT': True,
        'TEST_MODE': True,  # False in production — enables signature verification
    },
}
```

> **Note:** `is_test_mode` is a gateway constructor argument, not a webhook setting.
> Webhooks receive requests on the same URL in both test and production.

`AMOUNT_FIELD` holds som. Payme, Paynet and Uzum send tiyin; the webhooks
convert before comparing. `ACCOUNT_FIELD: 'order_id'` looks the account up by
its `id`.

3. Run migrations:

```bash
python manage.py migrate
```

4. Create the webhook views:

```python
# views.py
from paytechuz.integrations.django.views import (
    BasePaymeWebhookView,
    BaseClickWebhookView,
    BaseUzumWebhookView,
    BasePaynetWebhookView,
    BaseOctoWebhookView,
)
from .models import Order


class PaymeWebhookView(BasePaymeWebhookView):
    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()

    def get_check_data(self, params, account):  # optional
        # Extra data for CheckPerformTransaction (fiscal receipt)
        return {
            "detail": {
                "receipt_type": 0,
                "shipping": {"title": "Yetkazib berish", "price": 10000},
                "items": [
                    {
                        "discount": 0,
                        "title": account.product_name,
                        "price": int(account.amount * 100),
                        "count": 1,
                        "code": "00001",
                        "units": 1,
                        "vat_percent": 0,
                        "package_code": "123456",
                    }
                ],
            },
        }


class ClickWebhookView(BaseClickWebhookView):
    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()


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()

    def get_check_data(self, params, account):  # optional
        # Shown to the payer in the Uzum app before paying
        return {"fio": {"value": account.product_name}}


class PaynetWebhookView(BasePaynetWebhookView):
    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()

    def get_check_data(self, params, account):  # optional
        # Extra data for GetInformation, shown to the payer
        return {"fields": {"amount": int(account.amount)}}


class OctoWebhookView(BaseOctoWebhookView):
    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()
```

5. Register the webhook URLs:

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

from .views import (
    PaymeWebhookView,
    ClickWebhookView,
    UzumWebhookView,
    PaynetWebhookView,
    OctoWebhookView,
)

urlpatterns = [
    path('payments/webhook/payme/', PaymeWebhookView.as_view(), name='payme_webhook'),
    path('payments/webhook/click/', ClickWebhookView.as_view(), name='click_webhook'),
    path('payments/webhook/uzum/<str:action>/', UzumWebhookView.as_view(), name='uzum_webhook'),
    path('payments/webhook/paynet/', PaynetWebhookView.as_view(), name='paynet_webhook'),
    path('payments/webhook/octo/', OctoWebhookView.as_view(), name='octo_webhook'),
]
```

6. Send the customer to pay. The id in the link is the account the webhook
   looks up:

```python
# views.py
from django.conf import settings
from django.shortcuts import get_object_or_404, redirect
from paytechuz.gateways.payme import PaymeGateway

from .models import Order


def pay_with_payme(request, order_id):
    order = get_object_or_404(Order, id=order_id, status='pending')
    payme = PaymeGateway(
        payme_id=settings.PAYTECHUZ['PAYME']['PAYME_ID'],
        payme_key=settings.PAYTECHUZ['PAYME']['PAYME_KEY'],
        is_test_mode=False,
    )
    return redirect(payme.create_payment(
        id=order.id,
        amount=order.amount,
        return_url='https://example.com/orders/',
        account_field_name=settings.PAYTECHUZ['PAYME']['ACCOUNT_FIELD'],
    ))
```

Click and Uzum take `amount` in som the same way. Paynet's link takes tiyin:
`PaynetGateway(merchant_id=...).create_payment(id=order.id, amount=int(order.amount * 100))`.

### Several kassas on one URL

One business often holds several merchant accounts with one provider: a live
kassa and a sandbox one, or one per brand. Since `0.5.0` each Django webhook
serves them all from one URL. List them under `KASSAS`; the provider's own
credentials decide which kassa a call belongs to:

| Gateway | A call is matched by |
| --- | --- |
| Payme | the key in its Basic auth header (`PAYME_KEY`) |
| Click | `service_id` in the body (`SERVICE_ID`, signed with that kassa's `SECRET_KEY`) |
| Paynet | `serviceId` in the body, else the login (`USERNAME`) |
| Uzum | the Basic auth login (`USERNAME`); the call must then name that kassa's `serviceId` |

```python
PAYTECHUZ = {
    'PAYME': {
        'KASSAS': {
            'shop':  {'PAYME_ID': '...', 'PAYME_KEY': '...'},
            'gifts': {'PAYME_ID': '...', 'PAYME_KEY': '...'},
        },
        'KASSA_FIELD': 'kassa',          # optional, see below
        'ACCOUNT_MODEL': 'orders.models.Order',
        'ACCOUNT_FIELD': 'id',
        'AMOUNT_FIELD': 'amount',
        'ONE_TIME_PAYMENT': True,
    },
    'CLICK': {
        'KASSAS': {
            'shop': {'SERVICE_ID': '...', 'SECRET_KEY': '...'},
        },
        # ACCOUNT_MODEL etc. as above
    },
    'PAYNET': {
        'KASSAS': {
            'live': {'SERVICE_ID': '1001', 'USERNAME': '...', 'PASSWORD': '...'},
            'test': {'SERVICE_ID': '1003', 'USERNAME': '...', 'PASSWORD': '...',
                     'IS_SANDBOX': True},
        },
        # 'CREDENTIAL_MODEL': 'paytechuz.integrations.django.models.PaynetCredential',
    },
    'UZUM': {
        'KASSAS': {
            'shop': {'SERVICE_ID': '...', 'USERNAME': '...', 'PASSWORD': '...',
                     'ALLOWED_IPS': ['...'], 'IS_SANDBOX': False},
        },
        'IP_HEADER': 'HTTP_X_REAL_IP',   # where your proxy puts the caller's address
        'BEHIND_CLOUDFLARE': True,       # believe CF-Connecting-IP from Cloudflare only
    },
}
```

- **Separate books.** Every row in `payments` carries its `kassa`, and every
  lookup is scoped to the kassa that called. One kassa never sees, performs,
  cancels or reports another's transactions, and the same provider
  transaction id may exist once per kassa.
- **`KASSA_FIELD`** names a field on your account model that holds the kassa
  it must be paid through. A call from any other kassa is told the account
  does not exist. A Paynet kassa may set `ACCOUNT_KASSA` when the value stored
  on accounts differs from its key in `KASSAS`.
- **Sandbox (`IS_SANDBOX`, Paynet and Uzum).** Payments are recorded, but
  `sandbox_payment(params, transaction)` is called instead of
  `successfully_payment`. The account stays payable for the provider's tester,
  and sandbox rows stay out of live statements.
- **Paynet passwords.** `ChangePassword` stores the new password in
  `CREDENTIAL_MODEL` (by default the bundled `PaynetCredential`, table
  `paynet_service_credentials`). The settings' `PASSWORD` applies until Paynet
  rotates it. A wrong login answers error 412 with HTTP 401.
- **Uzum IP allowlist.** `ALLOWED_IPS` is per kassa. The caller is read from
  `IP_HEADER` (default `REMOTE_ADDR`). With `BEHIND_CLOUDFLARE`,
  `CF-Connecting-IP` is believed only when the request itself came from one
  of Cloudflare's published edge ranges.

The single-kassa settings shown earlier keep working unchanged. Their rows
have `kassa = ''`.

### Hooks run in the payment's transaction

`successfully_payment` (and `sandbox_payment`) run inside the same database
transaction as the row that records the payment. If a hook raises, nothing is
marked paid and the provider gets an error, so it retries: Payme `-32400`,
Click `-7`, Paynet `102`, Uzum `99999`.

Payme's `SetFiscalData` is supported. The receipt is kept in the
transaction's `extra_data['fiscal']`, then
`fiscal_data_received(params, transaction)` is called.

## FastAPI Integration

1. Set up the database models:

```python
from datetime import datetime, timezone

from sqlalchemy import create_engine, Column, Integer, String, Numeric, DateTime
from sqlalchemy.orm import declarative_base, sessionmaker

from paytechuz.integrations.fastapi import run_migrations

SQLALCHEMY_DATABASE_URL = "sqlite:///./payments.db"
engine = create_engine(SQLALCHEMY_DATABASE_URL)

Base = declarative_base()


class Order(Base):
    __tablename__ = "orders"

    id = Column(Integer, primary_key=True, index=True)
    product_name = Column(String, index=True)
    amount = Column(Numeric(12, 2))
    status = Column(String, default="pending")
    created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))


# Create the paytechuz payments table
run_migrations(engine)

# Create your own tables
Base.metadata.create_all(bind=engine)

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
```

2. Create the webhook routes:

```python
from fastapi import FastAPI, Request, Depends
from sqlalchemy.orm import Session

from paytechuz.integrations.fastapi import PaymeWebhookHandler, ClickWebhookHandler

app = FastAPI()


def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()


class CustomPaymeWebhookHandler(PaymeWebhookHandler):
    def successfully_payment(self, params, transaction):
        order = self.db.query(Order).filter(Order.id == transaction.account_id).first()
        order.status = "paid"
        self.db.commit()

    def cancelled_payment(self, params, transaction):
        order = self.db.query(Order).filter(Order.id == transaction.account_id).first()
        order.status = "cancelled"
        self.db.commit()


class CustomClickWebhookHandler(ClickWebhookHandler):
    def successfully_payment(self, params, transaction):
        order = self.db.query(Order).filter(Order.id == transaction.account_id).first()
        order.status = "paid"
        self.db.commit()

    def cancelled_payment(self, params, transaction):
        order = self.db.query(Order).filter(Order.id == transaction.account_id).first()
        order.status = "cancelled"
        self.db.commit()


@app.post("/payments/payme/webhook")
async def payme_webhook(request: Request, db: Session = Depends(get_db)):
    handler = CustomPaymeWebhookHandler(
        db=db,
        payme_id="your_merchant_id",
        payme_key="your_merchant_key",
        account_model=Order,
        account_field='id',
        amount_field='amount',
    )
    return await handler.handle_webhook(request)


@app.post("/payments/click/webhook")
async def click_webhook(request: Request, db: Session = Depends(get_db)):
    handler = CustomClickWebhookHandler(
        db=db,
        service_id="your_service_id",
        secret_key="your_secret_key",
        account_model=Order,
        account_field='id',
        amount_field='amount',
        one_time_payment=True,
    )
    return await handler.handle_webhook(request)
```

> The FastAPI integration currently ships webhook handlers for Payme and Click.
> Uzum, Paynet and Octo webhooks are available for Django.

## The transaction table

Both integrations record every callback in one table, `payments`, so you rarely
need provider-specific queries.

```python
from paytechuz.integrations.django.models import PaymentTransaction

paid = PaymentTransaction.objects.filter(
    gateway=PaymentTransaction.PAYME,
    state=PaymentTransaction.SUCCESSFULLY,
)
```

| Column | Meaning |
| --- | --- |
| `gateway` | `payme`, `click`, `uzum`, `paynet` or `octo` |
| `kassa` | the kassa that took the call; `''` in a single-kassa setup |
| `transaction_id` | the provider's id; unique together with `gateway` and `kassa` |
| `account_id` | your order's primary key, as a string |
| `amount` | in som, not tiyin |
| `state` | see below |
| `reason` | provider cancellation code, when one was sent |
| `extra_data` | the raw callback payload |
| `created_at` / `performed_at` / `cancelled_at` | timestamps |

States:

| Value | Constant | Meaning |
| --- | --- | --- |
| `0` | `CREATED` | row exists, nothing confirmed |
| `1` | `INITIATING` | provider created the transaction |
| `2` | `SUCCESSFULLY` | paid |
| `-1` | `CANCELLED_DURING_INIT` | cancelled before it was performed |
| `-2` | `CANCELLED` | cancelled after a successful payment |

> **Note on the Django app label.** The integration is installed as
> `paytechuz.integrations.django`, so Django derives the app label `django` and
> its migrations are recorded under that name. This is why `makemigrations`
> output and `django_migrations` rows mention an app called `django`.

## Project layout

```
paytechuz/
├── core/                     # shared base classes, HTTP client, exceptions, utils
├── gateways/                 # one package per provider (client + constants)
│   ├── payme/  click/  uzum/  paynet/  octo/
└── integrations/
    ├── django/               # models, admin, signals, migrations
    │   ├── webhooks/         # one webhook handler per provider
    │   └── views.py          # CSRF-exempt base views
    └── fastapi/              # SQLAlchemy models, pydantic schemas, handlers
```

`docs/abstract_webhook.md` describes the shared webhook contract and the
checklist to follow when adding a new provider.

## Development

```bash
make install-dev   # editable install with django, fastapi and dev extras
make test          # run the test suite
make lint          # flake8
make build         # build sdist + wheel into dist/
```

## Contributing

Pull requests are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) covers the setup,
what CI checks, and the extra care that amount handling and webhook protocols
need. `docs/abstract_webhook.md` is the contract to follow when adding a
gateway.

Found a security issue? Do not open an issue — see [SECURITY.md](SECURITY.md).

## License

MIT — see [LICENSE](LICENSE).
