Skip to main content

bepaid

Python client for the bePaid payment API (bepaid.by).

Covers the Gateway API (card payments, tokenization, saved-card charges, capture, void, refunds, payouts, recipient tokenization), the hosted Checkout API (checkout, payment token, Apple Pay), pay-by-link, the Direct/APM API (alternative payment methods, balance and currency queries, split payments), and the Merchant API (reports, channel balances). Built on httpx, pydantic and cryptography.

Install

uv add bepaid
# or
pip install bepaid

Requires Python 3.10+.

Usage

from bepaid import BepaidClient
from bepaid.models import PaymentRequest, CreditCardRaw

client = BepaidClient("shop_id", "secret_key")

# amounts are strings in minor units, e.g. "700" = 7.00 BYN
payment = client.create_payment(
    PaymentRequest(
        amount="700",
        currency="BYN",
        test=True,
        description="Order #123",
        tracking_id="order-123",
        credit_card=CreditCardRaw(
            number="4242424242424242",
            verification_value="123",
            holder="John Smith",
            exp_month=10,
            exp_year=2030,
            save_card=True,
        ),
    )
)

Async

AsyncBepaidClient mirrors the synchronous API and supports async with:

from bepaid import AsyncBepaidClient

async with AsyncBepaidClient("shop_id", "secret_key") as client:
    payment = await client.create_payment(...)

# or without the context manager:
client = AsyncBepaidClient("shop_id", "secret_key")
try:
    payment = await client.create_payment(...)
finally:
    await client.aclose()

BepaidClient is a thin synchronous wrapper around AsyncBepaidClient (each call runs on a fresh event loop, so it does not reuse connections); prefer the async client inside an asyncio application.

Authorization with 3-D Secure

auth = client.create_authorization(AuthorizationRequest(amount=700, currency="BYN", ...))
# redirect the customer to auth.redirect_url, then poll for the result:
tx = client.get_transaction(auth.uid)

Hosted checkout

checkout = client.create_checkout(
    CheckoutRequest(
        transaction_type="payment",
        order=CheckoutOrder(currency="BYN", amount=700, description="Order #123"),
        settings=CheckoutSettings(
            return_url="https://example.com/return",
            notification_url="https://example.com/webhook",
        ),
    )
)
# redirect the customer to checkout.redirect_url

Tokenization

token = client.create_token(
    CreateTokenRequest(
        number="4200000000000000",
        holder="John Smith",
        exp_month="05",
        exp_year="2028",
        contract=["recurring"],
    )
)
# store token.token, use it later without re-entering card details

APM payments (Direct API)

apm = client.create_apm_payment(
    ApmPaymentRequest(
        amount=700,
        currency="BYN",
        payment_method={"type": "erip", "service_no": "0000000001"},
    )
)

Webhooks

from bepaid.client import verify_webhook_auth
from bepaid.models import WebhookNotification

assert verify_webhook_auth(authorization_header, shop_id, secret_key)
notification = WebhookNotification.model_validate_json(raw_body)

Examples

Ready-to-run scripts under examples/:

Example Run
payment.py SHOP_ID=363 SECRET_KEY=secret uv run python examples/payment.py
subscriptions.py SHOP_ID=363 SECRET_KEY=secret uv run python examples/subscriptions.py

API coverage

Group Operations
Gateway create_payment, create_authorization, capture, void, refund, get_transaction, get_transaction_by_tracking_id, create_p2p, create_payout, charge_saved_card, tokenize_recipient_card
Tokens create_token
Checkout create_checkout, get_checkout_status, validate_apple_pay, create_payment_token, apple_pay_payment
Direct create_apm_payment, apm_refund, apm_full_refund, confirm_apm_payment, get_balance, get_currencies, create_split_payment
Pay-by-link create_product, list_products, get_product, update_product
Subscriptions create_customer, get_customer, list_customers, create_plan, get_plan, list_plans, create_subscription, get_subscription, cancel_subscription, get_plan_payment_link
Merchant get_reports, get_report_count, get_channel_balances
Webhooks verification (Basic auth + RSA Content-Signature) + payload parsing (transaction & subscription)

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bepaid-0.5.10.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bepaid-0.5.10-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file bepaid-0.5.10.tar.gz.

File metadata

  • Download URL: bepaid-0.5.10.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bepaid-0.5.10.tar.gz
Algorithm Hash digest
SHA256 501a151017c7f0175b15411ed08863315f2da0294c817d08f87a948f8886dfb7
MD5 8f1a5fddaa1ffb04292d7273d73d4e33
BLAKE2b-256 7e48700ed2c1a810c079e97d5c6438c6d0bbda61bb3f38791ca8b852e4afe159

See more details on using hashes here.

File details

Details for the file bepaid-0.5.10-py3-none-any.whl.

File metadata

  • Download URL: bepaid-0.5.10-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bepaid-0.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 bb6c3b5b0a2f97a67043460020420105749a6c1ae7f12b1f78e79ba9601b79c2
MD5 a8ecf4b45883af6a78fe1cb2e64bb939
BLAKE2b-256 61a01cebade723a8665a8501fdffbe44ca9489caf6f95d7a94131c62676ac8b3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.11

2 files

This release

0.5.10 This release

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 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