Skip to main content

NullPay SDK for Python backends

Project description

NullPay Python SDK

nullpay-python is the Python equivalent of @nullpay/node.

It follows the same backend-first architecture:

  • reads nullpay.json locally for named invoice lookup
  • calls the NullPay backend to create and retrieve checkout sessions
  • uses the NullPay relayer flow for invoice pre-generation when invoice_hash or salt is missing
  • verifies webhook signatures locally with HMAC-SHA256

The smart-contract and Provable SDK work stays on the NullPay backend. This package is a thin Python client for FastAPI, Flask, Django, and plain Python services.

Install

pip install ./packages/nullpay-python

Basic usage

from nullpay import NullPay

client = NullPay({
    "secretKey": "sk_test_...",
    "baseURL": "https://nullpay-backend-ib5q4.ondigitalocean.app/api",
})

session = client.checkout.sessions.create({
    "amount": 10,
    "currency": "USDCX",
    "type": "multipay",
    "success_url": "https://example.com/success",
    "cancel_url": "https://example.com/cancel",
})

print(session["checkout_url"])

API surface

NullPay(config)

Supported config keys:

  • secretKey or secret_key
  • baseURL or base_url
  • projectRoot or project_root
  • configPath or config_path
  • timeout

load_nullpay_config(project_root=None, config_path=None)

Loads nullpay.json from the provided project root or explicit path.

client.invoices

  • get_all()
  • get_by_index(i)
  • get_by_name(name)
  • get_by_type(type_name)

client.checkout.sessions

  • create(params)
  • retrieve(session_id)

create(...) mirrors the Node SDK behavior:

  • accepts nullpay_invoice_name and nullpay_invoice_index
  • auto-generates a salt if invoice_hash or salt is missing
  • calls /dps/relayer/create-invoice
  • polls the Provable salt_to_invoice mapping
  • performs best-effort dashboard sync via /invoices
  • finally creates the hosted checkout session via /checkout/sessions

client.webhooks

  • verify_signature(payload, signature)
  • construct_event(payload, signature)

Framework examples

See examples/ for:

  • FastAPI
  • Flask
  • Django

Tests

Run from this package directory:

python -m unittest discover -s tests

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

nullpay_python-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

nullpay_python-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file nullpay_python-0.1.0.tar.gz.

File metadata

  • Download URL: nullpay_python-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for nullpay_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22a77961c68369143520f300aae001c5cd7081eb3ebfbc9d3db7510e53bccdc4
MD5 681598dedd6f5c657535aa2e2fd4b567
BLAKE2b-256 c0d55bccb3bf846dd93f5ca516b3e5ab8d56446296e87cbb70d972c6833df5b4

See more details on using hashes here.

File details

Details for the file nullpay_python-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nullpay_python-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for nullpay_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afc8982d154e5abc3e80dd70df736998b92596edaf0bb9d3774a0d5f913144cf
MD5 748588b7a8ee5ce8ee06cea919f4b6cb
BLAKE2b-256 0c08376c1619cef72ff511ce5a40b79267177e0ae7cb512d296fcc0afcc8b8b5

See more details on using hashes here.

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