Skip to main content

Official inPAY Python SDK — create invoices, check status, and verify webhooks for the inPAY payment platform (Uzbekistan).

Project description

inPAY Python SDK

Official Python SDK for the inPAY payment platform (Uzbekistan). One inPAY contract → accept Click, Payme, UzCard/HUMO with a few lines of code.

Bitta inPAY shartnomasi bilan barcha to'lov usullarini qabul qiling.

O'rnatish / Installation

pip install inpay-python

Talab: Python ≥ 3.8. Tashqi bog'liqliksiz (faqat standart kutubxona).

Tez boshlash / Quick start

from inpay import InPay

inpay = InPay(
    merchant_id=12345,          # kassa merchant_id
    bearer_token="xxxxxxxx",    # kassa bearer token
    webhook_secret="yyyyyyyy",  # webhook imzosi uchun
)

# 1) To'lov yaratish
invoice = inpay.create(
    amount=50000,                       # so'm (min 1000)
    callback_url="https://shop.uz/inpay/webhook",
    order_id="A-123",                   # sizning ichki reference
)

print(invoice.pay_url)   # foydalanuvchini shu manzilga yo'naltiring

invoice:

Atribut Izoh
invoice.order_id inPAY buyurtma ID (16 hex)
invoice.pay_url Universal checkout sahifasi
invoice.pay_url_link So'ralgan usulga mos to'g'ridan havola
invoice.pay_links {"click": ..., "payme": ...} to'g'ridan havolalar

To'g'ridan-to'g'ri bitta usul

invoice = inpay.create(amount=50000, payment_method="click")  # "click"|"payme"|"myuzcard"

2) Holatni tekshirish / Status

tx = inpay.status("a1b2c3d4e5f6a7b8")
if tx.is_paid:
    ...
# tx.status: "pending" | "success" | "failed"

3) Webhook (payment.success)

inPAY to'lov muvaffaqiyatli bo'lganda callback_url'ingizga POST yuboradi va uni X-InPAY-Signature (HMAC-SHA256) bilan imzolaydi. SDK imzoni constant-time tekshiradi.

Flask misoli:

from flask import Flask, request
from inpay import InPay
from inpay.exceptions import SignatureError

app = Flask(__name__)
inpay = InPay(merchant_id=12345, bearer_token="xxxxxxxx", webhook_secret="yyyyyyyy")

@app.post("/inpay/webhook")
def inpay_webhook():
    sig = request.headers.get("X-InPAY-Signature", "")
    try:
        tx = inpay.webhook().verify(request.get_data(as_text=True), sig)
    except SignatureError:
        return {"ok": False}, 401

    if tx.is_paid:
        # ⚠️ IDEMPOTENT bo'ling — takror kelishi mumkin
        # if already_paid(tx.order_id): return {"ok": True}
        # mark_paid(tx.order_id, tx.amount)
        ...
    return {"ok": True}

Xavfsizlik: imzo tekshiruvidan o'tmagan webhook'ni HECH QACHON to'lov deb qabul qilmang.

Xatolar / Errors

from inpay.exceptions import ApiError, SignatureError, InPayError

try:
    inpay.create(amount=50000)
except ApiError as e:
    print(e.error_code)   # masalan "MERCHANT_INACTIVE", "AMOUNT_TOO_LOW"

Litsenziya

MIT © inPAY

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inpay_python-1.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inpay_python-1.0.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file inpay_python-1.0.0.tar.gz.

File metadata

  • Download URL: inpay_python-1.0.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for inpay_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0b5a453bd9d8d7b54b76b52d45c27b804caf2d8439e5c4495933c02c4211eb67
MD5 c093097a4ed606d507d0fdf2f024e9b0
BLAKE2b-256 992bae076d7cf5cc4631cb05ebad74a2b619a093a5381c280e94ba90ebac3348

See more details on using hashes here.

File details

Details for the file inpay_python-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: inpay_python-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for inpay_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b84cf91961569103c647b12de240ffb0f7342841e083ee4024aa50ed3480d4e8
MD5 4ac9ab4d8476d5c6376671a34ee14a61
BLAKE2b-256 dcf6f265d6451a7e2e5177118efee74283b694c39b8d5116e01f84b949bacdc3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page