Anfänger12 Min. Lesezeit
PHP SDK
Use the official PonponPay PHP SDK to create orders, query status, and verify webhook callbacks in Laravel, WordPress, WHMCS, or any custom PHP application.
If you need raw HTTP endpoints instead of the SDK wrapper, see the API Key guide.
Installation
composer require ponponpay/php-sdkInitialize the client
use PonponPay\PonponPay;
$ponponpay = new PonponPay('your-api-key', [
'api_url' => 'https://api.ponponpay.com',
'timeout' => 30,
]);Create an order
$order = $ponponpay->createOrder([
'mch_order_id' => 'ORDER_' . time(),
'currency' => 'USDT',
'network' => 'tron',
'amount' => 10.00,
'notify_url' => 'https://your-site.com/webhook.php',
'redirect_url' => 'https://your-site.com/success',
]);
echo $order->tradeId;
echo $order->paymentUrl;
echo $order->address;Query an order
$order = $ponponpay->getOrderByTradeId('T20240101120000123456');
echo $order->status;
echo $order->txHash;Verify webhook callbacks
The SDK includes HMAC-SHA256 verification with timestamp window checks and nonce-based replay protection. For the full security model, also review Webhook Security.
use PonponPay\PonponPay;
use PonponPay\WebhookHandler;
use PonponPay\Exception\SignatureException;
$ponponpay = new PonponPay('your-api-key');
try {
$data = $ponponpay->webhook()->handle();
$status = WebhookHandler::resolveStatus($data);
if ($status === 'paid') {
// update your business order here
}
http_response_code(200);
echo 'OK';
} catch (SignatureException $e) {
http_response_code($e->getHttpStatus());
echo $e->getMessage();
}Available SDK methods
| Method | Returns | Description |
|---|---|---|
getPaymentMethods() | PaymentMethod[] | Get available currency and network combinations for the current merchant. |
createOrder(array $params) | Order | Create a checkout order and return payment URL, address, and trade ID. |
getOrderByTradeId(string $tradeId) | Order | Query an order by PonponPay trade ID. |
getOrderByMchOrderId(string $mchOrderId) | Order | Query an order by your own merchant order ID. |
getMerchantDetail() | Merchant | Get merchant profile details associated with the API key. |
webhook() | WebhookHandler | Create a webhook verifier that reuses the same API key. |
Debug and local testing
$ponponpay = new PonponPay('your-api-key', [
'debug' => true,
'debug_log_file' => '/tmp/ponponpay-debug.log',
]);The SDK repository also includes ready-to-run examples such as examples/create_order.php, examples/webhook.php, and a browser demo in demo-web/.
Repository
GitHub: useponponpay/php-sdk