Skip to main content

Library for communication with ČSOB API

Project description

CSOB client

Python library for communicating with ČSOB (https://platbakartou.csob.cz/) payment gateway API. The API is described here: https://github.com/csob/paymentgateway.

The library focuses on the v.1.9 but it is designed for extensibility.

Installation

pip install csobclient

Basic usage

Client initialization

from csobclient import Client

client = Client("merchantId", "merch_private.key", "csob.pub")

Payment initialization

from csobclient import Cart, CartItem

response = client.init_payment(
    order_no="2233823251",
    total_amount=100,
    return_url="http://127.0.0.1:5000/",
    cart=Cart([CartItem("Apples", 1, 100)]),
    merchant_data=b"Hello, World!",
)

Get payment URL

url = client.get_payment_process_url(pay_id)

Process the gateway redirect

payment_info = client.process_gateway_return(data_dict)

Get payment status

payment_info = client.get_payment_status(pay_id)

Reverse payment

response = client.reverse_payment(pay_id)

Exceptions handling

from csobclient import APIError, HTTPRequestError

try:
    client.operation(...)
except APIError as exc:
    # handle API error
except HTTPRequestError as exc:
    # handle HTTP error

RSA keys management

The simples way to pass RSA keys is to pass their file paths:

from csobclient import Client

client = Client("merchantId", "merch_private.key", "csob.pub")

The library will read the private key from the file when needed. The public key will be cached into the RAM.

If you want to change it, use special classes:

from csobclient import Client, FileRSAKey, CachedRSAKey

client = Client("merchantId", FileRSAKey("merch_private.key"), FileRSAKey("csob.pub"))

You may also override the base RSAKey class to define your own key access strategy:

from csobclient import RSAKey

class MyRSAKey(RSAKey):

    def __str__(self) -> str:
        return "my key"

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

csobclient-0.2.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

csobclient-0.2.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file csobclient-0.2.0.tar.gz.

File metadata

  • Download URL: csobclient-0.2.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.9 Linux/5.15.0-1034-azure

File hashes

Hashes for csobclient-0.2.0.tar.gz
Algorithm Hash digest
SHA256 89cd83cf4e22b6ea212080ebbf3f5e2d458d9ba5b2d7494ef73704a2b10f0c40
MD5 1ec59863eed0fc19580849424428eea4
BLAKE2b-256 c1cf37a39564039340380831ff607c289809a5a9de372bca65ce159ff90cee08

See more details on using hashes here.

File details

Details for the file csobclient-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: csobclient-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.9 Linux/5.15.0-1034-azure

File hashes

Hashes for csobclient-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9411e0e497fcb6c66bbfae8e1336a36dbb19debb486514b2085ec2bdf2ce2ad1
MD5 9e912b62eab6551b6763eb367ad245a1
BLAKE2b-256 5b83c3a39d0810796c41bce1914cf5a4606e7abc74997092f41c736ec6a5a529

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