PHP SDK
Official PHP SDK for OxaPay — accept crypto payments, exchanges, and payouts.
Installation
composer require oxapay/php-sdkAfter installing, if you updated autoloaded classes, run:
composer dump-autoload -oQuick start
<?php
require __DIR__ . '/vendor/autoload.php';
use OxaPay\PHP\OxaPayManager;
use OxaPay\PHP\Support\Facades\OxaPay;
// via static method
$oxapay = new OxaPayManager(timeout: 10);
$res = $oxapay->payment("XXXXXX-XXXXXX-XXXXXX-XXXXXX")
->generateInvoice([
'amount' => 10.5,
'currency' => 'USDT'
]);
// via facade
$res = OxaPay::payment("XXXXXX-XXXXXX-XXXXXX-XXXXXX")
->generateInvoice([
'amount' => 10.5,
'currency' => 'USDT'
]);
print_r($res);Handling Webhooks (Payments & Payouts)
<?php
require __DIR__ . '/../vendor/autoload.php';
use OxaPay\PHP\Support\Facades\OxaPay;
use OxaPay\PHP\Exceptions\WebhookSignatureException;
// use for merchant webhook endpoint
try {
$data = OxaPay::webhook(merchantApiKey: "XXXXXX-XXXXXX-XXXXXX-XXXXXX")->getData();
// ...
} catch (WebhookSignatureException $e) {
// ...
}
// use for payout webhook endpoint
try {
$data = OxaPay::webhook(payoutApiKey: "XXXXXX-XXXXXX-XXXXXX-XXXXXX")->getData();
// ...
} catch (WebhookSignatureException $e) {
// ...
}
// Use when your endpoint is used for both webhook merchant and payout
try {
$data = OxaPay::webhook(merchantApiKey: "XXXXXX-XXXXXX-XXXXXX-XXXXXX", payoutApiKey: "XXXXXX-XXXXXX-XXXXXX-XXXXXX")->getData();
// ...
} catch (WebhookSignatureException $e) {
// ...
}
// or you can get data without verify HMAC
$data = OxaPay::webhook()->getData(false);Available methods
🔹payment
generateInvoice– Create invoice & get payment URL. More detailsgenerateWhiteLabel– White-label payment. More detailsgenerateStaticAddress– Create static deposit address. More detailsrevokeStaticAddress– Revoke static address. More detailsstaticAddressList– List static addresses. More detailsinformation– Single payment information. More detailshistory– Payment history list. More detailsacceptedCurrencies– Accepted currencies. More details
🔹account
balance– Account balance. More details
🔹payout
generate– Request payout. More detailsinformation– Single payout information. More detailshistory– Payout history list. More details
🔹exchange
swapRequest– Swap request. More detailsswapHistory– Swap history. More detailsswapPairs– Swap pairs. More detailsswapCalculate– Swap pre-calc. More detailsswapRate– Swap Quote rate. More details
🔹common
prices– Market prices. More detailscurrencies– Supported crypto. More detailsfiats– Supported fiats. More detailsnetworks– Supported networks. More detailsmonitor– System status. More details
🔹webhook
verify– ValidatesHMACheader (sha512 of raw body).getData– ValidatesHMACheader and return webhook data. More details
Exceptions
All SDK exceptions extend OxaPay\PHP\Exceptions\OxaPayException:
ValidationRequestException(HTTP 400)InvalidApiKeyException(HTTP 401)NotFoundException(HTTP 404)RateLimitException(HTTP 429)ServerErrorException(HTTP 500)ServiceUnavailableException(HTTP 503)HttpException(network/unknown)MissingApiKeyException(missing api key)MissingTrackIdException(missing track id)MissingAddressException(missing address)WebhookSignatureException(bad/missing HMAC)WebhookNotReceivedException(webhook request was not received)
Security Notes
Verify webhook HMAC before use input data.
Whitelist OxaPay IPs on your firewall (ask support).
Use HTTPS everywhere.
Store keys in
.env, not code.Rotate keys regularly.
Testing (safe & offline)
This package uses Pest, PHPUnit, and Orchestra Testbench for testing.
Dependencies are already listed under require-dev in composer.json.
Run tests with composer:
composer testRun tests with pest:
vendor/bin/pestCompatibility
PHP +8.x
Security
If you discover a security vulnerability, please email [email protected].
Do not disclose publicly until it has been fixed.
Contributing
Pull requests are welcome. For major changes, open an issue first.
Run coding standards & static analysis before PR:
composer cs-fix
composer phpstan
composer testLicense
Apache-2.0 — see LICENSE.
Changelog
See CHANGELOG.md for version history.
To view the OxaPay package on Packagist:
Last updated