Skip to content

Latest commit

 

History

History

README.md

Examples

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

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

Configuration

Shared data lives in two include files (not runnable on their own):

  • config.php — connection and keys: domain, projectId, publicId, secretKey, plus login/accountSecretKey for account-level methods.
  • order.php — order data: orderId, orderSum, orderDesc, orderCurrency. Included by payment examples in addition to config.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

Scenarios

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.

Webhook handler locally

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