PayLink card payment SDK for Python
Project description
mongolian-payment-paylink
PayLink card payment SDK for Python — create invoices, query transactions, run reports.
Wraps the PayLink External API (single POST /external/process endpoint, process-code driven).
Installation
pip install mongolian-payment-paylink
Requires Python >= 3.8. Depends on httpx.
Quick Start
from mongolian_payment_paylink import PayLinkClient, PayLinkConfig, CreateInvoiceInput
client = PayLinkClient(PayLinkConfig(
base_url="https://paylink.mn/api/v1", # test: https://pay-link.fiba.mn/api/v1
username="MERCHANT_USERNAME",
signature_key="YOUR_SIGNATURE_KEY",
))
invoice = client.create_invoice(CreateInvoiceInput(
amount_total=10000,
count_total=1,
amount=10000,
description="Order #123",
merchant_ref="ORDER-123",
))
print(invoice.payment_link) # redirect the buyer here
print(invoice.invid)
Async
import asyncio
from mongolian_payment_paylink import AsyncPayLinkClient, PayLinkConfig
async def main():
async with AsyncPayLinkClient(PayLinkConfig(
base_url="https://paylink.mn/api/v1",
username="MERCHANT_USERNAME",
signature_key="YOUR_SIGNATURE_KEY",
)) as client:
detail = await client.get_invoice("INV-123")
print(detail["status"])
asyncio.run(main())
Authentication & signing
Every request sends three headers: pc (process code), X-USERNAME, and X-SIGNATURE.
Note on the signature. PayLink's exact signing scheme is not published. By default this SDK signs the HMAC-SHA256 (hex) of the JSON request body, keyed by
signature_key. If PayLink specifies a different scheme, pass your ownsignfunction — it receives the exact body string and returns the signature:PayLinkConfig(base_url=..., username=..., sign=lambda body: my_signature(body))
Environment variables
PAYLINK_BASE_URL=https://paylink.mn/api/v1
PAYLINK_USERNAME=MERCHANT_USERNAME
PAYLINK_SIGNATURE_KEY=your-signature-key
from mongolian_payment_paylink import PayLinkClient, load_config_from_env
client = PayLinkClient(load_config_from_env())
Methods
| Method | Process code | Description |
|---|---|---|
create_invoice(input) |
cu0900 | Create an invoice → CreatedInvoice |
list_invoices(input) |
cu0901 | List invoices |
get_invoice(invid) |
cu0904 | Invoice detail incl. transactions |
cancel_invoice(invid) |
cu0905 | Cancel an invoice |
batch_mark_paid(invid) |
cu0906 | Batch mark an invoice paid |
invoice_report(input) |
cu0907 | Paginated invoice report |
invoice_summary(input) |
cu0908 | Invoice summary counters |
transaction_report(input) |
cu0909 | Paginated transaction report |
transaction_summary(input) |
cu0910 | Transaction summary counters |
List/report/summary results are returned as plain dicts/lists exactly as the API
sends them (snake_case keys). create_invoice maps to the CreatedInvoice dataclass.
Dates use the YYYY-MM-DD HH24:MI:SS format.
Endpoints
| Environment | Base URL |
|---|---|
| Production | https://paylink.mn/api/v1 |
| Test | https://pay-link.fiba.mn/api/v1 |
Error handling
Every call returns HTTP 200; the result is driven by response_code (RC000000 =
success). Non-success codes and transport errors raise PayLinkError:
from mongolian_payment_paylink import PayLinkError
try:
client.get_invoice("INV-404")
except PayLinkError as err:
print(err) # "PayLink cu0904 failed: RC000015 - Record not found"
print(err.response_code) # "RC000015"
print(err.status_code) # set for HTTP-level failures
print(err.response) # raw response body
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mongolian_payment_paylink-1.0.0.tar.gz.
File metadata
- Download URL: mongolian_payment_paylink-1.0.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46ea408e322964fa3de7f95354e62f3814ad15c212c94c25e0d6dca8711965e3
|
|
| MD5 |
e3b4c9775b2acfe790ccd18efafa932d
|
|
| BLAKE2b-256 |
2096813316dc2122d0bdcdc5dad588a960c7d8eef368988297733e9d18e8e44b
|
File details
Details for the file mongolian_payment_paylink-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mongolian_payment_paylink-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5489ff2ee42ba5eaa09befd0c09fd9460d5ffd42b033f1efd2437d727ed819a1
|
|
| MD5 |
4aa30a9b11c3245ce7860249659f57f7
|
|
| BLAKE2b-256 |
0b0d99dd736ac48bb62bd0a318b4b22f2b363e143201e42493774bd1013bd8ef
|