Skip to main content

tbc-payments

PyPI

tbc-payments is a small, typed Python client for TBC Checkout. It helps a backend create a checkout session, redirect the customer to TBC's payment page, and later verify or manage the payment.

It has synchronous and asynchronous clients with the same API. The package manages access tokens and HTTP connections; it never handles card details.

What it supports

  • Creating and looking up Checkout payments.
  • Cancelling payments and completing pre-authorizations.
  • Creating and deleting recurring-payment registrations.
  • TBC Installment requests.
  • Production and sandbox URLs.
  • Typed models, structured API errors, timeouts, and conservative retries.

Installation

pip install tbc-payments

Python 3.10 or newer is required.

Create a payment

from tbc_payments import Amount, PaymentMethod, PaymentRequest, TBCClient

payment_request = PaymentRequest(
    amount=Amount("49.90"),
    return_url="https://shop.example.com/payments/return",
    callback_url="https://shop.example.com/webhooks/tbc",
    merchant_payment_id="order-1842",
    methods=(PaymentMethod.CARD, PaymentMethod.APPLE_PAY),
)

with TBCClient("api-key", "client-id", "client-secret") as tbc:
    payment = tbc.create_payment(payment_request)

redirect_url = payment.approval_url

Redirect the customer to redirect_url. A merchant_payment_id should be unique in your system so an ambiguous request can be reconciled safely.

Check the result

Treat the callback as a notification, not as confirmation that an order is paid. Return HTTP 200 promptly, then fetch the payment from TBC and fulfil the order only once.

payment = tbc.get_payment(callback_payload["PaymentId"])
if payment.status == "Succeeded":
    fulfil_order_once(payment.pay_id)

Async

from tbc_payments import Amount, AsyncTBCClient, PaymentRequest

async with AsyncTBCClient("api-key", "client-id", "client-secret", sandbox=True) as tbc:
    payment = await tbc.create_payment(
        PaymentRequest(Amount("1.00"), "https://shop.example.com/payments/return")
    )

Installments and recurring payments

Use PaymentMethod.INSTALLMENT with products whose total matches the payment amount:

from tbc_payments import InstallmentProduct, PaymentMethod

request = PaymentRequest(
    amount=Amount("100.00"),
    return_url="https://shop.example.com/payments/return",
    methods=(PaymentMethod.INSTALLMENT,),
    installment_products=(InstallmentProduct("50.00", 2, "Coffee maker"),),
)

For saved cards, enable save_card=True when creating the initial payment and store the returned recurring_id. Call execute_recurring_payment only after your business flow has established the necessary customer consent.

Behaviour worth knowing

  • Amounts may have at most two decimal places. Values are validated rather than silently rounded.
  • Tokens are refreshed before expiry. A failed read may be retried; money-moving requests are not retried automatically.
  • cancel_payment returns None after a successful 200. complete_payment returns CompletionResult.
  • sandbox=True uses https://test-api.tbcbank.ge/v1.

Development

python -m pip install -e '.[dev]'
pre-commit install
pytest
ruff check .
ruff format --check .
mypy
bandit -c pyproject.toml -r src
pip-audit

See CONTRIBUTING.md and SECURITY.md for contribution and vulnerability-reporting guidance.

License

MIT

Metadata

Release files for tbc-payments 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tbc-payments 0.2.0
File Size Uploaded
tbc_payments-0.2.0.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tbc-payments 0.2.0
File Interpreter ABI Platform
tbc_payments-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.2 kB

Release files / tbc_payments-0.2.0.tar.gz

Download URL tbc_payments-0.2.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cf64abba0517e1d4fcce62a913563a1fda8a83f481c1bfe1dae4f28511b69e5f
BLAKE2b-256 checksum
How to use checksums
9c0219f11ed37299b7c115aaaa03a5e6fa9a61d645e2eed61b21a7968465bc60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / tbc_payments-0.2.0-py3-none-any.whl

Download URL tbc_payments-0.2.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ad9cd9bfe50aaf5359e0d615334b3e588381aff8082cad39e14501f0fefdc93
BLAKE2b-256 checksum
How to use checksums
434937f1a91b452f2486bd44afd8759c9256d6eedfa401ceb66519e770156f23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page