Skip to main content

A simple client for the Kapital payment gateway.

Project description

Kapital Payment Gateway Client

kapital is a Python client for the Kapital Bank payment gateway, designed to simplify the process of creating and managing payment orders. This library provides a straightforward interface to interact with the Kapital Bank API, making it easier to integrate payment functionality into your applications.

Features

  • Create payment orders with customizable parameters.
  • Supports basic authentication for secure API access.
  • Handles JSON payloads and responses seamlessly.

Installation

You can install the kapital package via pip. It's recommended to create a virtual environment for your project.

pip install kapital

Usage

Here’s a quick guide on how to use the kapital client.

Importing the Client

from kapital import Kapital

Initializing the Client

To use the client, initialize it with your credentials. If you don't provide any credentials, default values will be used.

client = Kapital(
    base_url="https://e-commerce.kapitalbank.az/api",
    username="your-username",
    password="your-password"
)

Creating a Payment Order

You can create a payment order by calling the create_order method. Here's an example:

response = client.create_order(
    redirect_url="https://your-redirect-url.com",
    amount=100.00,
    description="Payment for Order #123",
    currency="AZN",
    language="az"
)

print(response)

Response Structure

The create_order method returns a dictionary containing the following keys:

  • order_id: The unique identifier for the order.
  • password: The password for the order.
  • hppUrl: The URL for redirecting the user to complete the payment.
  • status: The status of the order.
  • cvv2AuthStatus: The CVV2 authentication status.
  • secret: A secret value associated with the order.
  • redirect_url: The full URL to redirect the user for payment.

Example Response

{
    "order_id": "123456",
    "password": "secret_password",
    "hppUrl": "https://payment-url.com",
    "status": "pending",
    "cvv2AuthStatus": "approved",
    "secret": "order_secret",
    "redirect_url": "https://payment-url.com?id=123456&password=password"
}

Error Handling

The client raises exceptions for various error cases, such as:

  • If the response status code is not 200, an Exception will be raised.
  • If the response format is invalid, a ValueError will be raised indicating the specific issue.
try:
    response = client.create_order(
        redirect_url="https://your-redirect-url.com",
        amount=100.00,
        description="Payment for Order #123"
    )
except Exception as e:
    print(f"An error occurred: {e}")

Contributing

Contributions are welcome! If you have suggestions for improvements or want to report bugs, please open an issue or submit a pull request.

License

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

Authors

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

kapital-0.2.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

kapital-0.2.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file kapital-0.2.2.tar.gz.

File metadata

  • Download URL: kapital-0.2.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for kapital-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ddd5d9729e70ef054a8cb379eb450256d968c14c60d0c08206e1dbc205b5587a
MD5 098dfbc939aae1c138c65d521de0c5fd
BLAKE2b-256 c6eef0ce0c2c2a3e2d2ab68d29bf9ff1261b7b68d14d0512ffad6a5b42883d34

See more details on using hashes here.

File details

Details for the file kapital-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: kapital-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for kapital-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 de1be83adaf73b168edeccd7d4fccced8b7e318d2d13ef74c9d3b4d57ce56319
MD5 3d88de78a1dbff12368c1f2349fd3f2a
BLAKE2b-256 3e1abc426f328e93accd1b379137c94975461bbf23894fd9dc5b20d249e6f837

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