Python library
The payitgo package wraps the payitgo API for Python: payments, tokens, your
webhook (IPN) and its signature check, the events to replay what
you missed, the public checkout calls, and payouts to your own
clients from your payout wallet. It uses only the standard library. Use it on
your server only: it holds your secret key.
Responses are dicts with the API's own keys (order_id, checkout_url, …),
so the Payments, Webhooks,
Checkout and Mass payouts pages describe
every field this library returns.
The client is synchronous: each call blocks until the answer arrives.
Install
pip install payitgo
The package is published as payitgo and imported as payitgo:
import payitgo
| Requirement | |
|---|---|
| Python | 3.8 or later |
| Dependencies | None (urllib, json, hmac from the standard library) |
Quickstart
import os
import payitgo
client = payitgo.Client(os.environ["PAYITGO_KEY"])
payment = client.payments.create(order_id="ORD-1001", amount="49.90", token="USDT_TRC20")
print(payment.crypto_amount, payment.token, "to", payment.deposit_address)
Then set your webhook URL and fulfil the order when
payment.confirmed arrives.
Configuration
payitgo.Client
payitgo.Client(api_key, base_url=None, timeout=30, max_retries=2, webhook_secret=None, webhook_url=None)
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
api_key |
str | yes | Your secret key, test or live (Authentication). An empty key raises ValueError |
|
base_url |
str | no | PAYITGO_BASE_URL, then https://api.payitgo.co |
payitgo's API, default https://api.payitgo.co: leave it out (Base URL). Trailing slashes are removed; "" uses the default |
timeout |
int or float | no | 30 |
Seconds one attempt may wait for the server (connecting, and each read). A timeout counts as a network error, so it is retried |
max_retries |
int | no | 2 |
How many times a request is retried after a network error, a 429 or a 5xx. 0 turns retries off |
webhook_secret |
str | no | None |
Your mode's signing secret. webhooks.construct_event uses it when you pass none |
webhook_url |
str | no | None |
Sent as webhook_url with every payments.create that does not pass its own |
The constructor makes no request. It raises ValueError when:
| Message | Cause |
|---|---|
payitgo: the API key is required |
api_key is missing, not a string, or empty |
client = payitgo.Client(
os.environ["PAYITGO_KEY"],
timeout=15,
max_retries=2,
webhook_secret=os.environ["PAYITGO_WEBHOOK_SECRET"], # the signing secret of the key's mode
webhook_url="https://api.yourdomain.com/payitgo/ipn", # optional default for payments.create
)
The client keeps no per-request state: create one and share it, across threads too.
Attributes
| Attribute | Type | Description |
|---|---|---|
payments |
object | Payments |
tokens |
object | Tokens |
webhooks |
object | Webhooks |
events |
object | Events |
checkout |
object | Checkout |
payouts |
object | Payout requests |
payout_batches |
object | Payout batches |
payout_wallets |
object | The payout wallet |
The module also has payitgo.__version__ ("0.7.1", sent in the
User-Agent: payitgo-python/0.7.1 header), payitgo.WEBHOOK_EVENTS (the
event types), payitgo.SIMULATION_OUTCOMES (the outcomes
payments.simulate takes), and the classes Client, Webhook, PayitgoError,
SignatureVerificationError and PayitgoObject.
is_live
GET /v1/webhook · API reference
client.is_live() -> bool
Returns True for a live key, False for a test key. A key does not say
its mode, so the first call asks payitgo (the livemode of the key's
webhook; a read-only key may call it) and the answer is kept
for the client's life: later calls make no request.
Errors PayitgoError, as any call: 401 for a key payitgo
does not know, 403 for a live key while live mode is off. An error is not
kept: the next call asks again.
if not client.is_live():
print("test mode: payments are simulated")
Base URL
The client calls payitgo's API, default https://api.payitgo.co, so you
never need to set it. It takes the address from, in order: the base_url
argument, the PAYITGO_BASE_URL environment variable, and that default:
export PAYITGO_BASE_URL=https://api.payitgo.co
Test and live mode
The key decides the mode. A test key creates and reads test payments
(no coins: you simulate what the customer sends) and
manages the test webhook; a live key does the same for live ones. The key
does not say which it is: the dashboard shows a Test or Live badge next to
it, and client.is_live() asks payitgo. Pair each key with the
webhook secret of the same mode. See Test mode.
HTTP client
Requests go through urllib.request from the standard library, with the
headers Authorization: Bearer <key>, Accept: application/json,
Content-Type: application/json (when there is a body) and
User-Agent: payitgo-python/0.7.1. The standard proxy variables
(HTTPS_PROXY, NO_PROXY) apply. There is no argument to pass your own HTTP
client or session.
Errors
PayitgoError
Every call that reaches the API raises payitgo.PayitgoError when the request
fails.
class PayitgoError(Exception):
message: str
status: int
| Attribute | Type | Description |
|---|---|---|
status |
int | The HTTP status, or 0 when no answer came (network error or timeout, after the retries) |
message |
str | The API's error message, such as minimum payment in USDT_TRC20 is $6.44 right now (network fees). The HTTP reason phrase (such as Bad Gateway) when the answer had no message. request failed: <cause> for a network error. str(e) is the same |
Branch on status; log message (its wording may change, see
Errors and limits).
status |
Meaning | Retried by the library |
|---|---|---|
0 |
No answer: DNS, connection, TLS or timeout | Yes |
400 |
The request is invalid (the message says which field) | No |
401 |
missing api key or invalid api key |
No |
403 |
Not allowed, for example a live key while live mode is off, a storefront key changing the account's webhook or reading its events, or a key without payouts making one | No |
404 |
No such payment, payout or payout batch in the key's mode | No |
409 |
Conflicts with the current state, such as changing a payment's coin once it can no longer change, simulating a payment whose simulation is running, or canceling a payout that was sent already | No |
429 |
Over the rate limit | Yes |
500 and other 5xx |
Something failed on payitgo's side | Yes |
try:
client.payments.create(order_id="ORD-1", amount=1, token="BTC")
except payitgo.PayitgoError as e:
if e.status == 400:
log.warning("payitgo refused: %s", e.message) # e.g. an amount under the coin's minimum
else:
raise
SignatureVerificationError
construct_event raises
payitgo.SignatureVerificationError (a subclass of Exception) when a
notification cannot be trusted. Answer 400. str(e) says why:
| Message | Cause |
|---|---|
missing or malformed X-Webhook-Signature header |
No header, or no t or v1 in it |
signature does not match |
The body, the timestamp or the secret differ from what payitgo signed (a v1 that is not 64 hex characters included) |
timestamp outside the tolerance |
t is further than the tolerance (5 minutes) from your clock |
malformed timestamp |
t is not a number (checked unless the tolerance is 0) |
no webhook secret: pass one, or set the client's webhook_secret |
The client method got no secret and the client has no webhook_secret |
A body that is correctly signed but is not JSON raises ValueError
(json.JSONDecodeError); payitgo never sends one.
Retries
A request is retried, up to max_retries times (default 2, so at most 3
attempts), after a network error or timeout, a 429 or a 5xx. It waits
0.5 s before the first retry and 1 s before the second. Other statuses are
never retried. When the last attempt fails, the call raises a PayitgoError
with that attempt's status (0, 429 or 5xx).
Every call is retried the same way, and each is safe to repeat:
| Call | Repeating it |
|---|---|
payments.create |
Returns the order's open payment instead of a second one (safe retries) |
payments.select_token, checkout.select_token |
Returns the payment unchanged: choosing the coin it has already changes nothing |
payments.simulate |
If the first attempt went through, the repeat raises 409 while that simulation runs: read the payment with retrieve |
webhooks.set, webhooks.remove |
Changes nothing the second time |
webhooks.test |
Queues one more ping |
payouts.request |
With a reference: returns the payment that reference names, not a second one. Without one, a second request is kept: always send a reference |
payouts.send |
With ids: if the first attempt went through, the repeat raises 400 (those requests are no longer in the list). Without: it sends whatever valid requests arrived since, or raises 400 (no valid payout request to send). Find the batch from a sent request's batch_id (payouts.retrieve) |
payouts.cancel |
Returns the payment, canceled, as it is: nothing changes the second time |
payouts.quote |
Prices again; nothing else changes |
payout_wallets.simulate_top_up |
Adds the amount again (test money, on paper) |
| Reads | Change nothing |
Payments
payments.create
POST /v1/payments · API reference
client.payments.create(order_id, amount, token=None, webhook_url=None, *,
currency=None, **optional) -> PayitgoObject
Creates a payment for one of your orders. With a token, the payment comes
back with its deposit address, amount, QR payload and a 15-minute deadline.
Without one, it comes back with token_options and the customer (or your
page, with select_token) chooses the coin. While the
order has an open payment, creating it again returns that payment.
| Parameter | Type | Required | Description |
|---|---|---|---|
order_id |
str | yes | Your id for the order, 1 to 128 bytes. One open payment per order and mode |
amount |
str, Decimal or int |
yes | The price, in currency, such as "49.90". Sent as str(amount): prefer a string or a Decimal to a float |
token |
str | no | The coin, such as "USDT_TRC20" (from tokens.list). Leave it out to let the customer choose |
webhook_url |
str | no | https:// URL that gets this payment's notifications instead of your account's webhook URL (per-payment URL). None: the client's webhook_url. "": none for this payment, even with a client default |
currency |
str | no | Keyword only. The ISO 4217 code of the currency the price is in, such as "EUR", "GBP" or "NGN" (any case; any of the 154 currencies GET /currencies lists). Default USD. payitgo converts the price at the rate of the moment, and every figure on the payment is in this currency from then on, in every response and webhook (your currency) |
tokens |
list of str | no | Keyword only. Without token: the coins to offer, such as ["USDT_TRC20", "USDT_BEP20"]. Default: every coin you accept whose minimum the amount reaches |
description |
str | no | Keyword only. What the customer pays for, up to 500 bytes |
metadata |
dict of str to str | no | Keyword only. Your own data: up to 20 keys of up to 40 bytes, values of up to 500 |
customer_email |
str | no | Keyword only. The customer's email address |
success_url |
str | no | Keyword only. http(s) URL the hosted checkout links to once the payment is confirmed |
cancel_url |
str | no | Keyword only. http(s) URL the hosted checkout links back to if the payment closes unpaid |
simulate |
str | no | Keyword only. Test keys only: the outcome to simulate, one of payitgo.SIMULATION_OUTCOMES. With token it starts at once; without, once the coin is chosen |
Keyword arguments whose value is None are not sent. Any other keyword is sent
to the API as it is (the API ignores fields it does not know).
Returns the Payment: the new one (201) or the order's open
one (200); both look the same. Fields: the payment
object.
Errors PayitgoError with status 400 for an invalid request: a missing
order_id, amount must be > 0, amount is worth less than a cent,
currency must be the ISO 4217 code of a currency (USD, EUR, GBP, NGN…),
a token you do not accept, an amount under the token's minimum
(minimum payment in BTC is 4.50 EUR right now (network fees); $5.00 for
a payment in dollars) or, without a token, under every coin's
(amount is below the minimum of every token on offer), a webhook_url
that is not public https, a simulate with a live key or an unknown
outcome, and the rest of the create errors. 503
(exchange rate unavailable for currency: try again shortly) when no
exchange rate can be had for currency (after the retries).
Also 401, 403, 429, 500 and 0 as for every call.
# The customer pays in a coin you know:
payment = client.payments.create(
order_id="ORD-1001",
amount="49.90",
token="USDT_TRC20",
description="2 x Acme T-shirt",
metadata={"customer_id": "cus_42"},
customer_email="[email protected]",
success_url="https://yourdomain.com/thanks",
cancel_url="https://yourdomain.com/cart",
)
# payment.deposit_address, payment.crypto_amount, payment.qr_payload, payment.expires_at
# The customer chooses the coin (on the hosted page, or yours):
open_payment = client.payments.create(order_id="ORD-1002", amount=25)
for option in open_payment.get("token_options", []):
print(option.token, option.minimum, option.get("amount_due", ""))
# This payment's notifications go to its own URL:
client.payments.create(
order_id="ORD-1003",
amount=30,
token="USDT_TRC20",
webhook_url="https://api.yourdomain.com/orders/ORD-1003/ipn",
)
# Priced in euros: every figure on the payment is in EUR, in every response and webhook.
priced = client.payments.create(order_id="ORD-1004", amount="45.50", currency="EUR", token="USDT_TRC20")
# priced.currency "EUR", priced.amount "45.5", priced.crypto_amount "49.23"
payments.retrieve
GET /v1/payments/{id} · API reference
client.payments.retrieve(id) -> PayitgoObject
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | yes | The payment's id, or your order_id for the order's open payment (the payment id is tried first). Escaped for the URL by the library |
Returns the Payment.
Errors PayitgoError 404 (payment not found) for an unknown id, a payment
of the other mode, or an order with no open payment. Plus the
common statuses.
by_id = client.payments.retrieve("8f3a2c1e9b7d4a6f05e1c2d3")
by_order = client.payments.retrieve("ORD-1001") # the order's open payment
if by_id.status == "confirmed":
print("paid at", by_id.confirmed_at)
payments.list
GET /v1/payments · API reference
client.payments.list(status=None, chain=None, token=None, limit=None, offset=None, store_id=None) -> PayitgoObject
Payments of the key's mode, newest first.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
status |
str | no | all | Only payments in this status, such as "confirmed" |
chain |
str | no | all | Only payments on this network, such as "tron" |
token |
str | no | all | Only payments in this coin, such as "USDT_TRC20" |
limit |
int | no | 50 |
Page size, 1 to 200 (0 or less: 50; over 200: 200) |
offset |
int | no | 0 |
How many to skip |
store_id |
str | no | all | Only payments of this store (ignored for a storefront key, which sees its own) |
Arguments left at None are not sent.
Returns a Payment list: payments, total (matches
across all pages), and the limit and offset applied.
Errors the common statuses only. An unknown status, chain or token matches nothing.
# Every confirmed payment, page by page:
confirmed, offset = [], 0
while True:
page = client.payments.list(status="confirmed", limit=100, offset=offset)
confirmed.extend(page.payments)
offset += page.limit
if offset >= page.total:
break
payments.select_token
POST /v1/payments/{id}/token · API reference
client.payments.select_token(payment_id, token) -> PayitgoObject
Sets the coin of a payment created without one, once the customer picked it on your own page, or changes it: another coin, while nothing has arrived (Changing the coin).
| Parameter | Type | Required | Description |
|---|---|---|---|
payment_id |
str | yes | The payment's id or your order_id |
token |
str | yes | One of the payment's token_options[].token, such as "USDT_TRC20" |
Returns the whole Payment, now with deposit_address,
crypto_amount, rate_locked, qr_payload and an expires_at 15 minutes
away.
Errors PayitgoError:
status |
message |
Cause |
|---|---|---|
400 |
token is required |
Empty token |
400 |
token is not one of this payment's options |
A coin not in token_options |
400 |
minimum payment in … is $… right now (it is converted on its way to the merchant, and the exchange takes no less) |
The coin needs a bigger payment than this one: it is converted through the exchange on its way to the merchant, which takes no less, and the merchant pays the fees or hides such coins (hide_below_minimum). Offer the other coins |
400 |
this payment can no longer be paid |
The payment has closed, or it is still pending past its expires_at (an hour to choose the coin, then 15 minutes to pay) |
404 |
payment not found |
No such payment in the key's mode |
409 |
the coin for this payment can no longer be changed |
The payment was created with its coin, something arrived, a test payment's simulation is running, or the coin was changed three times already |
payment = client.payments.create(order_id="ORD-1002", amount=25)
# …your page lists payment.token_options, the customer picks one…
chosen = client.payments.select_token(payment.id, "USDT_BEP20")
print(chosen.crypto_amount, chosen.token, chosen.deposit_address, chosen.expires_at)
payments.simulate
POST /v1/payments/{id}/simulate · API reference
client.payments.simulate(payment_id, outcome) -> PayitgoObject
Plays an outcome on a test payment: payitgo sends its deposits, status changes and webhooks about 5 seconds apart, as live coins would, with no coins (Test mode). Test keys only.
| Parameter | Type | Required | Description |
|---|---|---|---|
payment_id |
str | yes | The payment's id or your order_id |
outcome |
str | yes | One of payitgo.SIMULATION_OUTCOMES, such as "confirmed" (what each does) |
Returns the whole Payment, with its simulation started.
Simulated deposits have simulated True; their tx_id names no transaction on any chain.
Errors PayitgoError:
status |
message |
Cause |
|---|---|---|
400 |
outcome is required |
Empty outcome |
400 |
simulate must be one of: confirmed, overpaid, … |
An unknown outcome |
400 |
only test payments can be simulated: use a test key |
A live key |
400 |
choose the payment's coin first |
wrong_asset before a coin is chosen. Any other outcome waits for the coin instead (simulation.state requested) |
400 |
this payment is confirmed: only a pending or partially paid payment can be simulated |
The payment is closed or confirming |
400 |
a BTC address only receives BTC: wrong_asset needs a coin on Tron, Ethereum or BNB Smart Chain |
wrong_asset on a coin that has no other |
404 |
payment not found |
No such payment in the key's mode |
409 |
a simulation is already running for this payment |
Wait until its state is "done" |
payment = client.payments.simulate("ORD-1002", "partially_paid")
print(payment.simulation) # {'outcome': 'partially_paid', 'state': 'running'}
# once it is done, pay the rest:
client.payments.simulate("ORD-1002", "confirmed")
Tokens
tokens.list
GET /v1/tokens · API reference
client.tokens.list(amount=None, currency=None) -> list[PayitgoObject]
The coins your customers can pay with in the key's mode, with today's network
fee and minimum, in currency (US dollars without one). With amount, only
the coins a payment of that amount offers (its token_options), each with
amount_due when you pass the fees on.
| Parameter | Type | Required | Description |
|---|---|---|---|
amount |
str, Decimal or int |
no | The order's amount, in currency, such as "49.90" |
currency |
str | no | The ISO 4217 code the amount and every figure are in, such as "EUR" (any case). Default USD |
Returns a list of TokenInfo (the library unwraps the API's
{"currency": "USD", "tokens": […]}).
Errors PayitgoError 400 (amount must be > 0) for an amount that is
not a positive number, 400 (currency must be the ISO 4217 code of a currency (USD, EUR, GBP, NGN…))
for a code that is no currency, 503 (exchange rate unavailable for currency: try again shortly)
when its exchange rate cannot be had, and the common statuses.
for t in client.tokens.list(amount="49.90"):
print(f"{t.token} on {t.chain}: pay ${t.get('amount_due', '49.90')}, {t.fee_note}")
Webhooks
The webhook (IPN) of the key's mode: one URL that receives every notification
of that mode, and the secret that signs them
(Webhooks). A test key manages the test
webhook, a live key the live one. A storefront
key can get and test it, but not
set or remove it.
webhooks.get
GET /v1/webhook · API reference
client.webhooks.get() -> PayitgoObject
Returns the Webhook: url (None when none is set) and
secret, the signing secret to give the client as webhook_secret.
It always succeeds for a valid key.
webhook = client.webhooks.get()
print(webhook.url, webhook.secret)
webhooks.set
PUT /v1/webhook · API reference
client.webhooks.set(url) -> PayitgoObject
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
str | yes | An absolute https:// URL on a public host that accepts POST |
Returns the Webhook with its new url. The secret does not
change. Setting the URL it already has changes nothing.
Errors PayitgoError 400 (url is required, url must use https,
url must be an absolute http(s) URL, url host does not resolve,
url must point at a public host, url must point at your own server, not payitgo's), 403 for a storefront key, 500
(could not set the webhook), and the common statuses.
client.webhooks.set("https://api.yourdomain.com/payitgo/ipn")
webhooks.remove
DELETE /v1/webhook · API reference
client.webhooks.remove() -> PayitgoObject
Stops posting the mode's notifications to its URL. Payments created with their
own webhook_url still get theirs, and the secret is kept.
Returns the Webhook with url None.
Errors 403 for a storefront key, 500 (could not remove the webhook),
and the common statuses.
webhooks.test
POST /v1/webhook/test · API reference
client.webhooks.test() -> PayitgoObject
Queues a signed ping notification to the mode's URL; it arrives within about
5 seconds.
Returns the Delivery, with status "pending".
Errors PayitgoError 400 (no webhook url is set for this mode: set one first), 500 (could not queue the test), and the
common statuses.
delivery = client.webhooks.test()
print(delivery.id, delivery.event_type, delivery.url) # 6710c3a1f2b4e5d6a7b8c9d0 ping https://…
webhooks.construct_event
No request · how verification works
client.webhooks.construct_event(payload, signature_header, secret=None, tolerance=None) -> PayitgoObject
Verifies a notification and returns its event. It computes the HMAC-SHA256 of
t + "." + payload with the secret, compares it with v1 in constant time,
checks that t is within the tolerance of your clock, and only then parses the
body.
| Parameter | Type | Required | Description |
|---|---|---|---|
payload |
bytes or str | yes | The raw request body, exactly as received (request.get_data() in Flask, await request.body() in FastAPI, request.body in Django). A body parsed and serialized again will not verify (keep the raw body). A str is encoded as UTF-8 |
signature_header |
str or None |
yes | The X-Webhook-Signature header |
secret |
str | no | The signing secret, as payitgo gave it. Default: the client's webhook_secret. A secret passed here wins |
tolerance |
int | no | How far t may be from your clock, in seconds. None (the default) means 300. 0 turns the timestamp check off (only for tests with captured bodies) |
Returns the Event.
Errors SignatureVerificationError. Answer
400.
event = client.webhooks.construct_event(request.get_data(), request.headers.get("X-Webhook-Signature"))
if event.type == "payment.confirmed":
print(event.data.order_id)
payitgo.Webhook.construct_event
payitgo.Webhook.construct_event(payload, signature_header, secret, tolerance=300) -> PayitgoObject
The same check without a client, for code that has the secret but no API key.
secret is required; tolerance is in seconds (payitgo.Webhook.DEFAULT_TOLERANCE
is 300), and 0 turns the timestamp check off.
event = payitgo.Webhook.construct_event(raw_body, signature_header, os.environ["PAYITGO_WEBHOOK_SECRET"])
Errors SignatureVerificationError, except
the "no webhook secret" one.
Events
Every event of the key's mode is kept, exactly as its webhook carried it:
read them again to catch up on what your system missed
(Replay events). Any account key of the mode
reads them, read-only ones too; a storefront
key gets 403.
events.list
GET /v1/events · API reference
client.events.list(type=None, after=None, created_after=None, limit=None) -> PayitgoObject
The mode's events, oldest first. Pings are left out, and events of the last few seconds are left for the next read, so reading on never skips one.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
type |
str, or list of str | no | all | Only events of this type ("payout_item.sent"), of a family ("payout_item.*"), or of any of a list (sent comma-separated) |
after |
str | no | An event's id: the events after it. Keep the last one you handled |
|
created_after |
datetime or str |
no | The events after this time, ignored with after. A datetime is sent as RFC 3339 in UTC (a naive one is taken as UTC); a str is sent as given |
|
limit |
int | no | 100 |
Page size, 1 to 200 |
Arguments left at None are not sent.
Returns an Event list: events, each an Event
as construct_event returns it, and has_more.
While has_more, call again with after the last event's id. A key
without payouts gets claim links without their url and pin.
Errors PayitgoError:
status |
message |
Cause |
|---|---|---|
400 |
type must be event types, such as payout_item.sent or payout_item.* |
|
400 |
created_after must be an RFC 3339 time, such as 2026-10-20T09:00:00Z |
|
400 |
limit must be 1 to 200 |
|
400 |
after is not an event of this mode |
An unknown id, or the other mode's |
403 |
a storefront's key cannot read the account's events: use an account key |
after = load_last_event_id() # your code: the id of the last event you handled, or None
while True:
page = client.events.list(type="payout_item.*", after=after)
for event in page.events:
handle(event) # the same code as your webhook handler, which skips ids it has handled
after = event.id
save_last_event_id(after)
if not page.has_more:
break
Checkout
These two calls use the public checkout API:
they are sent without your API key and are keyed by the payment's
checkout_token. They return the payer's view of a payment. On your
server you rarely need them: payments.retrieve and payments.select_token
return more. The client still needs a key to be created, though these
calls never send it.
checkout.retrieve
GET /checkout/{checkout_token} · API reference
client.checkout.retrieve(checkout_token) -> PayitgoObject
| Parameter | Type | Required | Description |
|---|---|---|---|
checkout_token |
str | yes | The payment's checkout_token |
Returns a Payment without your private fields: merchant_id,
metadata, customer_email, customer_id, webhook_url, checkout_token,
checkout_url and opened_at are absent, and channel is "". Reading it from your server does not count as the customer opening the
checkout page.
Errors PayitgoError 404 (payment not found), 0 and 5xx.
checkout.select_token
POST /checkout/{checkout_token}/token · API reference
client.checkout.select_token(checkout_token, token) -> PayitgoObject
| Parameter | Type | Required | Description |
|---|---|---|---|
checkout_token |
str | yes | The payment's checkout_token |
token |
str | yes | One of the payment's token_options[].token |
Returns the payer's view of the Payment with its coin, address, amount and a 15-minute deadline.
Errors the same as payments.select_token, and
429 (rate limit exceeded) when choices come too fast from one visitor.
view = client.checkout.retrieve("b28d4f61e9a03c75d2e8f1a6")
if view.token == "":
chosen = client.checkout.select_token("b28d4f61e9a03c75d2e8f1a6", "USDT_TRC20")
print(chosen.deposit_address)
Payouts
Pay your own clients (withdrawals from your platform, prizes, payroll) from
your payout wallet: one address per network, yours alone, that you top
up. Each payment costs 0.5% (at least $0.50) plus its network fee; the coins
it pays in, such as USDT_TRC20 or USDT_BEP20, are listed in
Mass payouts.
There are two ways to send them:
- Payout requests, one by one. Your system sends each client's request as
it comes in (
payouts.request). payitgo checks and prices it at once and keeps it in your open list (payouts.inbox) until you send the list, or until it goes by itself with auto-send in your payout settings (Payout requests). - Batches. A whole list at once (payroll, prizes), made in the dashboard
under Pay people, typed, pasted or uploaded as a CSV file, or on a
schedule. Read one with
payout_batches.retrieveand follow it through its webhooks.
A payment with claim=True and no address is a claim link:
its recipient chooses the coin and the address. A batch or quote with convert pays
recipients in other coins than the wallet holds, converted on their
way.
Either way the payments end up in a batch that waits for its approvals (your
payout settings) and for funds, then is
sent (a batch's life). Reading works with any
key. Everything that changes something needs a key with payouts turned on
in the dashboard (The API); any other key gets
403:
status |
message |
Cause |
|---|---|---|
403 |
this api key cannot make payouts: turn payouts on for it in the dashboard |
The key's payouts is off |
403 |
your payout rules require keys limited to IP addresses: set this key's allowed IPs |
api_require_allowlist is on and the key has no allowed_ips |
A test key works with the test payout wallet, on paper
(In test mode); a batch or payment of the other
mode is 404.
from decimal import Decimal
item = client.payouts.request(
asset="USDT_TRC20",
address="TR7mNkucnhLZoJQLLJ6DR88jpLQufWxUJi",
amount="25.50",
reference="withdrawal-1001", # your id: safe to retry
)
inbox = client.payouts.inbox()
for c in inbox.coverage:
if Decimal(c.top_up) > 0:
print(f"send {c.top_up} {c.asset} to {c.address} first")
batch = client.payouts.send() # every valid request, as one batch
print(batch.status) # pending_approval, awaiting_funds or processing
payouts.request
POST /v1/payouts · API reference · a key with payouts on
client.payouts.request(asset, address=None, amount=None, reference=None, *, tag=None, name=None, email=None,
note=None, claim=None, claim_assets=None, webhook_url=None) -> PayitgoObject
Adds one of your clients' payout requests to your open list, checked and priced at once with today's fees. It waits there, with its costs, until you send the list (or auto-send does).
| Parameter | Type | Required | Description |
|---|---|---|---|
asset |
str | yes | The coin, such as "USDT_TRC20" (any case): one of the coins payouts pay in |
address |
str | yes, unless a claim link | The client's address on the coin's network. Leave it out for a claim link (with claim=True) |
amount |
str, Decimal or int |
yes | How much of the coin, such as "25.50". Sent as str(amount): prefer a string or a Decimal to a float. When the recipient pays the fees (your payout settings' fee_paid_by), they come out of it. Leaving it out raises TypeError without a request |
reference |
str | no, but send one | Your id for it (the withdrawal request's), unique in its mode across every payout. A reference that a payment carries already returns that payment (references and retries) |
tag |
int | no | Keyword only. A destination tag, for XRP |
name, note |
str | no | Keyword only. Who it is for, and why: kept with it and shown in the dashboard |
email |
str | no | Keyword only. The recipient's email. For a claim link the link is emailed there; otherwise nothing is sent to it. An email alone makes no claim link |
claim |
bool | no | Keyword only. True (with no address) makes it a claim link. Without an email, share its claim.url yourself, and its claim.pin another way |
claim_assets |
list of str | no | Keyword only. Makes it a claim link too: the other coins its recipient may choose (up to 10), paid at the same dollar value |
webhook_url |
str | no | Keyword only. An https:// URL on a public host: this payment's events go there instead of your webhook's URL, signed with the same secret. It stays with the request when it is sent. The client's webhook_url is not used for payout requests |
Arguments left at None are not sent.
Returns the PayoutItem: the new one (201) or the payment
the reference already names (200); both look the same. A valid request is
ready, with its fee, send_amount and debit (and, for a claim link,
its claim). An invalid one is still
kept, as invalid, and never sent: its errors say why
(issues), for you to tell your client.
Errors PayitgoError 403 for a key without payouts (above), 409
(your list of payout requests is full: send or cancel some first), 400
(invalid request body) for a field of the wrong type, 400
(webhook_url: url must use https, webhook_url: url host does not resolve,
webhook_url: url must point at a public host, webhook_url: url must point at your own server, not payitgo's), 400
(your payout wallet cannot pay this request and those already in your list; send … first, then try again) when
the payout wallet cannot pay it with the requests already waiting (nothing is
added), 503 when its balance cannot be checked just now (send it again),
and the
common statuses. A request's own problems never raise: they
are its errors.
item = client.payouts.request("USDT_BEP20", "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed", "120",
"withdrawal-1002", name="Ben Okafor", email="[email protected]")
if item.status == "invalid":
reject_withdrawal(item.errors[0].message) # e.g. "this address is for Tron, not BNB Smart Chain"
else:
print("fee", item.fee, "they receive", item.send_amount)
payouts.retrieve
GET /v1/payouts/{id} · API reference
client.payouts.retrieve(id) -> PayitgoObject
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | yes | The payment's id: a payout request, or a payment of a batch. Escaped for the URL by the library |
Returns the PayoutItem.
Errors PayitgoError 404 (not found) for an unknown id or a payment
of the other mode, and the common statuses.
payouts.retrieve_by_reference
GET /v1/payouts?reference= · API reference
client.payouts.retrieve_by_reference(reference) -> PayitgoObject
| Parameter | Type | Required | Description |
|---|---|---|---|
reference |
str | yes | Your reference for the payment, a request's or a batch payment's |
Returns the PayoutItem that carries it; if none does, the
latest that gave it back (canceled, failed or expired, with it as
released_reference): what became of a request sent with it.
Errors ValueError (payitgo: reference is required, raised by the library,
no request) for an empty one, PayitgoError 404 (not found), and the
common statuses.
item = client.payouts.retrieve_by_reference("withdrawal-1001")
print(item.status, item.get("tx_id"))
payouts.list
GET /v1/payouts · API reference
client.payouts.list(status=None, updated_since=None, cursor=None, limit=None) -> PayitgoObject
Every payment of the key's mode, whatever its batch (requests in your list, removed ones, every batch's), oldest change first: to bring your system back in sync after it was down, or to check it is. Changes of the last few seconds are left for the next read, so a cursor never skips one.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
status |
str, or list of str | no | all | Only payments in this status, or in any of a list (sent comma-separated): ["sent", "failed", "canceled", "expired"] for the ended ones |
updated_since |
datetime or str |
no | Payments changed at or after this time. A datetime is sent as RFC 3339 in UTC (a naive one is taken as UTC); a str is sent as given |
|
cursor |
str | no | The next_cursor of the page before: the payments changed after the last one it listed |
|
limit |
int | no | 50 |
Page size, 1 to 200 |
Arguments left at None are not sent.
Returns a Payout page: the payments, read as
page["items"] (page.items is the dict method), has_more, and
next_cursor (absent from an empty page: read it with .get()). Read with
updated_since the first time, then with cursor while has_more; keep the
last next_cursor to read what changed since, next time.
Errors PayitgoError:
status |
message |
Cause |
|---|---|---|
400 |
updated_since must be an RFC 3339 time, such as 2026-10-20T09:00:00Z |
A str that is not one |
400 |
limit must be 1 to 200 |
|
400 |
cursor is not one this API gave |
from datetime import datetime, timezone
cursor = load_payout_cursor() # your code: the last next_cursor you kept, or None
while True:
if cursor:
page = client.payouts.list(cursor=cursor, limit=200)
else:
page = client.payouts.list(updated_since=datetime(2026, 10, 1, tzinfo=timezone.utc), limit=200)
for item in page["items"]:
sync_withdrawal(item) # your code: acts on item.status
cursor = page.get("next_cursor") or cursor
if not page.has_more:
break
save_payout_cursor(cursor)
payouts.inbox
GET /v1/payouts/inbox · API reference
client.payouts.inbox(status=None, limit=None, offset=None) -> PayitgoObject
Your open list of payout requests in the key's mode: the requests not sent yet, and what sending them takes of each coin against what the wallet can spend.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
status |
str, or list of str | no | all | Only requests in this status ("ready", "invalid"), or in any of a list (sent comma-separated) |
limit |
int | no | 50 |
Page size, 1 to 200 (0 or less: 50; over 200: 200) |
offset |
int | no | 0 |
How many to skip |
Arguments left at None are not sent.
Returns an Inbox: the list as a batch (inbox, its totals
and counts), coverage (per coin: needed, spendable, and top_up, what
to send to address before sending the list) and the requests, read as
page["items"] (page.items is the dict method).
Errors the common statuses only.
page = client.payouts.inbox(status="invalid")
for item in page["items"]:
print(item.reference, item.errors[0].message)
payouts.send
POST /v1/payouts/send · API reference · a key with payouts on
client.payouts.send(ids=None) -> PayitgoObject
Sends your open list: every ready request, or only those of ids. They move
into a batch of their own (source "requests"), priced again at today's
fees and submitted: it then waits for its approvals and for funds, or starts at
once. Each request sent raises payout_item.processing, with its new
batch_id. Requests that are invalid, or not among ids, stay in the list.
At most 10,000 go in one batch; the rest wait for the next send. A request no
longer valid when priced again comes back to the list with its errors
(payout_item.returned); the others go on.
| Parameter | Type | Required | Description |
|---|---|---|---|
ids |
list of str, or str | no | The ids of the requests to send (a str is one id). None sends every valid request. An empty list raises ValueError without a request: the API would take it as every request |
Returns the PayoutBatch they became: pending_approval,
awaiting_funds (its waiting says what to top up, and where) or
processing. Past 100 requests it comes back validating and is submitted
once checked (payout_batch.quoted follows). If the batch cannot be submitted
(none of its requests is valid any more at today's prices, or it is over your
limit per batch), the requests go back to your list, each saying why
(payout_item.returned), that batch is canceled (payout_batch.canceled,
canceled_by "system"), and send raises the error. A batch priced in the
background is canceled the same way, and your team gets a "Payout requests
not sent" notification.
Errors PayitgoError:
status |
message |
Cause |
|---|---|---|
400 |
no valid payout request to send · no payout request to send |
Nothing ready in the list |
400 |
payout request … is not a valid request waiting in your list |
An id that is not a ready request of the list |
400 |
none of the requests is valid any more: they are back in your list, each saying why |
Priced again, none can be paid |
400 |
this batch takes $…, over your limit of $… per batch |
Over your batch_max_usd: the requests are back in the list |
403 |
A key without payouts (above) |
batch = client.payouts.send()
if batch.status == "awaiting_funds" and batch.waiting.reason == "funds":
for s in batch.waiting.shortfall:
print(f"top up {s.amount} {s.asset} at {s.address}") # it starts by itself once funded
payouts.cancel
DELETE /v1/payouts/{id} · API reference · a key with payouts on
client.payouts.cancel(id) -> PayitgoObject
Takes a payment out. A request still in your open list is removed: it comes
back canceled with cancel_reason "removed", its reference is free
again (it moves to released_reference), it no longer has a batch_id, and
its record stays: retrieve keeps answering it. A
payment sent already but not on its way yet is canceled, with
cancel_reason "canceled": in a funded batch (cooling, queued, a claim
link still claimable, or sending until its transfer is signed) its money
stays in the wallet and its fee comes back (Fees); in a
batch not funded yet, the batch is totalled again, and canceled when nothing
is left in it. Either way payout_item.canceled is sent. A payment canceled
already is answered as it is: safe to repeat.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | yes | The payment's id |
Returns the PayoutItem, canceled.
Errors PayitgoError 404 (not found) for an unknown id or a payment
of the other mode, 409 (the payment is sent, or failed, expired) once
it ended, 403 for a key without payouts, and the
common statuses.
item = client.payouts.cancel(item.id)
print(item.status, item.cancel_reason, item.get("released_reference")) # canceled removed withdrawal-1001
payouts.quote
POST /v1/payout-quotes · API reference · a key with payouts on
client.payouts.quote(items, fee_paid_by=None, *, convert=None, convert_from=None) -> PayitgoObject
What up to 100 payments would cost, checked and priced exactly as in a batch, without keeping anything: show a client their fee before they ask.
| Parameter | Type | Required | Description |
|---|---|---|---|
items |
list of dict | yes | 1 to 100 payments (below) |
fee_paid_by |
str | no | "merchant" (fees on top) or "recipient" (fees out of each amount). Default: your payout settings' |
convert |
str | no | Keyword only. "same_network" (each payment from the wallet's own coin) or "convert", which pays every payment in another coin than convert_from from convert_from, converted on its way. Default: your payout settings' |
convert_from |
str | no | Keyword only. The wallet's coin converted payments are paid from, such as "USDT_TRC20". Default: your payout settings' |
Each payment is a dict:
| Key | Type | Required | Description |
|---|---|---|---|
asset |
str | yes | The coin, such as "USDT_TRC20" (any case). With convert, the coin the recipient receives |
address |
str | yes, unless a claim link | The recipient's address on the coin's network. Leave it out for a claim link (with claim) |
amount |
str, Decimal or int |
yes | How much of the coin. The library sends it as str(amount) |
reference |
str | no | Your id for this payment, unique in its mode (retries) |
name, note |
str | no | Who it is for, and why |
email |
str | no | The recipient's email: a claim link is emailed there. An email alone makes no claim link |
claim |
bool | no | True (with no address): a claim link. Without an email, share its claim.url, and its claim.pin another way |
claim_assets |
list of str | no | Makes it a claim link too: the other coins its recipient may choose |
tag |
int | no | A destination tag, for XRP |
Keys set to None are not sent.
Returns a Payout quote: quote (the totals a batch of
them would have) and the payments as they would be, read as
result["items"], without id, merchant_id, batch_id or times.
Errors PayitgoError 400 (quote between 1 and 100 payments,
fee_paid_by must be merchant or recipient, convert must be same_network or convert,
convert_from: payouts are not paid from …), 403, and the
common statuses.
result = client.payouts.quote([{"asset": "USDT_BEP20", "address": "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed",
"amount": "120"}], fee_paid_by="recipient")
row = result["items"][0]
print(row.fee, row.send_amount) # 0.61183421 119.38816579
payout_batches.retrieve
GET /v1/payout-batches/{id} · API reference
client.payout_batches.retrieve(id) -> PayitgoObject
A batch by its id, whether made in the dashboard or by
payouts.send.
Returns the PayoutBatch. Errors 404 (not found)
for an unknown id or a batch of the other mode.
payout_wallets.list
GET /v1/payout-wallets · API reference
client.payout_wallets.list() -> list[PayitgoObject]
Your payout wallet in the key's mode, one per network, each with what it holds of each coin. It is made the first time it is asked for, and never changes.
Returns a list of PayoutWallet (the library unwraps the
API's {"wallets": […]}).
for wallet in client.payout_wallets.list():
for a in wallet.assets:
print(wallet.network, wallet.address, a.asset, "spendable", a.spendable, "needed", a.needed)
payout_wallets.simulate_top_up
POST /v1/payout-wallets/{asset}/simulate-top-up · API reference · a test key with payouts on
client.payout_wallets.simulate_top_up(asset, amount) -> list[PayitgoObject]
Test keys only: adds amount of asset to the test wallet's balance on
paper, and funds any test batch waiting for it. Test payments are then sent on
paper within seconds, each with a made-up tx_id (on no chain), and their
webhooks follow as live ones would.
| Parameter | Type | Required | Description |
|---|---|---|---|
asset |
str | yes | One of the payout coins, such as "USDT_TRC20" |
amount |
str, Decimal or int |
yes | Over 0, up to 10,000,000. Sent as str(amount) |
Returns the wallets, as list does.
Errors PayitgoError 400 (only a test wallet is topped up on paper: use a test key
for a live key, payouts in … are not available yet for a coin payouts do not pay in,
amount must be over 0 and at most 10000000), 403.
client.payout_wallets.simulate_top_up("USDT_TRC20", "1000")
Claim links
Claim links · no route of their own
When you don't know a recipient's address, pass claim=True (a
"claim": True key in a batch row) or claim_assets, and leave the address
out: the payment is a claim link, and its recipient chooses the coin and
the address on a page of payitgo's. With an email, payitgo emails them the
link; without one, share claim.url yourself, and give its PIN, claim.pin
(6 digits), another way (a call, a text message): the recipient enters it to
claim, so the link alone pays no one. After 5 wrong PINs the link is locked
(claim.pin_locked) until a new PIN is made in the dashboard. claim_assets are the other
coins they may choose, paid at the same dollar value. Payout requests, batch
rows and quotes all take them. An email alone makes no claim link: a payment
with neither an address nor claim is invalid (invalid_address).
item = client.payouts.request(
asset="USDT_TRC20",
amount="50",
reference="prize-cup-final-1",
claim=True,
email="[email protected]", # optional: the link is emailed here
claim_assets=["USDT_BEP20", "USDC_BEP20"],
)
# In a batch: {"reference": "prize-cup-final-2", "asset": "USDT_TRC20", "amount": "25", "claim": True}
status |
What it means |
|---|---|
ready |
Checked and priced, waiting for its batch to be funded (its address is "") |
claimable |
Funded: its money is kept for it until claim.expires_at. Share or resend the link |
queued, sending, sent |
Claimed (claim.claimed_at): paid like any payment, to the coin and address chosen |
expired |
Never claimed: its money is free again and its reference given back |
Read item.claim (PayoutItem): url, pin, pin_locked,
email, assets, expires_at, claimed_at, emailed, last_email_at,
extended, and funded_asset / funded_amount when the recipient chose
another coin than the one it was funded with (its asset, amount and fees are then those of
the coin chosen). The webhooks payout_item.claimed and
payout_item.claim_expired carry the payment. An address with claim=True
is an invalid_address error, and an email that is not one an
invalid_email error. Emailing the link again and extending it are done in
the dashboard.
Converted payments
To pay recipients in another coin than your wallet holds, pass
convert="convert" to payouts.quote. Every payment in
another coin than convert_from is then paid from the wallet's
convert_from, converted on its way. Both default to your payout settings,
which payout requests follow.
result = client.payouts.quote(
[{"asset": "BTC", "address": "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", "amount": "0.001"}],
convert="convert",
convert_from="USDT_TRC20", # paid from the wallet's USDT on Tron
)
item = result["items"][0]
print(item.convert.to, item.convert.to_amount, item.convert.estimate) # BTC 0.001 0.00100502
print(item.asset, item.amount, item.fee, item.debit) # USDT_TRC20 65 4.442417 69.442417
For a converted payment:
| Key | In |
|---|---|
asset, amount, send_amount, fee, debit |
The wallet's coin (convert_from): amount is what convert.to_amount is worth, send_amount what goes to be converted, fee with converting included |
address |
The recipient's, on the network of convert.to |
convert.to, convert.ticker, convert.network |
The coin the recipient receives |
convert.to_amount |
What you asked to pay, in convert.to |
convert.estimate |
About what arrives, in convert.to |
convert.amount_out |
What arrived, once sent |
A batch with converted payments holds its prices for 15 minutes instead of
an hour. A coin that cannot be converted into right now is a
conversion_unavailable error on the payment. Claim links are never
converted: their recipient chooses among the wallet's coins.
Staying in sync
Payout webhooks · Staying in sync
A payment's events go to its own webhook_url when it has one; otherwise to
its batch's webhook_url; otherwise to your webhook's URL. Withdrawals and
schedules always go to your webhook's URL.
Every payment, a payout request or a batch row, ends sent, failed,
canceled or expired, and each end has its event: payout_item.sent,
payout_item.failed, payout_item.canceled (whoever canceled it:
cancel_reason and canceled_by say why and who) or
payout_item.claim_expired. Each is delivered at least once and keeps its
id however often it is sent: deduplicate on event.id. Order is not
guaranteed: act on event.data.status and the latest event.data.updated_at,
never on the order events arrive in. A payout request also tells you when it
leaves your list (payout_item.processing) and when it comes back
(payout_item.returned, not final). After an outage, replay what you missed
with client.events.list (after the last event id you
handled), and resync your payments with
client.payouts.list (keep its next_cursor).
def on_payout_item(event): # a payout_item.* event, from construct_event or events.list
if is_processed(event.id):
return # a retry, or replayed
item = event.data
if is_newest(item.id, item.updated_at): # your code: no later change of it handled yet
if item.status == "sent":
mark_withdrawal_paid(item.get("reference"), item.tx_id)
elif item.status in ("failed", "canceled", "expired"):
# Never paid: its money stays in your wallet, and its reference is given back.
release_withdrawal(item.get("reference") or item.get("released_reference"))
mark_processed(event.id)
Types
PayitgoObject
Every response is a payitgo.PayitgoObject: a dict whose keys can also be read as
attributes, at every level (nested dicts are PayitgoObject too, lists are plain
lists).
payment["status"] == payment.status # True
payment.deposits[0].amount # nested objects too
payment.get("checkout_url") # optional keys: use .get()
json.dumps(payment) # it is a dict
Optional keys are absent when they have no value: reading a missing one as an
attribute raises AttributeError, so use .get() for them. A key that is a
Python keyword (from in a deposit) can only be read with [], and so can a
key named like a dict method: page["items"] in payout lists, since
page.items is the dict's own items().
Amounts are decimal strings ("49.9"): convert them with decimal.Decimal,
never float. Times are RFC 3339 strings ("2026-10-10T09:15:00.112Z"):
datetime.fromisoformat() reads them on Python 3.11 and later.
The tables list each object's keys and their Python types; the linked API pages say what each one means. "Optional" keys may be absent.
Payment
| Key | Type |
|---|---|
id, order_id, status |
str |
merchant_id |
str (absent from the checkout view) |
store_id |
str, optional |
token, chain, deposit_address |
str ("" until the coin is chosen) |
token_options |
list of TokenInfo, optional (while the coin can be chosen or changed) |
previous_coins |
list, optional: the coins chosen before token, each with token, chain, deposit_address, destination_tag, crypto_amount, rate_locked |
destination_tag |
int, optional (XRP only) |
livemode, fees_paid_by_customer |
bool |
simulation |
PayitgoObject, optional (a test payment's simulated outcome): outcome (one of payitgo.SIMULATION_OUTCOMES) and state ("requested", "running" or "done") |
currency |
str: what the payment is priced in, an ISO 4217 code ("USD" unless you gave one) or a payment link's coin (your currency). Every figure below is in it |
amount, amount_due, amount_received |
str (decimal): the price, what the customer pays (the price plus the fees when you pass them on) and what arrived so far, in currency |
amount_extra |
str (decimal), optional: what of amount_due only reaches the exchange's minimum; you receive it |
crypto_amount, crypto_received |
str (decimal): what the customer sends, and what arrived, in the coin |
confirmations, confirmations_required |
int: the latest deposit's confirmations, out of what makes it final on the payment's network. Show "12 of 20" while status is detecting |
detected_at |
str (RFC 3339), optional: when the first deposit was seen |
rate_locked |
str (decimal): the coin's price in currency, locked when the coin was chosen |
settlement |
str: "direct" or "custodial" |
tx_id |
str, optional |
overpaid, paid_late |
bool, optional |
deposits |
list of Deposit |
expires_at, created_at |
str (RFC 3339) |
confirmed_at |
str, optional |
network_fee_note, qr_payload |
str ("" until the coin is chosen) |
checkout_token |
str (absent from webhooks and the checkout view) |
checkout_url |
str, optional |
token_name, token_ticker, token_icon_url, network |
str, optional (once the coin is chosen) |
confirmations, confirmations_required |
int |
explorer_url, detected_at, opened_at |
str, optional (opened_at absent from the checkout view) |
channel |
str: "mobile", "desktop", "api" or "" ("" in the checkout view) |
link_id, customer_id |
str, optional (customer_id absent from the checkout view) |
description, customer_email, success_url, cancel_url, webhook_url |
str, optional |
metadata |
PayitgoObject of str, optional |
Deposit
| Key | Type |
|---|---|
tx_id, token, chain, status, seen_at |
str |
amount, value |
str (decimal): in the coin, and in the payment's currency |
counted |
bool |
confirmations, confirmations_required |
int |
ticker, icon_url, explorer_url |
str, optional (explorer_url absent for a test payment) |
late |
bool, optional |
simulated |
bool, optional (played by a test payment's simulation: its tx_id is on no chain) |
confirmed_at, made_at, failed_at, fail_reason |
str, optional |
from |
str, optional (read it as deposit["from"] or deposit.get("from")) |
to |
str, optional: the address it was sent to, the payment's or a previous coin's |
block |
int, optional |
Payment list
What payments.list returns.
| Key | Type |
|---|---|
payments |
list of Payment |
total, limit, offset |
int |
TokenInfo
| Key | Type |
|---|---|
token, chain, name, ticker, network, icon_url, fee_note |
str |
confirmations |
int |
minimum, network_fee |
str (decimal): the smallest payment accepted and the network fee right now, in the listing's currency like every figure here |
network_fee_bps |
int, optional: for a coin that is converted |
amount_due, amount_extra |
str (decimal), optional: with an amount, when you pass the fees on |
Webhook
| Key | Type |
|---|---|
livemode |
bool |
url |
str, or None when none is set |
secret |
str (signs the mode's notifications) |
events |
list of str: the event types it is sent, every one but ping |
created_at, updated_at |
str |
Delivery
| Key | Type |
|---|---|
id, merchant_id, url, event_id, event_type, payload, next_attempt_at, created_at |
str |
livemode |
bool |
target |
str: "account" or "payment" |
status |
str: "pending", "sending", "delivered", "failed" or "resolved" |
attempts, max_attempts |
int |
last_status_code |
int, optional |
last_error, last_attempt_at, delivered_at, resolved_at, resolution_note |
str, optional |
history |
list, optional; each entry has at (str) and, when they apply, url, signed, error, response, note (str), status_code, millis (int) |
PayoutItem
A payment to one recipient: a payout request, a payment of a batch, or a row of a quote (the payment object).
| Key | Type |
|---|---|
id, merchant_id |
str (absent from a quote's rows) |
batch_id |
str, optional: its batch, or your open list's id while it is a payout request waiting there. Absent from a quote's rows and for a request removed from the list |
livemode |
bool |
reference |
str, optional: your id for it |
refused_reference, released_reference |
str, optional: a reference refused because another payment carries it; the reference of a payment never sent, given back for a new one (its reference is then absent) |
row |
int: its place in its batch, from 1 |
recipient |
PayitgoObject: name, email, note, each optional |
asset, chain, address, status |
str. status: "validating", "ready", "invalid", "cooling", "queued", "sending", "sent", "failed", "canceled", and for a claim link "claimable" and "expired" (the payments). address is "" for a claim link not claimed yet; for a converted payment, asset is the wallet's coin and address the recipient's on the network of convert.to |
ticker, icon_url |
str, optional |
tag |
int, optional (XRP) |
amount, send_amount, fee, debit, usd_rate, amount_usd |
str (decimal): what you asked to pay, what reaches the recipient, its whole fee (a converted payment's converting included), what it takes from the wallet, the coin's dollar price and amount in dollars. "0" while validating and when invalid |
claim |
PayitgoObject, optional (claim links): assets (list of str), emailed, extended (int), and optionally email, url, pin, expires_at, claimed_at, last_email_at, funded_asset, funded_amount (str) and pin_locked (bool). url and pin only for a key with payouts on |
convert |
PayitgoObject, optional (converted payments): to, ticker, network, to_amount, estimate (str), and amount_out and sent_at (str) once sent |
errors, warnings |
list of PayitgoObject ([] when none), each with code, message, and optionally field and hint (issues) |
cooling_until |
str, optional: a new recipient's payment waits until then |
tx_id |
str, optional: its transaction, once sent (made up in test mode) |
explorer_url |
str, optional (live only) |
fail_reason |
str, optional |
cancel_reason |
str, optional, once canceled: "removed" (taken out of your list of payout requests), "canceled" (that payment alone, by your team or a key), "batch_canceled" (its batch was canceled), "rejected" (its batch was rejected), "invalid" (no longer payable when its batch was submitted or funded: errors say why) |
cancel_note |
str, optional: with "rejected", the approver's reason |
canceled_by, canceled_at |
str, optional: who canceled it (a team member's id, an API key's id, or "system": payitgo itself), and when |
members |
PayitgoObject, optional: the email of the team member in canceled_by, by id ({"9b2e…": "[email protected]"}) |
webhook_url |
str, optional: where its events go instead of its batch's webhook_url or your webhook's URL |
fee_credit |
str (decimal), optional: the fee given back for a payment never sent |
sent_at |
str, optional |
created_at, updated_at |
str (absent from a quote's rows) |
PayoutBatch
| Key | Type |
|---|---|
id, merchant_id, name, source, created_by, fee_paid_by, status |
str. source: "api", "dashboard", "csv", "requests" or "schedule"; fee_paid_by: "merchant" or "recipient"; status: "validating", "quoted", "pending_approval", "awaiting_funds", "processing", "completed", "canceled" or "rejected" (a batch's life) |
livemode, by_api_key |
bool |
inbox, open |
bool: made of payout requests; your open list itself (only in payouts.inbox) |
reference, webhook_url |
str, optional |
convert |
str: "same_network" or "convert" |
convert_from |
str, optional: the coin converted payments are paid from |
waiting |
PayitgoObject, optional, while it waits: reason ("funds", "daily_limit", "paused"), note, since, and for funds the shortfall: a list of {asset, network, amount, address}, what to send where |
totals |
list of PayitgoObject, per coin of its payments that go: asset, ticker, icon_url, chain, network (str), items (int), amount, send_amount, fee, debit, debit_usd, saved_usd (str, decimal) |
counts |
PayitgoObject of int: total, invalid, ready, cooling, queued, sending, sent, failed, canceled, claimable, expired |
total_usd |
str (decimal): what it takes from the wallet, in dollars |
quote_expires_at |
str, optional: its prices hold until then |
approvals_needed |
int |
approvals |
list of {user_id, at} |
rejection |
PayitgoObject, optional: by, at, reason |
submitted_by, submitted_at, funded_at, completed_at, canceled_by, canceled_at |
str, optional |
members |
PayitgoObject: the emails of the team members it names (created_by, submitted_by, approvals, rejection, canceled_by), by id |
created_at, updated_at |
str |
Inbox
What payouts.inbox returns.
| Key | Type |
|---|---|
inbox |
PayoutBatch: your open list, with inbox and open True. Its totals and counts are those of the requests waiting |
coverage |
list of PayitgoObject, per coin of the valid requests: asset, ticker, network, address (str: where to top up), needed (what sending them takes from the wallet), spendable (what the wallet can spend) and top_up (what to send first, "0" when covered) (str, decimal) |
items |
list of PayoutItem: read it as page["items"] |
total, limit, offset |
int |
Payout quote
What payouts.quote returns.
| Key | Type |
|---|---|
quote |
PayitgoObject: livemode (bool), fee_paid_by and convert (str), convert_from (str, with convert "convert"), totals and counts (as in a PayoutBatch), total_usd (str, decimal) |
items |
list of PayoutItem, without ids or times: read it as result["items"] |
PayoutWallet
| Key | Type |
|---|---|
chain, network, address |
str. chain: the network, such as "tron" or "bsc" |
explorer_url |
str, optional (live only) |
livemode |
bool |
assets |
list of PayitgoObject: asset, ticker, icon_url (str), balance, reserved, spendable, needed (str, decimal) |
error |
str, optional: why its balances could not be read just now |
Payout page
What payouts.list returns.
| Key | Type |
|---|---|
items |
list of PayoutItem, oldest change first: read it as page["items"] |
has_more |
bool |
next_cursor |
str, optional (absent from an empty page): pass it as cursor |
Withdrawal
The data of payout_wallet.withdrawn and payout_wallet.withdrawal_failed:
the wallet's money sent to one of your payout addresses, from the dashboard
(Withdrawals).
| Key | Type |
|---|---|
id, merchant_id, asset, chain, address_id, address, requested_by |
str |
livemode |
bool |
amount, fee, send_amount |
str (decimal): what left the wallet, the fees, what reaches the address |
tag |
int, optional (XRP) |
status |
str: "requested", "sending", "sent" or "failed" |
tx_id, explorer_url, sent_at |
str, optional: once sent (explorer_url live only) |
fail_reason |
str, optional: why it failed; its money stays in the wallet |
members |
PayitgoObject: the email of requested_by, by id |
created_at, updated_at |
str |
Schedule
A summary of a schedule: the data of payout_schedule.run, and the
schedule of payout_schedule.funding_needed
(Schedules). Schedules are made in the dashboard,
and their rows stay there: the library only receives this summary in
webhooks.
| Key | Type |
|---|---|
id, name |
str |
livemode, auto_submit |
bool |
status |
str: "active" or "paused" |
cadence |
str: "weekly", "biweekly" or "monthly" |
weekday, day |
int: the day of the week (0 is Sunday) for weekly and biweekly; the day of the month (1 to 28, or -1 for its last day) for monthly |
at, timezone |
str: the time of day ("09:00") and its IANA time zone |
fee_paid_by |
str |
remind_days |
int: how many days before a run the wallet is checked (payout_schedule.funding_needed) |
totals |
list of {asset, ticker, items, amount}: what a run pays per coin, fees aside |
runs |
int |
next_run_at, last_run_at |
str, or None |
last_batch_id, last_error |
str ("" when none) |
Event
What construct_event returns (the body), and each
event of events.list.
| Key | Type |
|---|---|
id |
str (the same on every retry: deduplicate on it) |
type |
str: one of payitgo.WEBHOOK_EVENTS |
livemode |
bool |
created_at |
str |
data |
PayitgoObject: the Payment for payment.*, the settlement for settlement.*, the payout for payout.*, the PayoutBatch for payout_batch.*, the PayoutItem for payout_item.*, the Withdrawal for payout_wallet.withdrawn and payout_wallet.withdrawal_failed, the Schedule for payout_schedule.run, {"schedule": Schedule, "shortfall": [{asset, network, amount, address}]} for payout_schedule.funding_needed, {"message": "pong"} for ping |
payitgo.WEBHOOK_EVENTS is the tuple of event types:
payment.partially_paid, payment.detecting, payment.confirmed,
payment.underpaid, payment.expired, payment.failed,
payment.wrong_asset, payment.late_deposit, payout.approved,
payout.rejected, payout.sent, settlement.completed, settlement.failed,
payout_batch.quoted, payout_batch.pending_approval,
payout_batch.approved, payout_batch.rejected,
payout_batch.awaiting_funds, payout_batch.processing,
payout_batch.completed, payout_batch.canceled, payout_item.processing,
payout_item.returned, payout_item.sent, payout_item.failed,
payout_item.canceled, payout_item.claimed, payout_item.claim_expired,
payout_wallet.withdrawn, payout_wallet.withdrawal_failed,
payout_schedule.run, payout_schedule.funding_needed and ping
(payout webhooks).
Event list
What events.list returns.
| Key | Type |
|---|---|
events |
list of Event, oldest first |
has_more |
bool: read on with after the last event's id |
Examples
Your own payment page
Show the coins on your own site, create the payment in the coin the customer
picks, and render the amount, address, QR code and deadline from the payment
itself (what to show). Flask, with
segno for the QR code:
# pip install payitgo flask segno
import logging
import os
import payitgo
import segno
from flask import Flask, render_template_string, request
client = payitgo.Client(os.environ["PAYITGO_KEY"])
app = Flask(__name__)
NETWORKS = {
"tron": "Tron (TRC-20)", "ethereum": "Ethereum (ERC-20)", "bsc": "BNB Smart Chain (BEP-20)",
"bitcoin": "Bitcoin", "litecoin": "Litecoin", "dogecoin": "Dogecoin", "xrp": "XRP Ledger",
}
CHOOSE = """
<form method="post">
{% for t in tokens %}
<button name="token" value="{{ t.token }}">
{{ t.token }} on {{ networks.get(t.chain, t.chain) }}: ${{ t.get("amount_due", total) }}
</button>
{% endfor %}
</form>
"""
PAY = """
{% if not p.livemode %}<p><b>Test payment:</b> do not send coins to this address.</p>{% endif %}
<p>Send exactly <b>{{ p.crypto_amount }} {{ p.token.split("_")[0] }}</b>
on <b>{{ networks.get(p.chain, p.chain) }}</b> to</p>
<p><code>{{ p.deposit_address }}</code></p>
{% if p.get("destination_tag") is not none %}<p>Destination tag (required): <b>{{ p.destination_tag }}</b></p>{% endif %}
<img src="{{ qr }}" width="220" height="220" alt="QR code">
<p>Pay before <time datetime="{{ p.expires_at }}">{{ p.expires_at }}</time></p>
"""
# 1. The coins this order can be paid with, and what each costs the customer.
@app.get("/orders/<order_id>/pay")
def choose(order_id):
order = find_order(order_id) # your code: .id and .total ("49.90")
tokens = client.tokens.list(amount=order.total)
return render_template_string(CHOOSE, tokens=tokens, total=order.total, networks=NETWORKS)
# 2. The customer picked one: create the payment in it and show it.
@app.post("/orders/<order_id>/pay")
def pay(order_id):
order = find_order(order_id)
try:
payment = client.payments.create(
order_id=order.id, # the same order again returns its open payment
amount=order.total,
token=request.form["token"],
)
except payitgo.PayitgoError as e:
logging.error("payitgo %s: %s", e.status, e.message) # log it; do not show it to the customer
return "We could not start this payment. Please try again.", 502
return render_payment(payment)
def render_payment(p):
qr = segno.make(p.qr_payload).svg_data_uri(scale=5)
return render_template_string(PAY, p=p, qr=qr, networks=NETWORKS)
A payment keeps its coin while it is open: if the customer goes back and picks
another coin, payments.create for the same order returns the first payment
unchanged. To let the customer choose on your page after the payment
exists, create it without token and set the coin with select_token:
payment = client.payments.create(order_id=order.id, amount=order.total)
# render payment.token_options (each with token, chain, minimum, amount_due, fee_note)…
# …and when the customer picks one:
chosen = client.payments.select_token(payment.id, picked_token)
html = render_payment(chosen)
To follow the payment live on the page, connect the page's script to the
socket's default namespace (/) and subscribe with payment.checkout_token
(with an acknowledgement): every payment:update then carries the whole
payment (follow it live). No polling.
Fulfil the order from the webhook, never from the page.
A webhook (IPN) handler with Flask
Read the raw body, verify it, handle each event once, and answer 2xx within
10 seconds (answering and retries):
import os
import payitgo
from flask import Flask, request
client = payitgo.Client(
os.environ["PAYITGO_KEY"],
webhook_secret=os.environ["PAYITGO_WEBHOOK_SECRET"], # the signing secret of the key's mode
)
app = Flask(__name__)
@app.post("/payitgo/ipn")
def ipn():
try:
event = client.webhooks.construct_event(
request.get_data(), # the raw bytes, before any JSON parsing
request.headers.get("X-Webhook-Signature"),
)
except payitgo.SignatureVerificationError:
return "", 400 # not from payitgo, changed, or too old
if is_processed(event.id):
return "", 200 # a retry or redelivery
if event.livemode == client.is_live(): # ignore the other mode's events (asks payitgo once)
if event.type == "payment.confirmed": # final: fulfil
mark_order_paid(event.data.order_id, event.data.id) # idempotent
elif event.type == "payment.expired": # nothing arrived in time
release_order(event.data.order_id)
mark_processed(event.id)
return "", 200
is_processed, mark_processed, mark_order_paid and release_order are
your own code: store processed event ids in a table with a unique key, and make
fulfilment safe to run twice. If your code raises, Flask answers 500 and
payitgo retries the notification. More in
handle events safely.
The same handler in FastAPI. The client is synchronous, so the route is a plain
def (FastAPI runs it in a worker thread); construct_event makes no
request, but your own database calls might block:
from fastapi import Depends, FastAPI, Request, Response
app = FastAPI() # client is made as in the Flask example
async def raw_body(request: Request) -> bytes:
return await request.body() # the raw bytes, before any JSON parsing
@app.post("/payitgo/ipn")
def ipn(request: Request, body: bytes = Depends(raw_body)):
try:
event = client.webhooks.construct_event(body, request.headers.get("X-Webhook-Signature"))
except payitgo.SignatureVerificationError:
return Response(status_code=400)
if not is_processed(event.id):
if event.livemode == client.is_live() and event.type == "payment.confirmed":
mark_order_paid(event.data.order_id, event.data.id)
mark_processed(event.id)
return Response(status_code=200)
In an async def route, call the client's API methods with
await asyncio.to_thread(client.payments.retrieve, payment_id) so they do not
block the event loop.
Paying your clients' withdrawals
A platform whose clients withdraw their balance: each withdrawal request becomes a payout request as it comes in, the list is sent on your schedule (or by auto-send), and the webhook says when each payment is on chain. Flask, with the client made as in the handler above:
@app.post("/withdrawals")
def withdraw():
w = create_withdrawal(current_user(), request.form) # your code: holds the client's balance
try:
item = client.payouts.request(
asset=w.asset, # "USDT_TRC20"
address=w.address,
amount=w.amount, # a str or a Decimal
reference=w.id, # a retry returns the same payment, never a second
name=w.client_name,
)
except payitgo.PayitgoError as e:
logging.error("payitgo %s: %s", e.status, e.message)
return "We could not take this withdrawal. Please try again.", 502
if item.status == "invalid":
release_withdrawal(w.id) # give the balance back
return item.errors[0].message, 400
return {"fee": item.fee, "you_receive": item.send_amount}
# Every hour (or let auto-send in your payout settings do it):
def send_withdrawals():
try:
batch = client.payouts.send()
except payitgo.PayitgoError as e:
if e.status == 400: # nothing valid waiting
return
raise
if batch.status == "awaiting_funds" and batch.waiting.reason == "funds":
alert_finance(batch.waiting.note) # what to top up, and where
# In the webhook handler:
if event.type == "payout_item.sent":
mark_withdrawal_paid(event.data.get("reference"), event.data.tx_id)
elif event.type in ("payout_item.failed", "payout_item.canceled"):
# Never sent: its money stays in your wallet, and its reference is given back.
release_withdrawal(event.data.get("reference") or event.data.get("released_reference"))
Events can arrive more than once and out of order, and your system may miss some while it is down: Staying in sync says how to handle that.
Test mode
Build everything with your test key: the same calls, simulated payments instead of coins, and the test webhook with its own secret (Test mode).
client = payitgo.Client(os.environ["PAYITGO_TEST_KEY"]) # your test key
print(client.is_live()) # False
# Point the TEST webhook at your development server and read its secret.
hook = client.webhooks.set("https://dev.yourdomain.com/payitgo/ipn")
print(hook.secret) # test mode's signing secret: your dev PAYITGO_WEBHOOK_SECRET
# A signed ping arrives within seconds.
client.webhooks.test()
# A test payment that pays itself: payment.detecting, then payment.confirmed,
# arrive at the test webhook within half a minute.
payment = client.payments.create(order_id="TEST-1", amount=10, token="USDT_TRC20", simulate="confirmed")
print(payment.livemode, payment.simulation.state) # False running
# Another outcome on a payment you already have:
client.payments.simulate("TEST-2", "underpaid")
# Payouts from the test payout wallet, on paper (a key with payouts on):
client.payout_wallets.simulate_top_up("USDT_TRC20", "1000")
client.payouts.request("USDT_TRC20", "TR7mNkucnhLZoJQLLJ6DR88jpLQufWxUJi", "25", "test-withdrawal-1")
batch = client.payouts.send()
print(batch.status) # processing (without approvals): payout_item.sent follows within seconds
Never send real coins to a test address: nothing watches it (why).
Check your verification against the example in
the recipe (tolerance 0, because the example is
old):
body = b'{"created_at":"2026-10-10T09:12:44.512837Z","data":{"message":"pong"},"id":"5c0e1f9a2b7d4e3c8a6f1b2d","livemode":false,"type":"ping"}'
event = payitgo.Webhook.construct_event(
body,
"t=1791623565,v1=1af0ba31872e3152c422edaf9442c9f0eb4ebd202beebafbaaba14f77336194b",
"a3858862701d1ce11ab06cb5dd9bb941d4849283f81fc0c3f0db0d99a2b82d48",
tolerance=0,
)
print(event.type) # ping
To test your handler without the network, sign a body yourself:
import hashlib, hmac, time
def sign(body: bytes, secret: str, t: int = None) -> str:
t = int(time.time()) if t is None else t
v1 = hmac.new(secret.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest()
return f"t={t},v1={v1}"
# Flask: app.test_client().post("/payitgo/ipn", data=body, headers={"X-Webhook-Signature": sign(body, secret)})
Going live: put the live key and the live webhook secret in your
production environment, set the live webhook URL with the live key, and keep
the event.livemode check in your handler (going live).