Skip to main content

avepay (Python)

SDK officiel Python pour l'API AvePay MCF — certification fiscale DGI Burkina Faso / SECEF.

  • Client sync (AvePay) et async (AsyncAvePay), même API.
  • Payload friendly (snake_case, calculs auto) avec échappatoire brute (clés camelCase).
  • Python 3.9+, basé sur httpx.

Installation

pip install avepay-mcf

Quickstart

from avepay.mcf import AvePay, AvePayError

avepay = AvePay(api_key="ak_live_…", isf="1")
mcf = avepay.mcf("EL02000015-1")

receipt = mcf.certify(
    number="FV-2026-0001",
    type="FV",                                    # FV | FT | EV | ET (défaut FV)
    operator={"id": 1, "name": "Awa"},
    customer={"type": "PP", "name": "Client Comptant"},
    items=[
        {"name": "Riz 25kg", "tax_group": "B", "unit_price": 15000, "quantity": 1},
    ],
    payments=[{"method": "cash", "amount": 15000}],
)

print(receipt.sig)        # signature SECEF (codeSecef)
print(receipt.qr)         # contenu QR
print(receipt.total_ttc)  # 15000
print(receipt.counters)   # Counters(tc=…, fvc=…, frc=…)

certify()/credit_note() acceptent un dict positionnel ou des kwargs (les kwargs priment).

Mapping friendly → brut

  • number → invoiceNumber, type → invoiceType, operator={"id","name"} → operatorId/operatorName.
  • items : amount_ttc calculé (unit_price * quantity), tax_rate déduit du tax_group (A = 0 %, B = 18 %). Groupe inconnu (C..N) → fournir tax_rate.
  • payments : alias cash→E, transfer→V, card→C, mobile→M, cheque→B, other→A (codes bruts acceptés).
  • Toute clé brute (ex. invoiceType, clientType) prime sur l'alias friendly.

Avoir (credit note)

avoir = mcf.credit_note(
    number="FA-2026-0001",
    from_=receipt,                  # dérive credit_note_ref = f"{nim}-{fvc}"
    # ou: credit_note_ref="EL02000015-1-291",
    credit_note_nature="COR",       # COR | RAN | RAM | RRR (défaut COR)
    operator={"id": 1, "name": "Awa"},
    customer={"type": "PP"},
    items=[{"name": "Riz 25kg", "tax_group": "B", "unit_price": 15000}],
    payments=[{"method": "cash", "amount": 15000}],
)

Info / cancel-pending / me

info = mcf.info()             # mode, compteurs, marchand
mcf.cancel_pending()          # annule une transaction 38h pendante
me = avepay.me()              # org + NIM scopés + état bridges

Erreurs

try:
    mcf.certify(...)
except AvePayError as e:
    print(e.code, e.http_status, e.message, e.request_id)
    if e.is_bridge_offline:
        ...  # MCF hors ligne — réessayer plus tard

Retry réseau/5xx automatique avec backoff + Idempotency-Key réutilisée entre tentatives.

Async

import asyncio
from avepay.mcf import AsyncAvePay

async def main():
    async with AsyncAvePay(api_key="ak_live_…", isf="1") as avepay:
        receipt = await avepay.mcf("EL02000015-1").certify(number="FV-1", ...)
        print(receipt.sig)

asyncio.run(main())

Webhooks

event = avepay.webhooks.verify(raw_body, request.headers.get("X-Avepay-Signature"))
# event.type: "cert.issued" | "mcf.connected" | "mcf.disconnected"

Le secret est passé à verify(body, sig, secret) ou au client (AvePay(webhook_secret=…)).

URL de l'API

Priorité : base_url= explicite > variable d'env AVEPAY_BASE_URL > défaut https://api-mcf-orchestrator.toolsite.io. Au changement de domaine, il suffit de définir AVEPAY_BASE_URL (pas de nouvelle version).

Développement

python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest          # tests contre tests/fixtures/ (httpx MockTransport)

Metadata

Release files for avepay-mcf 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 avepay-mcf 0.1.0
File Size Uploaded Provenance
avepay_mcf-0.1.0.tar.gz 11.6 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 23.4 kB

Release files / avepay_mcf-0.1.0.tar.gz

Download URL avepay_mcf-0.1.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bd58cc493f524bb9337fa9612a4c3b116f7df39077a7c77a5999111fb3b7fb5d
BLAKE2b-256 checksum
How to use checksums
765e0788f203287c7143bebc1e323ff860e76a9cd8f15cecb92f8c338edcf971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

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

Download URL avepay_mcf-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11007776aedb19d1e86b38ef1f7d08a2dc33da92f5d13d6151c1a416da0fb1dc
BLAKE2b-256 checksum
How to use checksums
6c9c2687af753ac6b879caa8d6fbeb31c22d671ba203fe1f68cbe3b8ba1035ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for avepay-mcf 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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