PHP code example of pago-sh / sdk

1. Go to this page and download the library: Download pago-sh/sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pago-sh / sdk example snippets




 = Pago\Client::create('pago_pat_...');

$order = $pago->orders->get('018f...');

echo $order->id;

$pago = Pago\Client::v2026_04(
    accessToken: 'pago_pat_...',
    baseUrl: 'https://sandbox-api.pago.sh',
);

$pago = Pago\Client::create(
    accessToken: 'pago_pat_...',
    httpClient: new GuzzleHttp\Client(['timeout' => 10]),
);

foreach ($pago->orders->listPaginated(organizationId: $organizationId) as $order) {
    echo $order->id, PHP_EOL;
}

use Pago\Exception\PagoApiException;

try {
    $order = $pago->orders->get($id);
} catch (PagoApiException $exception) {
    echo $exception->statusCode;
}

use Pago\V2026_04\Webhooks;

$payload = Webhooks::validateEvent(
    body: file_get_contents('php://input'),
    headers: getallheaders(),
    secret: getenv('WEBHOOK_SECRET'),
);

echo $payload->type;