Skip to main content

Python client for the i-payment integration API

Project description

i-payment (Python)

Python client for the i-payment integration API. Supports both sync and async usage.

Installation

pip install i-payment

Quick start

from kaspi_client import KaspiClient

client = KaspiClient(api_key="your-api-key")

# List cashiers attached to your project
cashiers = client.list_cashiers()

# Create an invoice payment
invoice = client.create_invoice(phone="77001234567", amount=5000.0, comment="Order #42")
print(invoice.operation_id)   # OperationId from Kaspi
print(invoice.status)         # "RemotePaymentCreated"

# Generate a QR code for in-person payment
qr = client.create_qr(amount=1500.0)
print(qr.qr_token)            # base64 QR image token
print(qr.qr_operation_id)     # poll status with this

# Poll QR status
status = client.qr_status(qr.qr_operation_id)
print(status.status)          # "WaitingForPayment" | "Paid" | "Expired"

# Refund
client.create_refund(qr_operation_id=12345678, return_amount=1500.0)

# Context manager (auto-closes HTTP session)
with KaspiClient(api_key="your-api-key") as c:
    history = c.invoice_history(max_result=50)

Async

import asyncio
from kaspi_client import AsyncKaspiClient

async def main():
    async with AsyncKaspiClient(api_key="your-api-key") as client:
        qr = await client.create_qr(amount=2000.0)
        print(qr.qr_token)

asyncio.run(main())

Methods

Method Description
list_cashiers() Cashiers for the project
client_info(phone) Kaspi customer lookup
create_invoice(phone, amount, comment?) Invoice to customer's Kaspi app
invoice_details(operation_id) Invoice status
cancel_invoice(operation_id) Cancel pending invoice
invoice_history(max_result?) Recent invoice history
create_qr(amount, latitude?, longitude?) QR code payment
qr_status(qr_operation_id) QR payment status
operations_history(end_date, ...) Transaction history
operation_details(operation_id) Single operation details
create_refund(qr_operation_id, return_amount) Refund a QR payment

Errors

from kaspi_client import ValidationError, AuthenticationError, RateLimitError

try:
    client.create_invoice(phone="bad", amount=-1)
except ValidationError as e:
    print(e.status_code, str(e))
except AuthenticationError:
    print("Check your API key")

Options

client = KaspiClient(
    api_key="your-api-key",
    base_url="https://api.ipay.kz",  # default
    timeout=30.0,                     # seconds
)

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

i_payment-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

i_payment-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file i_payment-0.1.0.tar.gz.

File metadata

  • Download URL: i_payment-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for i_payment-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66ac037ce3b1441d864725ee44ce16aa9784a0d9e4e173aa24f3eadb58f85f02
MD5 ec8d38049938a0cf69461a13957abec8
BLAKE2b-256 c10e366774b3a4f32ee8fd5bf14adc0f0d75c4b8a06cbafd48f5659f809d4e6d

See more details on using hashes here.

File details

Details for the file i_payment-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: i_payment-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for i_payment-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0722be12cffe1fa4ad9f86df3d6860b79a07a1824b19db521299a3aaa5a9e2f
MD5 1f0c0ed1def19208f290ce7d65446cac
BLAKE2b-256 3e758723ca47f02307ffe982fe16d3af772953fdb0178e4aa94718054f7f375e

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