Skip to main content

openhub-bo-qr

Cobros con QR Simple y QR MLD-BCB vía Red Enlace (ATC) OpenHub, Bolivia. Sync y async, montos exactos con Decimal, cancelación, validación de webhooks y un mock en memoria para tus tests. Núcleo en Rust.

pip install openhub-bo[qr]

Uso

from decimal import Decimal
from openhub_bo.core import Session, Environment, Webhook, PaymentStatus
from openhub_bo.qr import QrClient

webhook = Webhook(url="https://mitienda.bo/webhooks/openhub", value="<secreto-largo-aleatorio>")

with Session("CLIENT_ID", "CLIENT_SECRET", environment=Environment.SANDBOX) as session:
    qr_client = QrClient(session)
    qr = qr_client.generate_qr(
        amount=Decimal("150.00"),
        description="Pedido #1042",
        reference="1042",  # tu referencia (solo dígitos)
        establishment_id=422717,  # asignado por ATC
        establishment_name="Mi Tienda",
        expires_in=900,  # segundos (o timedelta)
        webhook=webhook,  # obligatorio en OpenHub
    )
    save(order_id=1042, atc_reference=qr.reference)  # el webhook solo trae esta
    html = f'<img src="{qr.qr_data_uri}">'

    status = qr_client.get_qr_status(qr.reference)
    if status.status is PaymentStatus.PAID:
        ...
    elif status.status is PaymentStatus.PENDING:
        qr_client.cancel_qr(qr.reference)  # solo QR Simple

Async: AsyncSession + AsyncQrClient, misma API con await.

Si generate_qr pierde la respuesta (timeout tras enviar), lanza AmbiguousOutcomeError: el QR pudo haberse creado; no reintentes a ciegas.

Webhook

from openhub_bo.core import WebhookAuthError
from openhub_bo.qr import parse_webhook


@app.post("/webhooks/openhub")  # FastAPI / Starlette
async def openhub_webhook(request: Request):
    try:
        n = parse_webhook(request.headers, await request.body(), webhook=webhook)
    except WebhookAuthError:
        return Response(status_code=401)
    if n.success:
        # ATC no firma el payload: confirma estado e importe antes de entregar.
        confirmed = await qr_client.get_qr_status(n.reference)
        ...
    return Response(status_code=200)  # ATC espera HTTP 200

Tests sin red

from openhub_bo.qr.testing import MockOpenHub


def test_checkout():
    mock = MockOpenHub()
    qr_client = mock.client()
    qr = qr_client.generate_qr(...)
    call = mock.pay(qr.reference)  # simula el pago y devuelve el webhook
    n = parse_webhook(call.headers, call.body, webhook=webhook)

Metadata

Release files for openhub-bo-qr 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 openhub-bo-qr 0.1.0
File Size Uploaded
openhub_bo_qr-0.1.0.tar.gz 58.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for openhub-bo-qr 0.1.0
File
openhub_bo_qr-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
openhub_bo_qr-0.1.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
openhub_bo_qr-0.1.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
openhub_bo_qr-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
openhub_bo_qr-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
openhub_bo_qr-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
openhub_bo_qr-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 3.6 MB

Release files / openhub_bo_qr-0.1.0.tar.gz

Download URL openhub_bo_qr-0.1.0.tar.gz
Size 58.7 kB
Tags Source
SHA-256 checksum
How to use checksums
82b8c380e3b525b861f199e94f2d2ac59ce8035d82e2b05234d927362b45c1a9
BLAKE2b-256 checksum
How to use checksums
1dfeef782b56b295b559f9fc86de27e73d39c94788b2a82a199d79c409389046
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 6, 2026.

Transparency log

Release files / openhub_bo_qr-0.1.0-cp310-abi3-win_amd64.whl

Download URL openhub_bo_qr-0.1.0-cp310-abi3-win_amd64.whl
Size 343.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
80bb8152beb9809aded744d4f771f4a194f1715524a1b07eb7895caa4fb94b7c
BLAKE2b-256 checksum
How to use checksums
85ef47781d75b91e6c10107868632aa6a26b6ebd21977a0f7cf14f6270e51b6c
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 6, 2026.

Transparency log

Release files / openhub_bo_qr-0.1.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL openhub_bo_qr-0.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 693.9 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
f7d9d8f71d2ff93a4ebcbec8c91e00b0712c7a05319f86f9b335467479c3d7b8
BLAKE2b-256 checksum
How to use checksums
71a9077b660b9fd39397b65a9dd6f52daad60429e1a787593a856c629eca43a5
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 6, 2026.

Transparency log

Release files / openhub_bo_qr-0.1.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL openhub_bo_qr-0.1.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 656.2 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
a8a4168991439eb7d603b657e7eb11dd3619cc2589a5aa200b3999052a530e66
BLAKE2b-256 checksum
How to use checksums
389dceb12dbf44436b510cb5c13b981a26e0688495f8043d60a8c42326a502a0
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 6, 2026.

Transparency log

Release files / openhub_bo_qr-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL openhub_bo_qr-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 491.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
0c888cbf8257d1771a8682ff44bc71abfaf47384a2e3bf345461704dda9a2aa2
BLAKE2b-256 checksum
How to use checksums
4622fde7ccc9448c05d3b9a1ce16ea7fc6877e7caf681cc315d248388d6ea340
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 6, 2026.

Transparency log

Release files / openhub_bo_qr-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL openhub_bo_qr-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 484.8 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
1f0bc8075e3e8edf94f8db88c81b2071e73d9f1f572423057c9eea806f99499e
BLAKE2b-256 checksum
How to use checksums
4218acb597357823887cc14efed9a11177ac6bd39fa93ef53fddadb9969e0724
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 6, 2026.

Transparency log

Release files / openhub_bo_qr-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL openhub_bo_qr-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 438.4 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1c00105093bb780eb6bf6500d35c5af5e78cebaffa6f33ae14a65e3be23c4ee2
BLAKE2b-256 checksum
How to use checksums
d44721e4ea3958144533c9d15d0f50ae9fddffa502f385e458cd2b2ba077158c
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 6, 2026.

Transparency log

Release files / openhub_bo_qr-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL openhub_bo_qr-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 443.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
68b2c825660775a8f14b57a7834efe16361e313173fac5db89adea16aed81217
BLAKE2b-256 checksum
How to use checksums
0cb180f1bed45ba71e0713f5689dbc18313dc6a1286908db0d6723367aa74b40
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 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

8 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