Skip to main content

An unofficial Python wrapper for Tirikchilik API.

Project description

Tirikchilik

PyPI version Python Versions License: MIT PyPI Downloads

Donate with Tirikchilik

Tirikchilik is an unofficial Python library for interacting with the Tirikchilik payment API. It provides a simple and efficient way to create payments, check payment statuses, and handle various payment-related operations.

Note: This is an unofficial API wrapper and is not affiliated with or endorsed by Tirikchilik. Use at your own risk.

Features

  • Easy-to-use interface for creating payments
  • Automatic project ID retrieval by project name
  • Robust error handling for various API responses
  • Retry mechanism for failed requests
  • Type hinting for better code completion and error detection
  • Customizable session management

Installation

You can install Tirikchilik using pip:

pip install tirikchilik

Quick Start

Here's a simple example to get you started with Tirikchilik:

from tirikchilik import Tirikchilik

# Initialize the Tirikchilik client
client = Tirikchilik("MyProject")

# Create a payment
try:
    payment_response = client.create_payment(
        amount=1000,
        donater="John Doe",
        notes="Donation for Project X",
        card_number="1234567890123456",
        expiry="12/25"
    )

    # Get payment ID and checkout URL
    payment_id = payment_response['data']['payId']
    checkout_url = payment_response['data']['checkoutUrl']

    print(f"Payment ID: {payment_id}")
    print(f"Checkout URL: {checkout_url}")

    # Check payment status
    status_response = client.get_payment_status(payment_id)
    print(f"Payment status: {status_response['data']}")

except Exception as e:
    print(f"Error: {str(e)}")

Advanced Usage

Error Handling

Tirikchilik provides custom exceptions for different error scenarios:

from tirikchilik import Tirikchilik, CardNotFoundError, PaymentNotFoundError, UserNotFoundError, PaymentError

client = Tirikchilik("MyProject")

try:
    payment = client.create_payment(...)
except CardNotFoundError as e:
    print(f"Card not found: {e}")
except PaymentNotFoundError as e:
    print(f"Payment not found: {e}")
except UserNotFoundError as e:
    print(f"User not found: {e}")
except PaymentError as e:
    print(f"General payment error: {e}")

API Reference

Tirikchilik(project_name: str)

Initialize a Tirikchilik client.

  • project_name: The name of the project to use for payments.

create_payment(amount: int, donater: str, notes: str, card_number: str, expiry: str) -> Dict[str, Any]

Create a new payment.

  • amount: The payment amount in cents.
  • donater: The name of the person making the donation.
  • notes: Additional notes for the payment.
  • card_number: The card number to use for the payment.
  • expiry: The expiry date of the card in the format "YYMM". Example if the expiry date is December 2025, you should set "2512".

Returns a dictionary with the payment details. Example:

{
    'data': {
        'payId': 'ecdd416a-1bba-4047-9ebb-808b24424487',
        'checkoutUrl': 'https://checkout.multicard.uz/8ba58fb9-7b33-11ef-bfaa-00875680eaf6',
        'donateAmount': 500000,
        'commissionAmount': 26326,
        'totalAmount': 526512
    },
    'success': True,
    'error': None
}   
  • payId: The ID of the payment.
  • checkoutUrl: The URL to redirect the user to complete the payment.
  • donateAmount: The amount donated by the user. Remember you should increase amount to x100. For example, if you want to donate 5000 UZS, you should set 5000 * 100 = 500000.
  • commissionAmount: The commission amount calculated by the system.
  • totalAmount: The total amount to be paid by the user.

get_payment_status(payment_id: int) -> Dict[str, Any]

Get the status of a payment.

  • payment_id: The ID of the payment to check.

Returns a dictionary with the payment status. Example if the payment is successful:

{
    'data': 'Paid',
    'success': True,
    'error': None
}

Or if payment is in draft (not paid) status:

{
    'data': 'Draft',
    'success': True,
    'error': None
}

Dependencies

Tirikchilik depends on the following packages:

  • requests (~2.32.3)
  • urllib3 (~2.2.3)

These dependencies will be automatically installed when you install Tirikchilik.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Support

If you like this project, please consider supporting it by making a donation:

Donate with Tirikchilik

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This is an unofficial API wrapper for Tirikchilik. It is not affiliated with, endorsed, or supported by Tirikchilik. Use this library at your own risk. The authors and contributors are not responsible for any misuse or damage caused by this software.

Acknowledgments

  • Built with love for the Python community
  • Inspired by modern Python API clients

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

tirikchilik-0.0.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

tirikchilik-0.0.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file tirikchilik-0.0.1.tar.gz.

File metadata

  • Download URL: tirikchilik-0.0.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for tirikchilik-0.0.1.tar.gz
Algorithm Hash digest
SHA256 83f59c16082c56b591757ae3f4032fdb561bf12ba466122e06555dbad20b6a54
MD5 1e710ebe74dc19b74bf5596e92ff5db7
BLAKE2b-256 487bd6a23592418a59c46ee3ee5ec9ae7c1337b3ffa79d48dd2d281816718f7c

See more details on using hashes here.

File details

Details for the file tirikchilik-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tirikchilik-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for tirikchilik-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05fccd82e81b311a20582c639c1b7093141f305a3be7695f6f3eaa51b198f9c3
MD5 67289c497677d7a26273d3bff3dcce78
BLAKE2b-256 cfdb013c077a7ad5395f805f04613ae189c2d5f9deac7ae8304bfbff8ebaf997

See more details on using hashes here.

Supported by

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