Metadata-Version: 2.4
Name: mongolian-payment-hipay
Version: 1.0.0
Summary: HiPay payment gateway SDK for Python
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# mongolian-payment-hipay

HiPay payment gateway SDK for Python.

## Installation

```bash
pip install mongolian-payment-hipay
```

## Quick Start

```python
from mongolian_payment_hipay import HiPayClient, HiPayConfig

client = HiPayClient(HiPayConfig(
    endpoint="https://merchant.hipay.mn/api",
    token="YOUR_BEARER_TOKEN",
    entity_id="YOUR_ENTITY_ID",
))

# Create a checkout
checkout = client.checkout(50000)
print(checkout.qr_data)
print(checkout.checkout_id)

# Check checkout status
status = client.get_checkout(checkout.checkout_id)
print(status.status)

# Get payment details
payment = client.get_payment("payment-id")
print(payment.payment_brand)

# Submit a payment correction (refund)
correction = client.payment_correction("payment-id")
print(correction.correction_payment_id)

# Get a statement
statement = client.statement("2026-01-15")
for item in statement.data.list:
    print(item.payment_id, item.amount)
```

## Async Usage

```python
from mongolian_payment_hipay import AsyncHiPayClient, HiPayConfig

async with AsyncHiPayClient(HiPayConfig(
    endpoint="https://merchant.hipay.mn/api",
    token="YOUR_BEARER_TOKEN",
    entity_id="YOUR_ENTITY_ID",
)) as client:
    checkout = await client.checkout(50000)
    print(checkout.qr_data)
```

## Environment Variables

You can load configuration from environment variables:

```python
from mongolian_payment_hipay import HiPayClient, load_config_from_env

# Reads HIPAY_ENDPOINT, HIPAY_TOKEN, HIPAY_ENTITY_ID
config = load_config_from_env()
client = HiPayClient(config)
```

## Checkout with Items

```python
from mongolian_payment_hipay import CheckOutItem, CheckoutOptions

checkout = client.checkout(
    50000,
    CheckoutOptions(
        ip_address="192.168.1.1",
        items=[
            CheckOutItem(
                itemno="SKU001",
                names="Product Name",
                price=25000,
                quantity=2,
                brand="Brand",
                measure="pcs",
                vat=2500,
                citytax=100,
            )
        ],
    ),
)
```

## Error Handling

```python
from mongolian_payment_hipay import HiPayError

try:
    checkout = client.checkout(50000)
except HiPayError as e:
    print(e)           # Error message
    print(e.code)      # Response code
    print(e.details)   # Validation error details
    print(e.response)  # Raw response body
```

## License

MIT
