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 i_payment 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 i_payment 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 i_payment 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
Release history Release notifications | RSS feed
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.2.tar.gz
(5.8 kB
view details)
File details
Details for the file i_payment-0.1.2.tar.gz.
File metadata
- Download URL: i_payment-0.1.2.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9492dc54590a9d0d64225faec33dafae28991c564751a4bfe37a64b948c71cb
|
|
| MD5 |
c42c25ab4256cd6ca027d27a1bb9c84d
|
|
| BLAKE2b-256 |
0ff11f60519ec09c52495ed362e9f1c19721ec89f7c718ce92c852f152c1bc1f
|