Skip to main content

amatopay

Official Python client for the AmatoPay payment gateway API — collect mobile-money payments (alias push or QR), track payments and deliveries, and verify webhooks.

Install

uv add amatopay
# or
pip install amatopay

Quickstart

import amatopay

client = amatopay.AmatoPay(api_key="sk_live_...")  # or set AMATOPAY_API_KEY

session = client.checkout.create_session(
    order_number="ORDER-1001",
    amount="100000.00",
    currency="BIF",
    payer_alias="+25779000000",
    return_url="https://merchant.bi/payment/result",
)
print(session["checkout_url"])  # send the payer here, or redirect them

AmatoPay() with no arguments reads AMATOPAY_API_KEY (and AMATOPAY_BASE_URL, if you're pointed at a non-default environment) from the environment — handy for keeping secrets out of code.

What's here

  • client.ping() — confirm your API key works and check onboarding/activation status.
  • client.checkout — verify a payer alias, create alias-push or QR payment sessions, poll a hosted checkout session's status.
  • client.payments — list/retrieve payments, confirm delivery with a payer's secure code.
  • client.fees — preview the fee for a given amount before creating a session.
  • client.deliveries — track fulfillment (mark shipped/delivered) and buyer-protection claims.
  • amatopay.webhooks — verify and parse signed webhook deliveries.

See examples/ for runnable scripts, and the developer docs for the full API reference.

Handling errors

Every non-2xx response raises a typed exception, all subclasses of amatopay.APIError:

Status Exception
400 ValidationError
401 AuthenticationError
403 PermissionError
404 NotFoundError
429 RateLimitError
5xx ServerError
try:
    client.checkout.create_session(...)
except amatopay.ValidationError as e:
    print(e.body)  # {"payer_alias": ["This alias is not payable."]}
except amatopay.PermissionError:
    print("Merchant not active yet, or missing a required capability.")

Verifying webhooks

import amatopay

@app.route("/webhooks/amatopay", methods=["POST"])
def amatopay_webhook():
    try:
        event = amatopay.webhooks.construct_event(
            request.get_data(),  # raw bytes — verify before parsing JSON yourself
            request.headers["AmatoPay-Signature"],
            endpoint_secret,  # your whsec_... for this endpoint
        )
    except amatopay.SignatureVerificationError:
        return "", 400

    if event["type"] == "payment.paid":
        ...
    return "", 200

Development

This project uses uv.

uv sync              # install deps + dev tools into .venv
uv run pytest        # run the test suite
uv run ruff check .  # lint
uv build             # build the sdist + wheel into dist/

License

MIT

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

Built distribution (wheel)

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

Total release size: 23.3 kB

Release files / amatopay-0.1.0.tar.gz

Download URL amatopay-0.1.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cc1d5ef98bc7ec7a99d48c5f817a901722f50c3dcd5d0c92af324ea57d72699d
BLAKE2b-256 checksum
How to use checksums
6c9668ed07344c530a2332c00c8df81765701ceedcfe530466f0d5da6166d32c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL amatopay-0.1.0-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2b7539e453ce0badef55d581333970893163e77344c1d8a873befa1b3c67ed4
BLAKE2b-256 checksum
How to use checksums
a081090762d44d768a874b211f862880e5807a0f58619e04fda35af1382719d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

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