Ready-made Unitpay integration scenarios. The examples read $_GET/$_SERVER and call
header(), so they must be served over HTTP, not run from the CLI:
composer install # the examples autoload the SDK from vendor/
php -S localhost:8000 -t examples
# then open e.g. http://localhost:8000/paymentInfo.phpSince 3.0 every example loads vendor/autoload.php and uses the Unitpay\ namespace:
new Unitpay\Unitpay(...) as the entry point, then the service objects — payments(),
subscriptions(), payouts(), reference() — and webhook() for inbound verification.
Shared data lives in two include files (not runnable on their own):
- config.php — connection and keys:
domain,projectId,publicId,secretKey, pluslogin/accountSecretKeyfor account-level methods. - order.php — order data:
orderId,orderSum,orderDesc,orderCurrency. Included by payment examples in addition toconfig.php.
Secrets are not stored in code — they are read from the environment (with default placeholders):
export UNITPAY_SECRET_KEY=... # project key
export UNITPAY_LOGIN=... # account login (account-level methods)
export UNITPAY_ACCOUNT_SECRET_KEY=... # account key| File | Scenario |
|---|---|
| paymentForm.php | Unitpay-hosted payment form: form() builds the URL to the payment page; fluent setters (setBackUrl/setCustomerEmail/setCustomerPhone). |
| initPaymentApi.php | Server-to-server initPayment: handling the redirect / invoice / response reply. |
| receipt.php | 54-FZ fiscal receipt: line items via CashItem + setCashItems(), dictionaries from Model\Enum. |
| webhook.php | Webhook handler: signature and IP verification, check/pay/preauth/error responses. |
| paymentInfo.php | Payment info (getPayment). |
| refund.php | Payment refund, full or partial (refundPayment). |
| twoStagePayment.php | Two-stage payment: confirmPayment (capture) / cancelPayment (release). |
| subscriptions.php | Subscriptions: list, info, close. |
| payout.php | Payouts (mass-payment) via SBP + status. |
| accountInfo.php | Reference calls (read-only): balance, commissions, currency rates, BIN, payment methods. |
| offsetAdvance.php | Advance-offset receipt (offsetAdvance) — creates a fiscal receipt for a prepayment. |
By default 127.0.0.1 is not trusted. For local debugging of webhook retries from the same
host only, enable it with an explicit flag (and never in production):
UNITPAY_DEBUG_LOCAL=1 php -S localhost:8000 -t examples