Metadata-Version: 2.4
Name: paysig-server
Version: 0.2.0b1
Summary: Server-side PaySig checkout and webhook SDK
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Dynamic: license-file

# PaySig Python SDK



Python 3.10+, standard library only. Suitable for Django, Flask and FastAPI server code.



Install the downloaded wheel:



```sh

python -m pip install ./paysig_server-0.2.0b1-py3-none-any.whl

```



```python

import os

from paysig import PaySig, verify_webhook, assert_paid_checkout

api = PaySig(os.environ['PAYSIG_API_KEY'], os.environ['PAYSIG_API_SECRET'])

checkout = api.create_checkout(amount_usd='25.00', order_reference='ORDER-1001', idempotency_key='checkout-order-1001')

# Persist checkout['id'] with the order, then redirect to checkout['checkout_url'].

```



Use Django request.body, Flask request.get_data() or FastAPI await request.body() for verify_webhook(raw,headers,secret=...,project_id=...). It returns the verified event. Fetch with api.get_checkout(saved_checkout_id), then assert_paid_checkout(checkout,id=...,order_reference=...,amount_usd=...). For async frameworks, run this synchronous urllib client in a worker/thread rather than blocking the event loop.



## Payment rules



This is a server-side beta SDK. API secrets and webhook secrets stay on your server. Do not embed them in browser JavaScript, Android/iOS applications, public repositories or checkout URLs. No recovery phrase or private key is used.



- Use the USD total calculated from your trusted order database, as a string with at most two decimal places. Supported range: $0.01–$10,000,000. No FX conversion or floating-point crypto amounts.

- Create a stable Idempotency-Key per order; persist it BEFORE sending. Retry the exact same order/body with that key. A new request gets a fresh nonce automatically. The SDK does not automatically retry or maintain your order database.

- Persist the returned checkout ID with the order before redirecting the customer to checkout_url. Do not send a token, chain or receiving address when creating a USD checkout; the customer chooses an enabled combined method on PaySig checkout.

- Verify webhooks using the exact raw request bytes, before JSON parsing. Supply the separate webhook signing secret, expected project ID, and the PaySig-Timestamp, PaySig-Signature and PaySig-Event-Id headers. The default timestamp window is five minutes.

- Fulfil only invoice.paid, not payment.confirmed (which may be partial). Match data.checkoutId to your saved order, fetch it with getCheckout, and use assertPaidCheckout with the saved ID, reference and USD amount. A paid_late checkout returns review and must not automatically fulfil.

- Durable event deduplication and atomic order updates are YOUR application's responsibility. Use a database unique constraint on the event ID plus an order lock/transaction. Acknowledge 2xx only after the event is durably accepted. Never mark an order paid from a browser return or client-submitted status.

- A customer fee configured in PaySig is separate from the base order value. Verification compares order_amount_usd where available, not the fee-inclusive total.

- HTTPS certificate validation and redirect refusal are enabled by default. API errors do not echo secrets or response bodies. API responses are bounded to 256 KiB; webhook payloads to 128 KiB.

- No automated blockchain refunds, subscription charges, wallet signing or mainnet/testnet switch. The CMS checkout currently returns to the verified merchant homepage; a custom thank-you/cancel URL is not part of this API.



## Release and verification



Version 0.2.0-beta.1. Protocol tests use signatures generated by the actual PaySig backend and synthetic transports: no live charges or wallet operations. Language-runtime tests do not substitute for a full order-flow test in your application. Downloaded archives are the distribution mechanism; these package names have NOT been published to npm, PyPI, Packagist, the Go proxy or NuGet.org. Do not install an unrelated public package with a similar name.



Public documentation: https://docs.paysig.io/sdks

MIT license. Requires an active verified PaySig project, connected wallet, accepted currencies and separate API/webhook credentials.

