Skip to main content

southbill (Python)

Official Python SDK for the Southbill API. No third-party dependencies — standard library only. Requires Python 3.8+.

pip install southbill

Not yet published on PyPI. Until the first release, install from the repository.

Quick start

from southbill import Southbill

southbill = Southbill()  # or Southbill("sk_live_...")

session = southbill.checkout.sessions.create(
    amount=4900,
    currency="EUR",
    customer_email="ada@acme.com",
    success_url="https://acme.com/thanks",
)

print(session["checkout_url"])

The Merchant API accepts live keys only (sk_live_... for server calls, pk_live_... for publishable/browser use). Legacy sk_test_... keys are rejected with 401 authentication_error — sandbox testing happens on the Developer Platform, not through merchant keys.

Errors carry a machine-readable error.type plus an optional error.code:

type When
authentication_error Missing, malformed, revoked or expired key
permission_error Key lacks the required scope, or merchant is suspended
invalid_request Bad input; code: "resource_missing" for unknown IDs (404)
idempotency_error code: "idempotency_key_reused" (same key, different body) or code: "idempotency_in_flight" (same key still processing — retry shortly)
rate_limit_error code: "rate_limit_exceeded" — retry after Retry-After
already_refunded, charge_disputed Refund not possible for that charge
product_limit_reached, account_not_ready, invalid_state Plan or account state blocks the call
stripe_error, api_error Upstream or internal failure (502 / 500)

Note: the App API (OAuth apps) uses not_found as an error type, while the Merchant API returns invalid_request with code: "resource_missing" instead.

Resources

Namespace Methods
checkout.sessions create, retrieve, list, expire
customers create, retrieve, update, list, delete
invoices create, retrieve, update, list, send, void, mark_paid
products create, retrieve, update, list
payments retrieve, list
refunds create
subscriptions create, retrieve, list, cancel
events retrieve, list, replay

Payouts, bank details, KYC and API-key management stay merchant-controlled in the dashboard and are intentionally not part of the API surface.

Idempotency

Every POST sends an Idempotency-Key header (random UUID). Pass your own for safe retries across processes:

southbill.invoices.create(idempotency_key=f"inv-{order_id}", customer="cus_123")

Pagination

for invoice in southbill.invoices.auto_paging_iter(status="open"):
    print(invoice["id"])

Errors

Network errors, 429 and 5xx are retried twice with exponential backoff. Everything else raises SouthbillError:

from southbill import SouthbillError

try:
    southbill.refunds.create(payment="pi_123", amount=500)
except SouthbillError as error:
    print(error.status, error.type, error.param, error.request_id)

Webhooks

Verify the raw request body — never a re-serialized object.

from flask import Flask, request
from southbill import construct_event, SouthbillSignatureError

app = Flask(__name__)

@app.post("/webhooks/southbill")
def webhook():
    try:
        event = construct_event(
            payload=request.get_data(),
            signature=request.headers.get("southbill-signature", ""),
            secret=os.environ["SOUTHBILL_WEBHOOK_SECRET"],
        )
    except SouthbillSignatureError:
        return "", 400

    if event["type"] == "invoice.paid":
        ...  # handle it

    return "", 200

Signature scheme: Southbill-Signature: t=<unix seconds>,v1=<hex> where the hex digest is HMAC-SHA256(secret, "<timestamp>.<raw body>"). Default tolerance 300s.

License

MIT

Metadata

Release files for southbill 0.1.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 southbill 0.1.0
File Size Uploaded
southbill-0.1.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for southbill 0.1.0
File Interpreter ABI Platform
southbill-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / southbill-0.1.0.tar.gz

Download URL southbill-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
56f4c4b9dc264fa15faabe8ae8292f44c8ac62973e216f13f1625ba0c760083d
BLAKE2b-256 checksum
How to use checksums
47e44558e22b617b6e700c8cbf5657a71b43a487822639a28bb2c88b93dffc2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / southbill-0.1.0-py3-none-any.whl

Download URL southbill-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00eb46d31e264b763ca277b8bd6853afe7967851fb9d7d313147cd3f89d2bd63
BLAKE2b-256 checksum
How to use checksums
8c979d392cc33a387f221f04187bf57f6dbeb279a6f0b871951323eda200f108
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

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