PonponPay
Iniciante12 min de leitura

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-sdk

Initialize 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

MethodReturnsDescription
getPaymentMethods()PaymentMethod[]Get available currency and network combinations for the current merchant.
createOrder(array $params)OrderCreate a checkout order and return payment URL, address, and trade ID.
getOrderByTradeId(string $tradeId)OrderQuery an order by PonponPay trade ID.
getOrderByMchOrderId(string $mchOrderId)OrderQuery an order by your own merchant order ID.
getMerchantDetail()MerchantGet merchant profile details associated with the API key.
webhook()WebhookHandlerCreate 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