Skip to main content

Official Python SDK for the PawPayments Native V2 API

Project description

PawPayments — Python SDK

Official Python SDK for the PawPayments Native V2 API. Ships both a synchronous client (PawPayments, built on requests) and an asynchronous one (AsyncPawPayments, built on httpx).

Install

pip install pawpayments

Requires Python 3.9+.

Quickstart (sync)

from pawpayments import PawPayments

paw = PawPayments(api_key="…")

invoice = paw.invoices.create(
    amount=25,
    fiat_currency="USD",
    billing_type="STATIC",
    asset="usdt_tron",
    description="Pro plan, 1 month",
    notify_url="https://example.com/paw/webhook",
)
print(invoice["payment_url"])

Quickstart (async)

import asyncio
from pawpayments import AsyncPawPayments


async def main():
    async with AsyncPawPayments(api_key="…") as paw:
        invoice = await paw.invoices.create(
            amount=25,
            fiat_currency="USD",
            billing_type="STATIC",
            asset="usdt_tron",
        )
        print(invoice["payment_url"])


asyncio.run(main())

Resources

Group Methods
paw.assets list()
paw.rates get(base=, assets=)
paw.balance get()
paw.invoices create(**), get(id), list(**), notify(id)
paw.payouts create(**, uniq_id=), get(id), list(**), batch(items, uniq_id=)
paw.ledger list(type=, ...)
paw.notifications list(**), test(url=)
paw.permanent create(**), get(id), list(**), deactivate(id)

payouts.create and payouts.batch accept an optional uniq_id for explicit idempotency (UUIDv4). When omitted the SDK generates one with uuid.uuid4(). A repeated uniq_id within 2 hours yields a 409.

Webhook verification

from flask import Flask, request, abort
from pawpayments import Webhook

app = Flask(__name__)


@app.post("/paw/webhook")
def webhook():
    raw = request.get_data()
    sig = request.headers.get("X-Paw-Signature", "")
    if not Webhook.verify_raw_body(raw, sig, API_KEY):
        abort(401)
    payload = Webhook.parse_payload(raw)
    # …handle the invoice update…
    return "", 200

Errors

from pawpayments import PawPaymentsApiError

try:
    paw.invoices.create(...)
except PawPaymentsApiError as exc:
    print(exc.code, exc.http_status, str(exc), exc.details)

Testing

  • pytest tests/test_webhook.py — signature unit tests + PHP-interop parity.
  • PAW_API_KEY=… pytest tests/test_live.py tests/test_negative.py — live happy-path + negative-case suites against https://api.pawpayments.com. Tests skip when PAW_API_KEY is absent.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pawpayments-2.0.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pawpayments-2.0.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file pawpayments-2.0.0.tar.gz.

File metadata

  • Download URL: pawpayments-2.0.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pawpayments-2.0.0.tar.gz
Algorithm Hash digest
SHA256 82f2b3525fcd339b223c63e1a3e55a31d4e5ca7e76a88f1170b8718aa75ca2d9
MD5 ae7f5f06ad50ad6a55f4b1b710c804d0
BLAKE2b-256 7cf7fb179b9930510fd0ba1a02def573d075a38f205c1ff83708cc0390f3544a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pawpayments-2.0.0.tar.gz:

Publisher: release.yml on PawPayments/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pawpayments-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: pawpayments-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pawpayments-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97be943a1369c6ab215a77c9cc50933619897e48c88df135d9e1f7fb4da9d0c4
MD5 386ccd771aa3e771669e035a8b110df0
BLAKE2b-256 74857d8ea890d1fb43a4bb0fb164046c2ab39db4f9df42513c1fee474a71def2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pawpayments-2.0.0-py3-none-any.whl:

Publisher: release.yml on PawPayments/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page