ATH Móvil Unofficial Python Library
A modern, type-safe Python library for the ATH Móvil payment platform.
Note: This is an unofficial, third-party library and is not affiliated with, endorsed by, or supported by ATH Móvil or EVERTEC. For official API documentation, see the ATH Móvil Payment Button API.
Developed with AI assistance using Claude Code (claude.ai)
Features
- Full ATH Móvil Payment Button API support
- Webhook support for real-time transaction notifications
- Simple synchronous client
- Strict type safety with mypy
- Pydantic data validation
- Automatic retries with exponential backoff
- Comprehensive error handling
Installation
pip install athm
Or with uv:
uv add athm
Quick Start
from athm import ATHMovilClient
# Note: private token is only required for processing refunds
client = ATHMovilClient(public_token="your_public_token", private_token="your_private_token")
payment = client.create_payment(
total="5.00",
phone_number="7875551234",
metadata1="Order #123",
items=[
{
"name": "Product Name",
"description": "Product Description",
"quantity": "1",
"price": "5.00",
}
],
)
# Wait for customer confirmation
client.wait_for_confirmation(payment.data.ecommerce_id)
# Authorize payment
payment_result = client.authorize_payment(payment.data.ecommerce_id)
print(f"Payment completed: {payment_result.data.reference_number}")
# Refund the payment (requires a client initialized with private token)
refund_result = client.refund_payment(
reference_number=payment_result.data.reference_number,
amount="5.00",
)
Configuration
Get your credentials from your ATH Business account settings.
client = ATHMovilClient(
public_token=os.getenv("ATHM_PUBLIC_TOKEN"),
private_token=os.getenv("ATHM_PRIVATE_TOKEN"), # Required for refunds
)
Supported Operations
- Create payments
- Check payment status
- Authorize confirmed payments
- Cancel payments
- Process full and partial refunds
- Update phone numbers
- Subscribe to webhook notifications
- Parse and validate webhook payloads
Error Handling
from athm.exceptions import ValidationError, ATHMovilError
try:
payment = client.create_payment(
total="5.00",
phone_number="7875551234", # Customer's phone number with ATH Móvil account
items=[{"name": "Test", "description": "Test", "quantity": "1", "price": "5.00"}],
)
except ValidationError as e:
print(f"Invalid data: {e}")
except ATHMovilError as e:
print(f"Error: {e}")
Context Manager
with ATHMovilClient(public_token="token") as client:
payment = client.create_payment(
total="5.00",
phone_number="7875551234", # Customer's phone number with ATH Móvil account
items=[{"name": "Test", "description": "Test", "quantity": "1", "price": "5.00"}],
)
# Client is automatically closed when exiting the context
Webhooks
Subscribe to real-time transaction notifications:
# Subscribe to webhooks (requires private token)
client = ATHMovilClient(
public_token="your_public_token",
private_token="your_private_token",
)
client.subscribe_webhook(
listener_url="https://yoursite.com/webhook",
payment_received_event=True,
refund_sent_event=True,
ecommerce_payment_received_event=True,
ecommerce_payment_cancelled_event=True,
ecommerce_payment_expired_event=True,
)
Parse incoming webhook payloads in your endpoint:
from athm.webhooks import parse_webhook, WebhookEventType, WebhookStatus
@app.post("/webhook")
async def handle_webhook(request: Request):
payload = await request.json()
event = parse_webhook(payload)
if event.status == WebhookStatus.COMPLETED:
if event.transaction_type == WebhookEventType.PAYMENT:
# Standard payment completed
print(f"Payment received: {event.reference_number} for ${event.total}")
elif event.transaction_type == WebhookEventType.ECOMMERCE:
# eCommerce payment completed
print(f"Order {event.ecommerce_id} completed: ${event.total}")
elif event.transaction_type == WebhookEventType.REFUND:
# Refund processed
print(f"Refund sent: {event.reference_number}")
elif event.status == WebhookStatus.CANCELLED:
print(f"Transaction cancelled: {event.ecommerce_id}")
elif event.status == WebhookStatus.EXPIRED:
print(f"Transaction expired: {event.ecommerce_id}")
return {"status": "ok"}
Documentation
Development
git clone https://github.com/django-athm/athm-python.git
cd athm-python
uv sync --all-extras --dev
uv run pytest
Code Quality
uv run ruff format
uv run ruff check
uv run mypy athm
Requirements
- Python 3.10+
- httpx
- pydantic
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
License
MIT License - see LICENSE for details.
Metadata
Release files for athm 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| athm-0.4.1.tar.gz | 31.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| athm-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.2 kB
Release files / athm-0.4.1.tar.gz
| Download URL | athm-0.4.1.tar.gz |
|---|---|
| Size | 31.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81ee7273c3cf279e04e4b70ff0eb172dd83bf9cb25d25e7645914fb1f68c3160
|
|
BLAKE2b-256 checksum How to use checksums |
6e6de87e8f0072bb072f49f20a385e03ee34608cbc86d97c0792be4d44e0a452
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 10, 2025.
Transparency logRelease files / athm-0.4.1-py3-none-any.whl
| Download URL | athm-0.4.1-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f338cef2efb737270ad5bb2be8a1a4d2d7542cf2e1514c848f961ed7b3b94e5f
|
|
BLAKE2b-256 checksum How to use checksums |
255d78595e98ae77ed111b1fc1e2de40946642e249e3b59485c216d25f30e38c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 10, 2025.
Transparency log