Search by

xpayz / xpayz-php

XPAYZLABS

XpayZ API client for PHP: checkout sessions, deposit addresses, payments, payouts and webhook signature checks.

Package info

github.com/XPAYZLABS/xpayz-php

pkg:composer/xpayz/xpayz-php

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.1 2026-12-03 22:52 UTC

This package is auto-updated.

Last update: 2026-12-03 23:18:58 UTC


README

Server-side client for the XpayZ API: checkout sessions, deposit addresses, payments, payouts and webhook signature checks. PHP 7.4 or later with the curl and json extensions. No other dependencies.

Install

composer require xpayz/xpayz-php

Without Composer: download this repository (or the zip from https://www.xpayz.com/docs#sdks) and require 'xpayz-php/autoload.php';.

Version 0.1.1. Docs: https://www.xpayz.com/docs#sdks

Start

$xpayz = new XpayZ\Client(getenv('XPAYZ_API_KEY'));

$session = $xpayz->createCheckoutSession([
    'player_ref' => 'customer-42',
    'asset'      => 'USDT_TRON',
    'method'     => 'address',
    'amount'     => '25.00',
    'order_ref'  => 'order-1001',
], 'order-1001'); // idempotency key: same key = same session, even if you retry after a timeout

// Send $session['id'] and $session['client_token'] to the customer's browser for XpayZ's checkout. Never the API key.

Calls

createCheckoutSession, getCheckoutSession, cancelCheckoutSession, createAddress, registry, getPayment, listPayments, allPayments (generator over every page), listPaymentExceptions, serviceCredit, createWebhookEndpoint, rotateWebhookSecret, emergencyStop, createPayout, getPayout, createPayoutBatch.

Every call returns the decoded JSON as an array. Amounts are decimal strings ('25.00'), never floats.

Webhooks

try {
    $event = XpayZ\Webhook::verify(
        getenv('XPAYZ_WEBHOOK_SECRET'),          // during a rotation: [$new, $old]
        $_SERVER['HTTP_XPAYZ_SIGNATURE'] ?? null,
        file_get_contents('php://input')           // the raw body, exactly as received
    );
} catch (XpayZ\SignatureError $e) {
    http_response_code(400);
    exit;
}
// Deliveries can repeat or arrive out of order: use $event['id'] and $event['state_version'].
// For money, read the session or payment back from the API before you act.
http_response_code(200);

Deliveries older than 5 minutes are refused (replay protection).

Errors and retries

Failures throw XpayZ\ApiError with errorCode, status, detail and requestId. Network trouble, 429 and 5xx are retried twice with the same idempotency key. TLS is verified, redirects are never followed, and plain http:// is refused except on localhost.

Tests

php tests/run.php                                                       # offline checks
XPAYZ_BASE=http://127.0.0.1:3291 XPAYZ_KEY=xpz_test_… php tests/run.php  # also against a running XpayZ test backend