PHP library

The payitgo/payitgo-php package wraps the payitgo API for PHP: payments, tokens, your webhook (IPN) and its signature check, the public checkout calls, and payouts to your own clients from your payout wallet. It needs only the curl and json extensions. Use it on your server only: it holds your secret key.

Responses are associative arrays 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.

Method HTTP Returns
$payitgo->payments->create($params) POST /v1/payments Payment
$payitgo->payments->retrieve($id) GET /v1/payments/{id} Payment
$payitgo->payments->list($params) GET /v1/payments Payment list
$payitgo->payments->selectToken($id, $token) POST /v1/payments/{id}/token Payment
$payitgo->payments->simulate($id, $outcome) POST /v1/payments/{id}/simulate Payment
$payitgo->tokens->list($amount, $currency) GET /v1/tokens list of TokenInfo
$payitgo->webhooks->get() GET /v1/webhook Webhook
$payitgo->webhooks->set($url) PUT /v1/webhook Webhook
$payitgo->webhooks->remove() DELETE /v1/webhook Webhook
$payitgo->webhooks->test() POST /v1/webhook/test Delivery
$payitgo->webhooks->constructEvent($payload, $header, $secret, $tolerance) none (local) Event
\Payitgo\Webhook::constructEvent($payload, $header, $secret, $tolerance) none (local, no client) Event
$payitgo->events->list($params) GET /v1/events Event list
$payitgo->checkout->retrieve($checkoutToken) GET /checkout/{checkout_token} Payment
$payitgo->checkout->selectToken($checkoutToken, $token) POST /checkout/{checkout_token}/token Payment
$payitgo->payouts->request($params) POST /v1/payouts PayoutItem
$payitgo->payouts->inbox($params) GET /v1/payouts/inbox Payout inbox
$payitgo->payouts->send($ids) POST /v1/payouts/send PayoutBatch
$payitgo->payouts->cancel($id) DELETE /v1/payouts/{id} PayoutItem
$payitgo->payouts->retrieve($id) GET /v1/payouts/{id} PayoutItem
$payitgo->payouts->retrieveByReference($reference) GET /v1/payouts?reference= PayoutItem
$payitgo->payouts->list($params) GET /v1/payouts Payout list
$payitgo->payouts->quote($params) POST /v1/payout-quotes Payout quote
$payitgo->payoutBatches->retrieve($id) GET /v1/payout-batches/{id} PayoutBatch
$payitgo->payoutWallets->list() GET /v1/payout-wallets list of PayoutWallet
$payitgo->payoutWallets->simulateTopUp($asset, $amount) POST /v1/payout-wallets/{asset}/simulate-top-up list of PayoutWallet
$payitgo->isLive() GET /v1/webhook, the first time only bool

Install

composer require payitgo/payitgo-php
Requirement
PHP 8.1 or later
Extensions curl, json
Autoloading PSR-4, namespace Payitgo\ (Composer's vendor/autoload.php)
Class What it is
Payitgo\Client The client
Payitgo\Payments, Payitgo\Tokens, Payitgo\Webhooks, Payitgo\Events, Payitgo\Checkout Its resources, reached as $payitgo->payments and so on
Payitgo\Payouts, Payitgo\PayoutBatches, Payitgo\PayoutWallets Its payout resources: $payitgo->payouts, $payitgo->payoutBatches, $payitgo->payoutWallets
Payitgo\Webhook constructEvent without a client
Payitgo\Exception\PayitgoException A failed API call
Payitgo\Exception\SignatureVerificationException A notification that failed verification

Quickstart

<?php
require __DIR__ . '/vendor/autoload.php';

$payitgo = new \Payitgo\Client(getenv('PAYITGO_KEY'));

$payment = $payitgo->payments->create([
    'order_id' => 'ORD-1001',
    'amount' => '49.90',
    'token' => 'USDT_TRC20',
]);
echo $payment['crypto_amount'], ' ', $payment['token'], ' to ', $payment['deposit_address'], PHP_EOL;

Then set your webhook URL and fulfil the order when payment.confirmed arrives.

Configuration

new Client

new \Payitgo\Client(string $apiKey, array $options = [])
Parameter Type Required Default Description
$apiKey string yes Your secret key, test or live (Authentication). An empty key throws
$options['base_url'] string 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. null and false (an unset getenv()) use the default; an empty string throws
$options['timeout'] int no 30 Seconds one attempt may take, from connecting to the last byte (CURLOPT_TIMEOUT). A timeout counts as a network error, so it is retried
$options['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
$options['webhook_secret'] string no none Your mode's signing secret. webhooks->constructEvent() uses it when you pass none
$options['webhook_url'] string no none Sent as webhook_url with every payments->create() that does not pass its own

The constructor makes no request. It throws \InvalidArgumentException when:

Message Cause
payitgo: the API key is required $apiKey is empty
payitgo: base_url is empty: leave it out to use https://api.payitgo.co $options['base_url'] is an empty string
$payitgo = new \Payitgo\Client(getenv('PAYITGO_KEY'), [
    'timeout' => 15,
    'max_retries' => 2,
    'webhook_secret' => getenv('PAYITGO_WEBHOOK_SECRET'), // the signing secret of the key's mode
    'webhook_url' => 'https://api.yourdomain.com/payitgo/ipn',  // optional default for payments->create()
]);

Properties

All are public readonly.

Property Type Description
$payitgo->payments Payitgo\Payments Payments
$payitgo->tokens Payitgo\Tokens Tokens
$payitgo->webhooks Payitgo\Webhooks Webhooks
$payitgo->events Payitgo\Events Events: replay the events you missed
$payitgo->checkout Payitgo\Checkout Checkout
$payitgo->payouts Payitgo\Payouts Payouts: payout requests, and any payment by id or reference, or listed
$payitgo->payoutBatches Payitgo\PayoutBatches Payout batches
$payitgo->payoutWallets Payitgo\PayoutWallets Payout wallets

\Payitgo\Client::VERSION is '0.7.1', sent in the User-Agent: payitgo-php/0.7.1 header.

isLive

GET /v1/webhook · API reference

public function isLive(): 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. A PHP script that builds its client on every request asks once per request.

Throws PayitgoException, 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 (!$payitgo->isLive()) {
    echo "test mode: payments are simulated\n";
}

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 option, the PAYITGO_BASE_URL environment variable (getenv), 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 $payitgo->isLive() asks payitgo. Pair each key with the webhook secret of the same mode. See Test mode.

HTTP client

Requests go through the curl extension, with the headers Authorization: Bearer <key>, Accept: application/json, Content-Type: application/json (when there is a body) and User-Agent: payitgo-php/0.7.1. There is no option to pass your own HTTP client (Guzzle, PSR-18).

Errors

PayitgoException

Every call that reaches the API throws \Payitgo\Exception\PayitgoException (a \RuntimeException) when the request fails.

class PayitgoException extends \RuntimeException
{
    public readonly int $status;
}
Member Type Description
$e->status int The HTTP status, or 0 when no answer came (network error or timeout, after the retries). $e->getCode() is the same
$e->getMessage() string The API's error message, such as minimum payment in USDT_TRC20 is $6.44 right now (network fees). HTTP <status> when the answer had no message. payitgo: request failed: <curl error> for a network error

Branch on status; log the 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 a key without payouts making a payout No
404 No such payment, payout or 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
use Payitgo\Exception\PayitgoException;

try {
    $payitgo->payments->create(['order_id' => 'ORD-1', 'amount' => 1, 'token' => 'BTC']);
} catch (PayitgoException $e) {
    if ($e->status !== 400) {
        throw $e;
    }
    error_log('payitgo refused: ' . $e->getMessage()); // e.g. an amount under the coin's minimum
}

A request whose parameters cannot be encoded as JSON (a string that is not valid UTF-8, for example) throws \JsonException before anything is sent.

SignatureVerificationException

constructEvent() throws \Payitgo\Exception\SignatureVerificationException (a \RuntimeException) when a notification cannot be trusted. Answer 400. getMessage() 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
timestamp outside the tolerance t is not a number, or is further than the tolerance (5 minutes) from your clock
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 throws \JsonException; 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 throws a PayitgoException 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->selectToken(), checkout->selectToken() Returns the payment unchanged: choosing the coin it has already changes nothing
payments->simulate() If the first attempt went through, the repeat throws 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, with nothing added. Without a reference, a second request is kept: always send one
payouts->send() If the first attempt went through, the repeat throws 400 (no valid payout request to send), or sends the requests that arrived meanwhile; with $ids, 400: read inbox()
payouts->cancel() Returns the payment, canceled, as it is: nothing changes the second time
payoutWallets->simulateTopUp() Tops the test wallet up once more
payouts->quote() and reads Change nothing

Payments

payments->create

POST /v1/payments · API reference

public function create(array $params): array

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 selectToken()) chooses the coin. While the order has an open payment, creating it again returns that payment.

Key of $params Type Required Description
order_id string yes Your id for the order, 1 to 128 bytes. One open payment per order and mode
amount string, int or float yes The price, in currency, such as '49.90'. Sent as a string; prefer a string to a float
currency string no 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)
token string no The coin, such as 'USDT_TRC20' (from tokens->list()). Leave it out to let the customer choose
tokens list of strings no Without token: the coins to offer, such as ['USDT_TRC20', 'USDT_BEP20']. Default: every coin you accept whose minimum the amount reaches
description string no What the customer pays for, up to 500 bytes
metadata array of string to string no Your own data: up to 20 keys of up to 40 bytes, values of up to 500
customer_email string no The customer's email address
success_url string no http(s) URL the hosted checkout links to once the payment is confirmed
cancel_url string no http(s) URL the hosted checkout links back to if the payment closes unpaid
webhook_url string no https:// URL that gets this payment's notifications instead of your account's webhook URL (per-payment URL). Left out (or null): the client's webhook_url. '': none for this payment, even with a client default
simulate string no Test keys only: the outcome to simulate, one of \Payitgo\Payments::SIMULATION_OUTCOMES. With token it starts at once; without, once the coin is chosen

Every key is sent to the API as it is (the API ignores keys it does not know).

Returns the Payment array: the new one (201) or the order's open one (200); both look the same. Fields: the payment object.

Errors PayitgoException 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 = $payitgo->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 = $payitgo->payments->create(['order_id' => 'ORD-1002', 'amount' => 25]);
foreach ($open['token_options'] ?? [] as $option) {
    echo $option['token'], ' ', $option['minimum'], ' ', $option['amount_due'] ?? '', PHP_EOL;
}

// This payment's notifications go to its own URL:
$payitgo->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 = $payitgo->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

public function retrieve(string $id): array
Parameter Type Required Description
$id string 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 array.

Errors PayitgoException 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.

$byId = $payitgo->payments->retrieve('8f3a2c1e9b7d4a6f05e1c2d3');
$byOrder = $payitgo->payments->retrieve('ORD-1001'); // the order's open payment
if ($byId['status'] === 'confirmed') {
    echo 'paid at ', $byId['confirmed_at'], PHP_EOL;
}

payments->list

GET /v1/payments · API reference

public function list(array $params = []): array

Payments of the key's mode, newest first.

Key of $params Type Required Default Description
status string no all Only payments in this status, such as 'confirmed'
chain string no all Only payments on this network, such as 'tron'
token string no all Only payments in this coin, such as 'USDT_TRC20'
store_id string no all Only payments of this store (ignored for a storefront key)
limit int no 50 Page size, 1 to 200 (0 or less: 50; over 200: 200)
offset int no 0 How many to skip

Keys whose value is null or '' are left out of the query; the others are sent as they are.

Returns a Payment list array: 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 = [];
for ($offset = 0; ; $offset += $page['limit']) {
    $page = $payitgo->payments->list(['status' => 'confirmed', 'limit' => 100, 'offset' => $offset]);
    array_push($confirmed, ...$page['payments']);
    if ($offset + $page['limit'] >= $page['total']) {
        break;
    }
}

payments->selectToken

POST /v1/payments/{id}/token · API reference

public function selectToken(string $id, string $token): array

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
$id string yes The payment's id or your order_id
$token string 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 PayitgoException:

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 = $payitgo->payments->create(['order_id' => 'ORD-1002', 'amount' => 25]);
// …your page lists $payment['token_options'], the customer picks one…
$chosen = $payitgo->payments->selectToken($payment['id'], 'USDT_BEP20');
echo $chosen['crypto_amount'], ' ', $chosen['token'], ' to ', $chosen['deposit_address'], PHP_EOL;

payments->simulate

POST /v1/payments/{id}/simulate · API reference

public function simulate(string $id, string $outcome): array

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
$id string yes The payment's id or your order_id
$outcome string yes One of \Payitgo\Payments::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 PayitgoException:

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 = $payitgo->payments->simulate('ORD-1002', 'partially_paid');
echo $payment['simulation']['outcome'], ' ', $payment['simulation']['state'], PHP_EOL; // partially_paid running
// once it is done, pay the rest:
$payitgo->payments->simulate('ORD-1002', 'confirmed');

Tokens

tokens->list

GET /v1/tokens · API reference

public function list(string|int|float|null $amount = null, ?string $currency = null): array

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 an 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 string, int, float or null no The order's amount, in $currency, such as '49.90'
$currency string or null no The ISO 4217 code the amount and every figure are in, such as 'EUR' (any case). Default USD

Returns a list of TokenInfo arrays (the library unwraps the API's {"currency": "USD", "tokens": […]}).

Errors PayitgoException 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.

foreach ($payitgo->tokens->list('49.90') as $t) {
    printf("%s on %s: pay $%s, %s\n", $t['token'], $t['chain'], $t['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.

\Payitgo\Webhooks::EVENTS lists the event types; events->list() replays the events themselves.

webhooks->get

GET /v1/webhook · API reference

public function get(): array

Returns the Webhook array: url (null when none is set) and secret, the signing secret to give the client as webhook_secret. It always succeeds for a valid key.

$webhook = $payitgo->webhooks->get();
echo $webhook['url'] ?? '(none)', ' ', $webhook['secret'], PHP_EOL;

webhooks->set

PUT /v1/webhook · API reference

public function set(string $url): array
Parameter Type Required Description
$url string 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 PayitgoException 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.

$payitgo->webhooks->set('https://api.yourdomain.com/payitgo/ipn');

webhooks->remove

DELETE /v1/webhook · API reference

public function remove(): array

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' => null.

Errors 403 for a storefront key, 500 (could not remove the webhook), and the common statuses.

webhooks->test

POST /v1/webhook/test · API reference

public function test(): array

Queues a signed ping notification to the mode's URL; it arrives within about 5 seconds.

Returns the Delivery array, with 'status' => 'pending'.

Errors PayitgoException 400 (no webhook url is set for this mode: set one first), 500 (could not queue the test), and the common statuses.

$delivery = $payitgo->webhooks->test();
echo $delivery['id'], ' ', $delivery['event_type'], ' ', $delivery['url'], PHP_EOL; // 6710c3a1f2b4e5d6a7b8c9d0 ping https://…

webhooks->constructEvent

No request · how verification works

public function constructEvent(
    string $payload,
    ?string $signatureHeader,
    ?string $secret = null,
    int $tolerance = \Payitgo\Webhook::DEFAULT_TOLERANCE, // 300
): array

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 (hash_equals), checks that t is within the tolerance of your clock, and only then decodes the body.

Parameter Type Required Description
$payload string yes The raw request body, exactly as received: file_get_contents('php://input'), or $request->getContent() in Laravel and Symfony. Never json_encode($_POST) or a decoded array (keep the raw body)
$signatureHeader ?string yes The X-Webhook-Signature header: $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? null
$secret ?string 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. Default 300. 0 turns the timestamp check off (only for tests with captured bodies)

Returns the Event array.

Errors SignatureVerificationException. Answer 400.

$event = $payitgo->webhooks->constructEvent(
    file_get_contents('php://input'),
    $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? null,
);
if ($event['type'] === 'payment.confirmed') {
    echo $event['data']['order_id'];
}

Webhook::constructEvent

public static function constructEvent(
    string $payload,
    ?string $signatureHeader,
    string $secret,
    int $tolerance = self::DEFAULT_TOLERANCE, // 300
): array

The same check without a client, for code that has the secret but no API key. $secret is required. \Payitgo\Webhook::DEFAULT_TOLERANCE is 300.

$event = \Payitgo\Webhook::constructEvent($rawBody, $signatureHeader, getenv('PAYITGO_WEBHOOK_SECRET'));

Errors SignatureVerificationException, except the "no webhook secret" one.

Events

Every event of the key's mode is kept, sent or not, and can be read again exactly as its notification carried it (Replay missed events): after an outage, read from the last event you handled and handle the rest as you handle notifications.

events->list

GET /v1/events · any key of the account, read-only ones too · API reference

public function list(array $params = []): array

The mode's events, oldest first. A test ping is never listed; events of the last few seconds are left for the next read, so reading on never skips one.

Key of $params Type Required Default Description
type string or list of strings no all Event types: exact ('payout_item.sent') or a family ('payout_item.*'), such as ['payment.*', 'payout_item.*'] (a list is sent comma-separated)
after string no none An event's id: the events after it. Keep the last one you handled
created_after \DateTimeInterface or string no none The events created after this time. A \DateTimeInterface is sent as RFC 3339 in UTC; a string is sent as it is (RFC 3339). Ignored with after
limit int no 100 Page size, 1 to 200

Keys whose value is null or '' are left out of the query.

Returns an Event list array: events, each an Event as constructEvent() returns it (same id, so the ones you handled already are skipped by your usual check), and has_more. While has_more is true, call again with after set to the last event's id. A key that cannot make payouts gets claim links without their url and pin.

Errors PayitgoException:

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 A storefront key
$after = loadLastEventId();                       // your code: the last event you handled, or null
do {
    $page = $payitgo->events->list(['type' => 'payout_item.*', 'after' => $after, 'limit' => 200]);
    foreach ($page['events'] as $event) {
        handleEvent($event);                      // the same code as your webhook handler, deduplicating on $event['id']
        $after = $event['id'];
    }
    saveLastEventId($after);
} while ($page['has_more']);

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->selectToken() 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

public function retrieve(string $checkoutToken): array
Parameter Type Required Description
$checkoutToken string yes The payment's checkout_token

Returns a Payment array without your private keys: 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 PayitgoException 404 (payment not found), 0 and 5xx.

checkout->selectToken

POST /checkout/{checkout_token}/token · API reference

public function selectToken(string $checkoutToken, string $token): array
Parameter Type Required Description
$checkoutToken string yes The payment's checkout_token
$token string 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->selectToken(), and 429 (rate limit exceeded) when choices come too fast from one visitor.

$view = $payitgo->checkout->retrieve('b28d4f61e9a03c75d2e8f1a6');
if ($view['token'] === '') {
    $chosen = $payitgo->checkout->selectToken('b28d4f61e9a03c75d2e8f1a6', 'USDT_TRC20');
    echo $chosen['deposit_address'], PHP_EOL;
}

Payouts

Pay your own clients (withdrawals from your platform, payroll, prizes) from your payout wallet: one address per network, yours alone, that you top up (Mass payouts). $payitgo->payouts takes your clients' payout requests one by one and reads any payment. $payitgo->payoutBatches reads your batches, the whole lists you make in the dashboard under Pay people, typed, pasted or uploaded as a CSV file. $payitgo->payoutWallets is the wallet they are paid from. The payout coins, such as USDT_TRC20, USDT_BEP20 or BTC, are listed in Networks and coins.

Any key reads payouts. Making a request or a quote, sending, canceling and a test top-up need a key with payouts turned on in the dashboard (Payout keys); without it they throw a PayitgoException with status 403 (this api key cannot make payouts: turn payouts on for it in the dashboard). The key's mode decides the wallet: a test key works with the test wallet, on paper (Payouts in test mode).

Amounts are decimal strings in the coin ('120', '5.748213'). An amount you pass as an int or a float is sent as a string; prefer a string.

Payout input

Each payment you give payouts->request() and payouts->quote() takes these keys.

Key Type Required Description
asset string yes One of the payout coins, such as USDT_TRC20 (any case). With convert, the coin the recipient receives
address string yes, unless a claim link The recipient's address on the coin's network. A claim link has none
amount string, int or float yes How much of the coin, such as '120'. When the recipient pays the fees, they come out of it. Sent as a string
reference string no, but send one Your id for this payment (a withdrawal's, an employee's), unique in its mode across all your payouts (References and retries)
name, email, note string no Who it is for, and why: kept with it, shown in the dashboard and the results file. Nothing is sent to the email, except a claim link's
tag int no An XRP destination tag (an exchange's account, usually). Refused on any other coin
claim bool no true makes it a claim link: no address, its recipient chooses the coin and the address; with an email, the link is emailed there. An email alone makes no claim link
claim_assets list of strings no A claim link's other coins its recipient may choose, such as ['USDT_BEP20', 'BNB'], paid at the same dollar value (up to 10). Giving them makes it a claim link too
webhook_url string no An https:// URL on a public host: this payment's events go there instead of its batch's webhook_url or your webhook's URL. A payout request keeps it once sent into a batch. The payments of one call may name at most 10 different ones. The client's webhook_url option is not used here

Every key is sent to the API as it is, amount as a string.

payouts->request

POST /v1/payouts · a key with payouts on · API reference

public function request(array $params): array

Takes one of your clients' payout requests as it comes in (Payout requests). payitgo checks it (the coin, the amount, the address down to its checksum, the sanctions list, your limits) and prices it at once (Checking and pricing), and keeps it in your open list (inbox()) until you send() it, or until the list sends itself (auto-send). Who pays the fees is your payout settings' fee_paid_by as it is when the request comes in (and again when the list is sent).

$params is one payment.

Returns the PayoutItem: 'status' => 'ready' with its fee, send_amount (what arrives) and debit (what leaves the wallet), or 'status' => 'invalid' with errors saying why. An invalid request is kept in the list but never sent: cancel it and send a corrected one.

A reference another payment carries returns that payment (the API answers 200 instead of 201; the library returns the payment either way) with nothing added: your system can send the same request again after a timeout.

Errors PayitgoException:

status Message Cause
400 invalid request body A key of the wrong type, such as an amount that is no number
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 A webhook_url that cannot receive events
400 your payout wallet cannot pay this request and those already in your list; send … first, then try again The payout wallet cannot pay it with the requests already waiting; nothing is added
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
409 your list of payout requests is full: send or cancel some first 100,000 requests in the list
503 your payout wallet's balance cannot be checked right now; try again in a minute The payout wallet's balance cannot be read just now; send the request again

A request's own problems never throw: they are its errors.

$item = $payitgo->payouts->request([
    'reference' => 'WD-7781',                 // the withdrawal's id in your system
    'asset' => 'USDT_TRC20',
    'address' => 'TR7mNkucnhLZoJQLLJ6DR88jpLQufWxUJi',
    'amount' => '120',
    'name' => 'Ana Silva',
]);
if ($item['status'] === 'invalid') {
    foreach ($item['errors'] as $issue) {
        echo $issue['code'], ': ', $issue['message'], PHP_EOL; // invalid_address: …
    }
} else {
    echo 'fee ', $item['fee'], ', arrives ', $item['send_amount'], PHP_EOL;
}

payouts->inbox

GET /v1/payouts/inbox · any key · API reference

public function inbox(array $params = []): array

Your open payout requests, and what sending them takes.

Key of $params Type Required Default Description
status string or list of strings no all Only requests in these statuses: 'invalid', or ['ready', 'invalid'] (a list is sent comma-separated)
limit int no 50 Page size, 1 to 200
offset int no 0 How many to skip

Keys whose value is null or '' are left out of the query.

Returns the Payout inbox: inbox, your open list (a PayoutBatch with 'inbox' => true and 'open' => true, whose totals, counts and total_usd are those of its requests); coverage, per coin, what sending its valid requests needs (needed) against what the wallet can spend (spendable), and top_up, what to send to address first ('0' when the wallet covers it); items, the requests in the order they came; and total, limit, offset.

$inbox = $payitgo->payouts->inbox();
echo $inbox['inbox']['counts']['ready'], ' ready, ', $inbox['inbox']['counts']['invalid'], ' invalid', PHP_EOL;
foreach ($inbox['coverage'] as $c) {
    if ($c['top_up'] !== '0') {
        echo "send {$c['top_up']} {$c['ticker']} on {$c['network']} to {$c['address']}", PHP_EOL;
    }
}

payouts->send

POST /v1/payouts/send · a key with payouts on · API reference

public function send(?array $ids = null): array
Parameter Type Required Description
$ids ?list of strings no The requests to send, by id. null (the default): every ready request in the list. An empty list throws \InvalidArgumentException before anything is sent, so a filter that matched nothing never sends them all

Moves the requests (up to 10,000 a call: the rest wait for the next) into a batch of their own ('source' => 'requests', 'inbox' => true), priced again at today's fees, and submits it. It then waits for approvals (pending_approval) when your rules ask, waits for funds (awaiting_funds, its waiting.shortfall saying what to send where), or starts (processing). Invalid requests, and the ones you did not pick, stay in the list. Past 100 requests, the batch comes back validating and is submitted by itself once priced.

Returns the PayoutBatch. If it 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, that batch is canceled, and send() throws the error. A batch priced in the background is canceled the same way, and your team gets a "Payout requests not sent" notification.

Errors PayitgoException:

status Message Cause
400 no payout request to send · no valid payout request to send The list is empty, or has only invalid requests
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 batch_max_usd: the requests are back in the list, that batch canceled
403 this api key cannot make payouts: … As for request()
$batch = $payitgo->payouts->send();
if ($batch['status'] === 'awaiting_funds' && ($batch['waiting']['reason'] ?? '') === 'funds') {
    foreach ($batch['waiting']['shortfall'] as $s) {
        echo "top up {$s['amount']} {$s['asset']} at {$s['address']}", PHP_EOL; // it starts by itself once there
    }
}

payouts->cancel

DELETE /v1/payouts/{id} · a key with payouts on · API reference

public function cancel(string $id): array

Takes a payout request out. One still in your open list is removed: 'cancel_reason' => 'removed', no batch_id any more, and its record stays (retrieve() keeps answering it). Any payment's id works, a batch's row too; it is canceled alone ('cancel_reason' => 'canceled'):

Its reference moves to released_reference, free for a new payment, and a payout_item.canceled webhook follows. Safe to retry: a payment canceled already is returned as it is, with no second event.

Returns the PayoutItem, with 'status' => 'canceled' and its cancel_reason, canceled_by and canceled_at.

Errors 404 (not found) for an unknown id or one of the other mode; 409 (the payment is sent, the payment is failed, …) for a payment that can no longer be canceled.

$item = $payitgo->payouts->cancel($item['id']);
echo $item['cancel_reason'], ' ', $item['released_reference'] ?? '', PHP_EOL; // removed WD-7781

payouts->retrieve

GET /v1/payouts/{id} · any key · API reference

public function retrieve(string $id): array
Parameter Type Required Description
$id string yes The payment's id: a payout request's or a batch row's. Escaped for the URL by the library

Returns the PayoutItem. Errors 404 (not found) for an unknown id or a payment of the other mode.

payouts->retrieveByReference

GET /v1/payouts?reference= · any key · API reference

public function retrieveByReference(string $reference): array

Returns the PayoutItem that carries $reference in the key's mode or, 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 404 (not found) when no payment carries it or gave it back. An empty $reference throws \InvalidArgumentException (payitgo: reference is required) before anything is sent.

$item = $payitgo->payouts->retrieveByReference('WD-7781');
echo $item['status'], ' ', $item['tx_id'] ?? '', PHP_EOL;

payouts->list

GET /v1/payouts · any key · API reference

public function list(array $params = []): array

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.

Key of $params Type Required Default Description
status string or list of strings no all Only payments in these statuses: 'sent', ['sent', 'failed', 'canceled', 'expired'] (a list is sent comma-separated) or 'sent,failed'
updated_since \DateTimeInterface or string no none Payments changed at or after this time. A \DateTimeInterface is sent as RFC 3339 in UTC; a string is sent as it is (RFC 3339)
cursor string no none 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

Keys whose value is null or '' are left out of the query.

Returns a Payout list array: items, has_more, and next_cursor (absent when the page is empty). While has_more is true, call again with cursor set to next_cursor; when it is false, keep the last next_cursor and call with it later to get what changed since.

Errors PayitgoException:

status Message Cause
400 updated_since must be an RFC 3339 time, such as 2026-10-20T09:00:00Z
400 limit must be 1 to 200
400 cursor is not one this API gave
$cursor = loadPayoutCursor();                       // your code: the last next_cursor kept, or null
do {
    $page = $payitgo->payouts->list($cursor !== null
        ? ['cursor' => $cursor, 'limit' => 200]
        : ['updated_since' => new \DateTimeImmutable('-1 day'), 'limit' => 200]);
    foreach ($page['items'] as $item) {
        syncWithdrawal($item);                      // your code: by reference (or released_reference), on status and updated_at
    }
    $cursor = $page['next_cursor'] ?? $cursor;
} while ($page['has_more']);
savePayoutCursor($cursor);

payouts->quote

POST /v1/payout-quotes · a key with payouts on · API reference

public function quote(array $params): array

What up to 100 payments would cost, checked and priced as in a batch, without keeping anything: show a client their fee before they ask.

Key of $params Type Required Description
fee_paid_by string no 'merchant' (fees on top) or 'recipient' (out of each amount). Default: your payout settings
convert string no 'convert' pays every payment in another coin than convert_from from it, converted on its way. 'same_network' pays each from the wallet's own coin. Default: your payout settings
convert_from string no With 'convert', the wallet's coin the payments are paid from, such as 'USDT_TRC20'. Default: your payout settings
items list yes 1 to 100 payments

Returns the Payout quote: quote (livemode, fee_paid_by, convert, convert_from, totals, total_usd, counts) and items, the PayoutItems as they would be, without id, merchant_id, batch_id or times.

Errors 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 as for request().

$quote = $payitgo->payouts->quote(['fee_paid_by' => 'recipient', 'items' => [
    ['asset' => 'USDT_BEP20', 'address' => '0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'amount' => '120'],
]]);
echo 'you receive ', $quote['items'][0]['send_amount'], ' USDT', PHP_EOL; // 119.38816579

A claim link pays a recipient whose address you don't have (Claim links). Give a payment 'claim' => true (or claim_assets) and no address: its recipient opens the link and chooses the coin (asset, or one of claim_assets, at the same dollar value) and the address. With an email, payitgo emails the link once the payment is funded, and a code sent there confirms the claim; without one, you 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. An email alone makes no claim link: a payment without an address is invalid (invalid_address). Payout requests, batch rows and quotes all take them.

$item = $payitgo->payouts->request([
    'reference' => 'prize-2026-10-ana',
    'asset' => 'USDT_TRC20',
    'amount' => '50',
    'name' => 'Ana Silva',
    'email' => '[email protected]',                 // the link is emailed here
    'claim' => true,                              // no address: a claim link
    'claim_assets' => ['USDT_BEP20', 'BNB'],      // optional
]);
$link = $payitgo->payouts->request(['reference' => 'prize-2026-10-ben', 'asset' => 'USDT_TRC20', 'amount' => '50', 'claim' => true]);
echo $link['claim']['url'], PHP_EOL;              // yours to send to the winner

Its life, read from the PayoutItem:

status What it means claim keys to read
ready Priced (at the costliest address it may be paid to), waiting for its batch to be funded email, assets, url
claimable Funded: its money is kept for it until claimed expires_at, emailed (times emailed), last_email_at, extended (times extended)
queued, then sent Claimed: paid like any payment, to the coin and address chosen claimed_at; funded_asset and funded_amount when the recipient chose another coin than asset
expired Never claimed: its money is yours to spend again, its reference released

Events: payout_item.claimed and payout_item.claim_expired, with the payment. A batch counts them in counts['claimable'] and counts['expired']. A claim link with an address, or with an email that is not one (invalid_email), is invalid. Emailing a link again and extending it are done in the dashboard.

Converted payments

To pay recipients in another coin than your wallet holds, give payouts->quote() 'convert' => 'convert' and convert_from (a payout coin, such as 'USDT_TRC20'). Every payment in another coin than convert_from is then paid from it, converted on its way (Conversion). 'same_network' pays each payment from the wallet's own coin. Both default to your payout settings, which payout requests follow. Claim links are not converted.

$quote = $payitgo->payouts->quote([
    'convert' => 'convert',
    'convert_from' => 'USDT_TRC20',
    'items' => [
        ['asset' => 'BNB', 'address' => '0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed', 'amount' => '0.5'],
    ],
]);
$row = $quote['items'][0];
printf("pays %s %s from the wallet; about %s %s arrive\n", $row['debit'], $row['asset'], $row['convert']['estimate'], $row['convert']['ticker']);

A converted PayoutItem has convert: to (the coin the recipient receives), ticker, network, to_amount (what you asked to pay), estimate (about what arrives) and, once sent, amount_out (what arrived). Its asset, amount, fee (converting included) and debit are in the wallet's coin; its address is the recipient's, on convert['to']'s network. A batch with converted payments holds its prices 15 minutes instead of an hour. A coin that cannot be converted to right now makes the payment invalid (conversion_unavailable).

Staying in sync

Each step of a batch and of each payment raises a webhook (Webhooks): data is the PayoutBatch for payout_batch.*, the PayoutItem for payout_item.*, the Withdrawal for payout_wallet.*. A payment's events go to its own webhook_url, else to its batch's webhook_url, else to your webhook's URL; withdrawals and schedules always go to your webhook's URL. A payout request also says when it leaves your list for a batch (payout_item.processing) and when it comes back (payout_item.returned: its batch could not be submitted, or it was no longer valid when priced again; not final).

Every payment, a payout request or a batch row, ends sent, failed, canceled or expired, and each end has one event (payout_item.sent, payout_item.failed, payout_item.canceled, payout_item.claim_expired), whoever acted on it: your system, your team in the dashboard, or payitgo. Events are delivered at least once and keep their id however often they are sent: deduplicate on $event['id']. They can arrive in any order: act on $event['data']['status'] and the latest $event['data']['updated_at'], never on the order they arrive in. To replay the ones you missed, call events->list() with after set to the last event id you handled; to check every payment, read payouts->list() and keep its next_cursor for the next time. A canceled payment says why in cancel_reason (removed, canceled, batch_canceled, rejected with cancel_note, or invalid) and who in canceled_by; it is never brought back: to pay it after all, send a new request (its reference is free again).

Payout batches

A whole list of payments at once (payroll, prizes): checked and priced (quoted, its prices holding for an hour, 15 minutes with converted payments), submitted, approved when your rules ask, then funded from the payout wallet and sent (A batch's life). Make them in the dashboard under Pay people, typed, pasted or uploaded as a CSV file. payouts->send() makes one from your open list of payout requests. A batch of the other mode than the key's is a 404.

payoutBatches->retrieve

GET /v1/payout-batches/{id} · any key · API reference

public function retrieve(string $id): array

Returns the PayoutBatch. Errors 404 (not found).

Payout wallets

payoutWallets->list

GET /v1/payout-wallets · any key · API reference

public function list(): array

Your payout wallet of the key's mode: one address per network (tron, bsc, ethereum, bitcoin, litecoin, dogecoin and xrp), made the first time it is asked for, and what it holds of each payout coin. Send each network's coins to its address.

Returns a list of PayoutWallet arrays (the library unwraps the API's {"wallets": […]}). An asset's needed is what your batches waiting for funds need beyond its spendable: the top-up to send now.

foreach ($payitgo->payoutWallets->list() as $wallet) {
    foreach ($wallet['assets'] as $a) {
        printf("%s %s: %s spendable, %s needed, at %s\n", $wallet['network'], $a['ticker'], $a['spendable'], $a['needed'], $wallet['address']);
    }
}

payoutWallets->simulateTopUp

POST /v1/payout-wallets/{asset}/simulate-top-up · a test key with payouts on · API reference

public function simulateTopUp(string $asset, string|int|float $amount): array
Parameter Type Required Description
$asset string yes A payout coin, such as 'USDT_TRC20' (any case)
$amount string, int or float yes Over 0, up to 10,000,000 of the coin. Sent as a string

Adds $amount to the test wallet's balance, on paper, and funds any test batch waiting for it. Nothing happens on any chain.

Returns the list of PayoutWallet arrays.

Errors 400 (only a test wallet is topped up on paper: use a test key for a live key, payouts in … are not available yet, amount must be over 0 and at most 10000000), 403 as for payouts->request().

Types

Every response is an associative array decoded from the API's JSON (json_decode($body, true)). Amounts are decimal strings ('49.9'): compare and add them with bcmath or a decimal library, not floats. Times are RFC 3339 strings ('2026-10-10T09:15:00.112Z'): new \DateTimeImmutable($value) reads them. Optional keys are absent when they have no value: read them with ??.

The tables list each array's keys and their PHP types; the linked API pages say what each one means.

Payment

The payment object.

Key Type
id, order_id, status string
merchant_id string (absent from the checkout view)
store_id string, optional
token, chain, deposit_address string ('' 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 array, optional (a test payment's simulated outcome): outcome (one of \Payitgo\Payments::SIMULATION_OUTCOMES) and state ('requested', 'running' or 'done')
currency string: 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 string (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 string (decimal), optional: what of amount_due only reaches the exchange's minimum; you receive it
crypto_amount, crypto_received string (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 string (RFC 3339), optional: when the first deposit was seen
rate_locked string (decimal): the coin's price in currency, locked when the coin was chosen
settlement string: 'direct' or 'custodial'
tx_id string, optional
overpaid, paid_late bool, optional
deposits list of Deposit
expires_at, created_at string (RFC 3339)
confirmed_at string, optional
network_fee_note, qr_payload string ('' until the coin is chosen)
checkout_token string (absent from webhooks and the checkout view)
checkout_url string, optional
token_name, token_ticker, token_icon_url, network string, optional (once the coin is chosen)
confirmations, confirmations_required int
explorer_url, detected_at, opened_at string, optional (opened_at absent from the checkout view)
channel string: 'mobile', 'desktop', 'api' or '' ('' in the checkout view)
link_id, customer_id string, optional (customer_id absent from the checkout view)
description, customer_email, success_url, cancel_url, webhook_url string, optional
metadata array of string, optional

Deposit

The deposit object.

Key Type
tx_id, token, chain, status, seen_at string
amount, value string (decimal): in the coin, and in the payment's currency
counted bool
confirmations, confirmations_required int
ticker, icon_url, explorer_url string, 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, from, to, made_at, failed_at, fail_reason string, optional (to: 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

The TokenInfo object.

Key Type
token, chain, name, ticker, network, icon_url, fee_note string
confirmations int
minimum, network_fee string (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 string (decimal), optional: with an amount, when you pass the fees on

Webhook

The webhook object.

Key Type
livemode bool
url ?string (null when none is set)
secret string (signs the mode's notifications)
events list of strings: the event types it is sent, every one but ping
created_at, updated_at string

Delivery

The delivery object.

Key Type
id, merchant_id, url, event_id, event_type, payload, next_attempt_at, created_at string
livemode bool
target string: 'account' or 'payment'
status string: '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 string, optional
history list, optional; each entry has at (string) and, when they apply, url, signed, error, response, note (string), status_code, millis (int)

Event

What constructEvent() returns (the body), and each event of events->list().

Key Type
id string (the same on every retry: deduplicate on it)
type string: one of \Payitgo\Webhooks::EVENTS
livemode bool
created_at string
data array: 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 PayoutSchedule for payout_schedule.run, ['schedule' => PayoutSchedule, 'shortfall' => [['asset' => …, 'network' => …, 'amount' => …, 'address' => …], …]] for payout_schedule.funding_needed, ['message' => 'pong'] for ping

\Payitgo\Webhooks::EVENTS holds 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 (when each is sent).

Event list

What events->list() returns.

Key Type
events list of Event, oldest first
has_more bool

PayoutItem

One payment to a recipient: a payout request or a batch's row (the payment object).

Key Type
id, merchant_id string (absent from a quote's items)
batch_id string, optional: its batch, your open list's id while it is a payout request waiting there. Absent from a quote's items and from a request removed from the list
livemode bool
reference, refused_reference, released_reference string, optional
row int
recipient array: name, email, note, each optional
asset, chain, address, status string. address is '' for a claim link not claimed yet. status: 'validating', 'ready', 'invalid', 'cooling', 'queued', 'sending', 'sent', 'failed', 'canceled', and for a claim link 'claimable' and 'expired'
ticker, icon_url string, optional
tag int, optional
amount, send_amount, fee, debit, usd_rate, amount_usd string (decimal; '0' while validating and when invalid). fee is the whole fee: a converted payment's converting included
errors, warnings list of arrays, each with code, message (string) and, optional, field, hint (string); [] when none
cooling_until, tx_id, explorer_url, fail_reason, sent_at string, optional
fee_credit string (decimal), optional
cancel_reason string, 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; cancel_note says why) or 'invalid' (no longer payable when its batch was submitted or funded; errors say why)
cancel_note string, optional: with 'rejected', the approver's reason
canceled_by, canceled_at string, optional: who canceled it (a team member's id, an API key's id, or 'system': payitgo itself), and when
members array, optional: the email of the team member in canceled_by, by id
webhook_url string, optional: where its events go instead of its batch's webhook_url or your webhook's URL
claim array, optional (a claim link): assets (list of strings), emailed, extended (int); optional email, expires_at, claimed_at, last_email_at, url, pin, funded_asset (string), funded_amount (decimal string), pin_locked (bool). url and pin only for a key with payouts on
convert array, optional (a converted payment): to, ticker, network (string), to_amount, estimate (decimal string); once sent, amount_out (decimal string) and sent_at (string)
created_at, updated_at string (absent from a quote's items)

PayoutBatch

The batch object. Your open list of payout requests (inbox()) is one too, with 'inbox' => true and 'open' => true; a batch of sent requests has 'inbox' => true, 'open' => false.

Key Type
id, merchant_id, name, source, created_by, fee_paid_by, convert, status string. source: 'api', 'dashboard', 'csv', 'requests' or 'schedule'. convert: 'same_network' or 'convert'. status: 'validating', 'quoted', 'pending_approval', 'awaiting_funds', 'processing', 'completed', 'canceled' or 'rejected'
livemode, inbox, open, by_api_key bool
reference, webhook_url, convert_from string, optional (convert_from with 'convert' => 'convert')
waiting array, optional: reason ('funds', 'daily_limit' or 'paused'), note, since (string), and for funds the shortfall, a list of arrays with asset, network, amount (decimal), address
totals list of arrays, one per coin: asset, ticker, icon_url, chain, network (string), items (int), amount, send_amount, fee, debit, debit_usd, saved_usd (decimal string)
counts array of int: total, invalid, ready, cooling, queued, sending, sent, failed, canceled, claimable, expired
total_usd string (decimal)
approvals_needed int
approvals list of arrays with user_id, at
rejection array, optional: by, at, reason
quote_expires_at, submitted_by, submitted_at, funded_at, completed_at, canceled_by, canceled_at string, optional
members array: the emails of the team members it names (created_by, submitted_by, approvals, rejection, canceled_by), by id
created_at, updated_at string

Payout list

What payouts->list() returns.

Key Type
items list of PayoutItem, oldest change first
has_more bool
next_cursor string, optional (absent when items is empty): pass it as cursor to read on

Payout inbox

What payouts->inbox() returns.

Key Type
inbox PayoutBatch: your open list ('inbox' => true, 'open' => true). It is never submitted and never listed among your batches
coverage list of arrays, one per coin of its valid requests: asset, ticker, network, address (string), needed, spendable, top_up (decimal string)
items list of PayoutItem
total, limit, offset int

Payout quote

What payouts->quote() returns.

Key Type
quote array: livemode (bool), fee_paid_by and convert (string), convert_from (string, with 'convert' => 'convert'), totals (as a PayoutBatch's), total_usd (decimal string), counts (as a PayoutBatch's)
items list of PayoutItem, without id, merchant_id, batch_id or times

PayoutWallet

The wallet object.

Key Type
chain, network, address string. chain: the network, such as 'tron' or 'bsc'
livemode bool
explorer_url, error string, optional
assets list of arrays: asset, ticker, icon_url (string), balance, reserved, spendable, needed (decimal string)

Withdrawal

The data of payout_wallet.withdrawn and payout_wallet.withdrawal_failed: your payout wallet's money sent back to one of your payout addresses, from the dashboard (Withdrawals). The library has no calls for withdrawals.

Key Type
id, merchant_id, asset, chain, address_id, address, requested_by, created_at, updated_at string
status string: 'requested', 'sending', 'sent' or 'failed'
livemode bool
amount, fee, send_amount string (decimal)
tag int, optional
tx_id, explorer_url, sent_at string, optional
fail_reason string, optional: why a failed withdrawal failed; its money stays in the wallet
members array: the email of the team member in requested_by, by id

PayoutSchedule

The data of payout_schedule.run, and the schedule of payout_schedule.funding_needed: a summary of a batch made again and again (payroll, a monthly prize), set up in the dashboard (Schedules). It leaves out the schedule's rows (its recipients stay in the dashboard). Each run makes a batch with 'source' => 'schedule'. The library has no calls for schedules.

Key Type
id, name, at, timezone, fee_paid_by string. at: 'HH:MM' in timezone
status string: 'active' or 'paused'
cadence string: 'weekly', 'biweekly' or 'monthly'
livemode, auto_submit bool
weekday, day, remind_days, runs int
totals list of arrays, what its rows pay each run per coin: asset, ticker (string), items (int), amount (decimal string)
next_run_at, last_run_at ?string (null when none)
last_batch_id, last_error string ('' when none)

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). Plain PHP, with chillerlan/php-qrcode for the QR code:

<?php
// pay.php?order=ORD-1001 — composer require payitgo/payitgo-php chillerlan/php-qrcode
require __DIR__ . '/vendor/autoload.php';

use chillerlan\QRCode\QRCode;
use Payitgo\Exception\PayitgoException;

$payitgo = new \Payitgo\Client(getenv('PAYITGO_KEY'));
$order = findOrder($_GET['order'] ?? '');      // your code: ['id' => …, 'total' => '49.90']
$networks = [
    'tron' => 'Tron (TRC-20)', 'ethereum' => 'Ethereum (ERC-20)', 'bsc' => 'BNB Smart Chain (BEP-20)',
    'bitcoin' => 'Bitcoin', 'litecoin' => 'Litecoin', 'dogecoin' => 'Dogecoin', 'xrp' => 'XRP Ledger',
];
$h = fn ($s) => htmlspecialchars((string) $s, ENT_QUOTES);

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    // 1. The coins this order can be paid with, and what each costs the customer.
    echo '<form method="post">';
    foreach ($payitgo->tokens->list($order['total']) as $t) {
        printf('<button name="token" value="%s">%s on %s: $%s</button>',
            $h($t['token']), $h($t['token']), $h($networks[$t['chain']] ?? $t['chain']),
            $h($t['amount_due'] ?? $order['total']));
    }
    echo '</form>';
    exit;
}

// 2. The customer picked one: create the payment in it and show it.
try {
    $p = $payitgo->payments->create([
        'order_id' => $order['id'],                // the same order again returns its open payment
        'amount' => $order['total'],
        'token' => (string) ($_POST['token'] ?? ''),
    ]);
} catch (PayitgoException $e) {
    error_log("payitgo {$e->status}: {$e->getMessage()}"); // log it; do not show it to the customer
    http_response_code(502);
    exit('We could not start this payment. Please try again.');
}

if (!$p['livemode']) {
    echo '<p><b>Test payment:</b> do not send coins to this address.</p>';
}
printf('<p>Send exactly <b>%s %s</b> on <b>%s</b> to</p><p><code>%s</code></p>',
    $h($p['crypto_amount']), $h(explode('_', $p['token'])[0]),
    $h($networks[$p['chain']] ?? $p['chain']), $h($p['deposit_address']));
if (isset($p['destination_tag'])) {
    printf('<p>Destination tag (required): <b>%d</b></p>', $p['destination_tag']);
}
printf('<img src="%s" width="220" height="220" alt="QR code">', (new QRCode())->render($p['qr_payload']));
printf('<p>Pay before <time datetime="%s">%s</time></p>', $h($p['expires_at']),
    $h((new DateTimeImmutable($p['expires_at']))->format('H:i T')));

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 selectToken():

$p = $payitgo->payments->create(['order_id' => $order['id'], 'amount' => $order['total']]);
// render $p['token_options'] (each with token, chain, minimum, amount_due, fee_note)…
// …and when the customer picks one:
$p = $payitgo->payments->selectToken($p['id'], $pickedToken);
// render $p as above

To follow the payment live on the page, connect the page's script to the socket's default namespace (/) and subscribe with $p['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 in plain PHP

Read the raw body, verify it, handle each event once, and answer 2xx within 10 seconds (answering and retries). Here the processed event ids go in a table with the event id as its primary key, in the same transaction as the fulfilment, so a failure rolls both back and payitgo's retry runs it again:

<?php
// ipn.php
require __DIR__ . '/vendor/autoload.php';

use Payitgo\Exception\SignatureVerificationException;

$payitgo = new \Payitgo\Client(getenv('PAYITGO_KEY'), [
    'webhook_secret' => getenv('PAYITGO_WEBHOOK_SECRET'), // the signing secret of the key's mode
]);

try {
    $event = $payitgo->webhooks->constructEvent(
        file_get_contents('php://input'),               // the raw body
        $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? null,
    );
} catch (SignatureVerificationException) {
    http_response_code(400);                            // not from payitgo, changed, or too old
    exit;
}

$db = new PDO(getenv('DATABASE_DSN'), getenv('DATABASE_USER'), getenv('DATABASE_PASSWORD'),
    [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$db->beginTransaction();
// CREATE TABLE payitgo_events (id VARCHAR(64) PRIMARY KEY)
$insert = $db->prepare('INSERT INTO payitgo_events (id) VALUES (?) ON CONFLICT DO NOTHING'); // MySQL: INSERT IGNORE
$insert->execute([$event['id']]);
if ($insert->rowCount() === 1 && $event['livemode'] === $payitgo->isLive()) { // first time, and this mode
    switch ($event['type']) {
        case 'payment.confirmed':                       // final: fulfil
            markOrderPaid($db, $event['data']['order_id'], $event['data']['id']);
            break;
        case 'payment.expired':                         // nothing arrived in time
            releaseOrder($db, $event['data']['order_id']);
            break;
    }
}
$db->commit();
http_response_code(200);

markOrderPaid and releaseOrder are your own code. If anything throws, PHP answers 500, the transaction is rolled back, and payitgo retries the notification. More in handle events safely.

A webhook (IPN) handler in Laravel

Bind the client once, in config/services.php and a service provider:

// config/services.php
'payitgo' => [
    'key' => env('PAYITGO_KEY'),
    'webhook_secret' => env('PAYITGO_WEBHOOK_SECRET'),
],
// app/Providers/AppServiceProvider.php, in register():
$this->app->singleton(\Payitgo\Client::class, fn () => new \Payitgo\Client(config('services.payitgo.key'), [
    'webhook_secret' => config('services.payitgo.webhook_secret'),
]));

The controller reads the raw body with $request->getContent():

<?php
// app/Http/Controllers/PayitgoWebhookController.php
namespace App\Http\Controllers;

use App\Models\Order;                                    // your model
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Payitgo\Client;
use Payitgo\Exception\SignatureVerificationException;

class PayitgoWebhookController extends Controller
{
    public function __invoke(Request $request, Client $payitgo): Response
    {
        try {
            $event = $payitgo->webhooks->constructEvent(
                $request->getContent(),                  // the raw body, never $request->all()
                $request->header('X-Webhook-Signature'),
            );
        } catch (SignatureVerificationException) {
            return response('', 400);
        }

        DB::transaction(function () use ($event, $payitgo) {
            // payitgo_events: a table with the event id as its primary key
            if (DB::table('payitgo_events')->insertOrIgnore(['id' => $event['id']]) === 0) {
                return;                                  // a retry or redelivery
            }
            if ($event['livemode'] !== $payitgo->isLive()) {
                return;                                  // the other mode's event
            }
            match ($event['type']) {
                'payment.confirmed' => Order::markPaid($event['data']['order_id'], $event['data']['id']),
                'payment.expired' => Order::release($event['data']['order_id']),
                default => null,
            };
        });

        return response('', 200);
    }
}

Register the route and exempt it from CSRF protection (payitgo cannot send a CSRF token):

// routes/web.php
Route::post('/payitgo/ipn', \App\Http\Controllers\PayitgoWebhookController::class);

// bootstrap/app.php (Laravel 11 and later)
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: ['payitgo/ipn']);
})

On Laravel 10 and earlier, add 'payitgo/ipn' to $except in app/Http/Middleware/VerifyCsrfToken.php instead. Order::markPaid and Order::release stand for your own code; make them safe to run twice.

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).

$payitgo = new \Payitgo\Client(getenv('PAYITGO_TEST_KEY')); // your test key
var_dump($payitgo->isLive()); // bool(false)

// Point the TEST webhook at your development server and read its secret.
$hook = $payitgo->webhooks->set('https://dev.yourdomain.com/payitgo/ipn');
echo $hook['secret'], PHP_EOL; // test mode's signing secret: your dev PAYITGO_WEBHOOK_SECRET

// A signed ping arrives within seconds.
$payitgo->webhooks->test();

// A test payment that pays itself: payment.detecting, then payment.confirmed,
// arrive at the test webhook within half a minute.
$payment = $payitgo->payments->create([
    'order_id' => 'TEST-1', 'amount' => 10, 'token' => 'USDT_TRC20', 'simulate' => 'confirmed',
]);
var_dump($payment['livemode'], $payment['simulation']['state']); // bool(false) string(7) "running"

// Another outcome on a payment you already have:
$payitgo->payments->simulate('TEST-2', 'underpaid');

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 = '{"created_at":"2026-10-10T09:12:44.512837Z","data":{"message":"pong"},"id":"5c0e1f9a2b7d4e3c8a6f1b2d","livemode":false,"type":"ping"}';
$event = \Payitgo\Webhook::constructEvent(
    $body,
    't=1791623565,v1=1af0ba31872e3152c422edaf9442c9f0eb4ebd202beebafbaaba14f77336194b',
    'a3858862701d1ce11ab06cb5dd9bb941d4849283f81fc0c3f0db0d99a2b82d48',
    0,
);
echo $event['type'], PHP_EOL; // ping

To test your handler without the network, sign a body yourself:

function sign(string $body, string $secret, ?int $t = null): string
{
    $t ??= time();
    return 't=' . $t . ',v1=' . hash_hmac('sha256', $t . '.' . $body, $secret);
}
// POST $body to your handler with the header 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 livemode check in your handler (going live).

Paying your clients' withdrawals

A trading platform or a marketplace takes each withdrawal as a payout request the moment the client asks, with the withdrawal's id as its reference: a retry never pays it twice, and the client sees the fee at once. A cron job sends the list every few minutes (or let the list send itself with auto-send), and the webhook closes each withdrawal.

<?php
// withdraw.php: the client asks for a withdrawal
require __DIR__ . '/vendor/autoload.php';

$payitgo = new \Payitgo\Client(getenv('PAYITGO_KEY'));    // a key with payouts on
$withdrawal = createWithdrawal($user, $_POST['asset'], $_POST['address'], $_POST['amount']); // your code

$item = $payitgo->payouts->request([
    'reference' => $withdrawal['id'],
    'asset' => $withdrawal['asset'],
    'address' => $withdrawal['address'],
    'amount' => $withdrawal['amount'],                      // a decimal string
    'name' => $user['name'],
    'email' => $user['email'],
]);
if ($item['status'] === 'invalid') {
    $payitgo->payouts->cancel($item['id']);                 // out of the list, the reference free again
    rejectWithdrawal($withdrawal['id'], $item['errors'][0]['message']);
    exit;
}
saveFee($withdrawal['id'], $item['fee'], $item['send_amount']);
<?php
// send-payouts.php: every 5 minutes from cron
require __DIR__ . '/vendor/autoload.php';

use Payitgo\Exception\PayitgoException;

$payitgo = new \Payitgo\Client(getenv('PAYITGO_KEY'));
$inbox = $payitgo->payouts->inbox(['status' => 'ready', 'limit' => 1]);
if ($inbox['total'] === 0) {
    exit;
}
foreach ($inbox['coverage'] as $c) {
    if ($c['top_up'] !== '0') {
        alertTreasury("top up {$c['top_up']} {$c['ticker']} on {$c['network']} at {$c['address']}");
    }
}
try {
    $batch = $payitgo->payouts->send();                     // waits for the top-up by itself if it must
} catch (PayitgoException $e) {
    error_log("payitgo {$e->status}: {$e->getMessage()}");
}

In the webhook handler, after verifying the event and recording its id once:

switch ($event['type']) {
    case 'payout_item.sent':                                // on chain
        completeWithdrawal($db, $event['data']['reference'], $event['data']['tx_id']);
        break;
    case 'payout_item.failed':                              // never sent: its money stays in the wallet
    case 'payout_item.canceled':                            // whoever canceled it: cancel_reason says why
    case 'payout_item.claim_expired':                       // a claim link never claimed
        reopenWithdrawal($db, $event['data']['released_reference'] ?? $event['data']['reference'] ?? '');
        break;
    case 'payout_batch.awaiting_funds':                     // waiting.shortfall: what to send where
        alertTreasury($event['data']['waiting']['note'] ?? '');
        break;
}

A payment that failed or was canceled gives its reference back (released_reference), so the same withdrawal can be requested again. After an outage, replay what you missed with events->list() through the same code (Staying in sync).

Payouts in test mode

With a test key everything works on paper: the test payout wallet has its own addresses, a top-up is a call, and payments are sent within seconds with a made-up tx_id (on no chain, with no explorer_url), raising the same webhooks as live (In test mode).

$payitgo = new \Payitgo\Client(getenv('PAYITGO_TEST_KEY')); // with payouts on

$payitgo->payoutWallets->simulateTopUp('USDT_TRC20', '1000');

$payitgo->payouts->request(['reference' => 'TEST-WD-1', 'asset' => 'USDT_TRC20',
    'address' => 'TR7mNkucnhLZoJQLLJ6DR88jpLQufWxUJi', 'amount' => '120']);
$batch = $payitgo->payouts->send();
echo $batch['status'], PHP_EOL;                             // processing (or pending_approval with approvals on)

sleep(10);
$item = $payitgo->payouts->retrieveByReference('TEST-WD-1');
echo $item['status'], ' ', $item['tx_id'] ?? '', PHP_EOL;  // sent 64 hex characters

Recipients' addresses are not read on chain in test mode, so no new_holder, activation or contract_recipient issues appear; the daily limit does not apply.