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 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


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.1.tar.gz (5.8 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.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: i_payment-0.1.1.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

Hashes for i_payment-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af629b298e32bc6798b387afaaf72d595797bd29f356d014cbf034629ee5ec85
MD5 1cda3cd5e3275ca148daa63be86f6c30
BLAKE2b-256 ed99bd346bed0372b0f16907de003ce7ff1548ec8168795ebdd8c038aebedc97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: i_payment-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19b408cb62a5e378c083f7d3bceae3a0f0b43334399f20e36efa05736f171ee5
MD5 e1b411b39c4208d2a5654db513f7aad5
BLAKE2b-256 2c55fd2340306b23fec71ccadeaf0fecd03bf7e2bacbe8175dca4193891bc461

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