Official MakePay Python SDK for payment links, settings, and webhook verification.
Project description
MakePay Python SDK
Official Python SDK for MakePay server-side integrations. Use it to create hosted payment links, read and update links, manage MakePay settings, and verify signed webhooks.
Install
pip install makepay
uv add makepay
Configure
Create a MakePay API key in MakeCrypto and keep the secret on your server only.
import os
from makepay import MakePayClient
makepay = MakePayClient(
key_id=os.environ["MAKEPAY_KEY_ID"],
key_secret=os.environ["MAKEPAY_KEY_SECRET"],
# Optional: override only when MakePay gives you a custom checkout origin.
checkout_base_url="https://makepay.io",
)
Create A Hosted Checkout Link
response = makepay.create_payment_link(
{
"title": "Order #1042",
"description": "Checkout for order #1042",
"amount": "129.99",
"currency": "USDT",
"orderId": "order_1042",
"customerEmail": "buyer@example.com",
"returnUrl": "https://merchant.example/orders/1042",
"successUrl": "https://merchant.example/orders/1042/success",
"failureUrl": "https://merchant.example/orders/1042/pay",
"expirationTime": "12h",
}
)
print(response["paymentLink"])
Hosted And Embedded Checkout
Use the hosted URL for a full-page redirect, or the embedded URL and HTML helpers when your frontend keeps the shopper on the merchant site.
from makepay import (
build_makepay_embed_button_html,
build_makepay_embedded_checkout_url,
build_makepay_hosted_checkout_url,
build_makepay_iframe_html,
)
payment_uid = response["paymentLink"]["uid"]
hosted_url = build_makepay_hosted_checkout_url(payment_uid)
embed_url = build_makepay_embedded_checkout_url(
payment_uid,
parent_origin="https://merchant.example",
)
button_html = build_makepay_embed_button_html(payment_uid)
iframe_html = build_makepay_iframe_html(
payment_uid,
iframe_title="Secure MakePay checkout",
)
Read And Update Links
makepay.list_payment_links()
makepay.get_payment_link("PAYMENT_LINK_UID")
makepay.update_payment_link("PAYMENT_LINK_UID", {"status": "paused"})
makepay.send_payment_request_email("PAYMENT_LINK_UID", "buyer@example.com")
Settings
makepay.get_settings()
makepay.update_settings(
{
"callbackUrl": "https://merchant.example/webhooks/makepay",
}
)
Verify Webhooks
Read the raw body before parsing JSON.
from makepay import parse_makepay_webhook
def handle_makepay_webhook(raw_body: bytes, headers: dict[str, str]) -> tuple[str, int]:
event = parse_makepay_webhook(
raw_body,
headers.get("x-makepay-signature"),
os.environ["MAKEPAY_WEBHOOK_SECRET"],
)
if event.get("event", {}).get("type") == "status_changed":
# Update your local order status.
pass
return "ok", 200
Errors
API calls raise MakePayError with status and response_body fields.
from makepay import MakePayError
try:
makepay.get_payment_link("PAYMENT_LINK_UID")
except MakePayError as error:
print(error.status, error.response_body)
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 makepay-0.1.0.tar.gz.
File metadata
- Download URL: makepay-0.1.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
903142f8accfa89c3ea3aa2e85a3e528021c2f5b4000393dd7ae9a328843b292
|
|
| MD5 |
23827c9a5a5581992ca0df57ce2089fd
|
|
| BLAKE2b-256 |
e86e78c66ae2ce63f12b13860f218ce4d67da5fd8b1c4b03f34bfbbf4348765e
|
File details
Details for the file makepay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: makepay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af8c5f90147a6c57bb6e245ca3334a44e711d1d3276ef4e7066ee06c2131532d
|
|
| MD5 |
e91bc36793f616fad76faefb3277bbdd
|
|
| BLAKE2b-256 |
057f1ac349e1b8eeb8c49cf0932f68c143f5cb18121af9f249a9bc6368fa5963
|