Skip to main content

Official Python SDK for DigiPay — accept DigiByte payments on your site.

Project description

digipay

Official Python SDK for DigiPay — accept DigiByte payments on your site without holding any funds.

  • Non-custodial. Payments land directly in your wallet (single address or BIP84 xpub).
  • Zero runtime dependencies. Standard library only (urllib, hmac, hashlib, json).
  • Fully typed. py.typed, TypedDict DTOs, Literal status unions.
  • Python 3.10+.
pip install digipay

Quickstart

import os
from digipay import DigiPay

dp = DigiPay(api_key=os.environ["DIGIPAY_KEY"])

session = dp.sessions.create(amount=5, label="Order #1234")
print(session["checkoutUrl"])  # → https://pay.dgbwallet.app/pay/ses_…

Self-serve registration

If you don't have an API key yet, register a brand-new merchant + first store + initial key in a single call:

from digipay import DigiPay

merchant = DigiPay.register(
    display_name="My Shop",
    address_or_xpub="dgb1q…",  # or a BIP84 xpub
    webhook_url="https://my-shop.example/digipay-webhook",
)

print(merchant["apiKey"])        # dgp_… (shown once)
print(merchant["webhookSecret"]) # store this for verify_webhook

Webhook verification

DigiPay POSTs signed JSON to your webhookUrl on every state change. The signature is HMAC-SHA256 of the raw body, hex-encoded, in the X-DigiPay-Signature header (prefixed sha256=).

import os
from flask import Flask, request, abort
from digipay import verify_webhook, DigiPayError

app = Flask(__name__)

@app.post("/digipay-webhook")
def webhook():
    try:
        event = verify_webhook(
            raw_body=request.get_data(),                       # raw bytes
            signature=request.headers.get("X-DigiPay-Signature"),
            secret=os.environ["DIGIPAY_SECRET"],
        )
    except DigiPayError as err:
        abort(err.status)

    if event["event"] == "session.paid":
        # event["session"]["id"], .amount, .paidTxid, etc.
        ...
    return "", 200

Critical: verify the signature against the raw bytes before parsing JSON. Re-serialising (or letting a framework parse for you) breaks the HMAC.

Resources

Sessions

dp.sessions.create(amount=5, label="Order #1", memo="…", fiat_currency="USD", fiat_amount=2.50)
dp.sessions.get("ses_abc")
dp.sessions.list(status="paid", take=50)
dp.sessions.export_csv(status="paid")   # returns CSV text

Stores

dp.stores.list()
dp.stores.get("sto_abc")
dp.stores.create(name="Side hustle", network="mainnet")
dp.stores.update("sto_abc", webhook_url="…", default_session_expiry_minutes=30)
dp.stores.delete("sto_abc")

# Webhook tooling
dp.stores.send_test_webhook("sto_abc")
dp.stores.list_deliveries("sto_abc", take=100)
dp.stores.replay_delivery("sto_abc", "wdel_…")
dp.stores.export_deliveries_csv("sto_abc")

Errors

Every failure raises DigiPayError with the HTTP status preserved:

from digipay import DigiPay, DigiPayError

try:
    dp.sessions.create(amount=0)
except DigiPayError as err:
    print(err.status)  # 400
    print(err.body)    # {"error": "amount (DGB) must be > 0"}
err.status Meaning
0 Network / DNS / TLS / timeout
400 Validation failure — see err.body["error"]
401 Missing or invalid API key
404 Resource not found, or not owned by this merchant
429 Rate-limited (sandbox endpoints only)
>= 500 Server-side; safe to retry with backoff

Configuration

DigiPay(
    api_key="dgp_…",
    base_url="https://api.pay.dgbwallet.app",  # default
    timeout=15.0,                               # seconds, default
)

For staging or self-hosted, pass an alternate base_url.

License

MIT — see the repo root LICENSE.

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

digipay-0.1.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

digipay-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for digipay-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d838e4d229abdd039af62d7ba2ca60171d50d357ea44e353effe54ef48f6a00
MD5 7a2fa1e2bcbcdb3ef4bc68ce1ca488fc
BLAKE2b-256 c12dc63130d8b8aad5b9b1bb9312ece23c240e7e6fff440506b8906e6b2387fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for digipay-0.1.0.tar.gz:

Publisher: publish-sdk-python.yml on DennisPitallano/digibyte-wallet

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

File details

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

File metadata

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

File hashes

Hashes for digipay-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 657a63242fe121d05ae7a8d2f0a105731abafbb3f7a299590594bb7ab9908986
MD5 e26bf58e69709fa8fee872cee12c2291
BLAKE2b-256 7832d8bad9d77e969f554c2f49ee3ea1eec1705c81ec4514584b7212172a23f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for digipay-0.1.0-py3-none-any.whl:

Publisher: publish-sdk-python.yml on DennisPitallano/digibyte-wallet

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