> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orsunpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Read a payment with the synchronous or asynchronous Python client and verify webhook signatures.

Use Python 3.11 or newer. Install the SDK from the source distribution supplied by your integration contact with `python -m pip install .` in its package directory. To integrate directly over HTTPS, follow the [HTTP quickstart](https://docs.orsunpay.com/quickstart.md).

## Read a transaction

```python theme={null}
import os
from orsunpay import OrsunPay

with OrsunPay(
    os.environ["ORSUNPAY_API_KEY"],
    os.environ["ORSUNPAY_MERCHANT_ID"],
    os.environ["ORSUNPAY_API_BASE_URL"],
) as client:
    result = client.payments.retrieve(transaction_id)
    status = result.data.transaction.status
```

Use `client.payments.retrieve_by_order_id(order_id)` when you have the merchant order reference. The client also lists payments, handles refunds and creates sales, payouts and payment links. Pass amounts as decimal strings. Persist the idempotency key with the order and supply it as `idempotency_key` on creation. For asyncio, use `async with AsyncOrsunPay(...)` and await each resource call.

## Receive events

Verify the raw HTTP body against the signing secret before parsing or acting on an event. Follow the [webhook receiver guide](https://docs.orsunpay.com/webhooks.md) for a dependency-free Python example, timestamp validation and duplicate handling.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.