Python¶
oura · source
No runtime dependencies: it uses only the standard library. This SDK holds your secret key, so use it only on a server.
Install¶
Accept a payment¶
import os
from oura import Oura
oura = Oura(os.environ["OURA_SECRET_KEY"])
payment = oura.payments.create({
"amount": 245000, # NPR 2,450.00 in paisa
"methods": ["esewa", "khalti"],
"reference": "order_1042",
"return_url": "https://himalstore.com.np/orders/1042",
})
return redirect(payment["checkout_url"])
Other calls¶
oura.payments.retrieve("pay_123")
oura.payments.list(limit=20, starting_after="pay_123")
oura.payments.cancel("pay_123")
oura.payments.create(params, idempotency_key=f"order_{order_id}")
An idempotency key is generated for every create. Pass your own, tied to your order, to make retries safe across restarts. See Idempotency.
Configuration¶
Point the client at a local API while developing:
Webhooks¶
Verify with webhooks.construct_event(raw, header, secret) and webhooks.verify(raw, header, secret, tolerance=300). Both compare in constant time and reject stale timestamps. Always pass the raw request body. Full example: Webhooks.
Errors¶
Every non-2xx response raises oura.errors.OuraError with the error code, HTTP status and message. See Errors.