Metadata-Version: 2.4
Name: paylabs-sdk
Version: 1.0.0
Summary: Official Python SDK for Paylabs Payment Gateway & SNAP Remit API
Project-URL: Homepage, https://paylabs.co.id
Project-URL: Documentation, https://docs.paylabs.co.id
Project-URL: Repository, https://github.com/paylabs/paylabs-python-sdk
Project-URL: Issues, https://github.com/paylabs/paylabs-python-sdk/issues
Author-email: Paylabs Developer Team <developer@paylabs.co.id>
License: MIT
License-File: LICENSE
Keywords: disbursement,indonesia,paylabs,payment-gateway,qris,sdk,snap,virtual-account
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: pycryptodome>=3.15.0
Requires-Dist: pytz>=2023.3
Requires-Dist: requests>=2.28.0
Provides-Extra: async
Requires-Dist: httpx>=0.24.0; extra == 'async'
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: responses>=0.23.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Requires-Dist: twine>=4.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# Paylabs Python SDK (`paylabs-sdk`)

Official Python SDK for Paylabs Payment Gateway (Payin API).

[![PyPI Version](https://img.shields.io/pypi/v/paylabs-sdk.svg)](https://pypi.org/project/paylabs-sdk/)
[![Python Versions](https://img.shields.io/pypi/pyversions/paylabs-sdk.svg)](https://pypi.org/project/paylabs-sdk/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

---

## 🚀 Fitur Utama

- 💳 **Payin API**: QRIS, Virtual Account (BCA, Mandiri, BRI, BNI, dll), H5 Link, Credit Card, E-Wallet, Retail OTC Store.
- 🔐 **Keamanan RSA SHA256**: Otomatisasi penandatanganan request (`X-SIGNATURE`) dan verifikasi callback notification.
- ⚡ **PEP 561 Compliant**: Lengkap dengan Type Annotations (`py.typed`) untuk Autocomplete maksimal di IDE (VS Code / PyCharm).
- 🛠️ **Error Handling Terstruktur**: Handling error API dan signature melalui `PaylabsAPIError` & `PaylabsSignatureError`.

---

## 📦 Instalasi

```bash
pip install paylabs-sdk
```

---

## 💻 Penggunaan Quickstart

### 1. Inisialisasi Client (Context Manager / Standard)
```python
from paylabs import PaylabsClient, Environment

# Opsi A: Menggunakan Context Manager (Rekomendasi untuk auto-close HTTP session)
with PaylabsClient(
    merchant_id="YOUR_MERCHANT_ID",
    private_key=open("private_key.pem").read(),
    public_key=open("public_key.pem").read(),
    environment=Environment.SANDBOX,  # Gunakan Environment.PRODUCTION untuk live
) as client:
    response = client.payin.create_qris(amount=15000, product_name="Kopi Espresso")
    print("QR Code String:", response.get("qrCode"))

# Opsi B: Standard Instance
client = PaylabsClient(
    merchant_id="YOUR_MERCHANT_ID",
    private_key=open("private_key.pem").read(),
    public_key=open("public_key.pem").read(),
    environment=Environment.SANDBOX,
)
```

### 2. Transaksi QRIS
```python
from paylabs.exceptions import PaylabsAPIError

try:
    response = client.payin.create_qris(
        amount=15000,
        product_name="Kopi Espresso",
        notify_url="https://domainanda.com/callback",
    )
    print("QR Code String:", response.get("qrCode"))
except PaylabsAPIError as e:
    print(f"API Error [{e.err_code}]: {e.err_msg}")
```

### 3. Virtual Account (BCA, Mandiri, BRI, BNI, dll)
```python
response = client.payin.create_va(
    payment_type="BCAVA",
    amount=50000,
    product_name="Kaos Polos",
    payer="Budi",
)
print("Nomor VA:", response.get("vaCode"))
```

### 4. H5 Payment Link
```python
response = client.payin.create_h5(
    amount=25000,
    phone_number="081234567890",
    product_name="Voucher Game",
    redirect_url="https://domainanda.com/finish",
)
print("Payment Link URL:", response.get("redirectUrl"))
```

### 5. Verifikasi Callback Notification
```python
is_valid = client.verify_callback_signature(
    path="/callback",
    raw_body_or_json=raw_json_body_string,
    signature=headers.get("X-SIGNATURE"),
    timestamp=headers.get("X-TIMESTAMP"),
)

if is_valid:
    print("Callback valid dari Paylabs!")
else:
    print("Signature callback tidak valid!")
```

---

## 🛠️ Testing & Development

### Jalankan Unit Test:
```bash
pip install -e .[dev]
pytest tests/ -v
```

### Build Package Manual:
```bash
python -m build
twine check dist/*
```

---

## 📄 Lisensi
[MIT License](LICENSE) © Paylabs Developer Team.
