PHP code example of vynex / pay-php
1. Go to this page and download the library: Download vynex/pay-php 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/ */
vynex / pay-php example snippets
use Vynex\Pay\Client;
use Vynex\Pay\Exception\ApiException;
use Vynex\Pay\Webhook;
$vynex = new Client(getenv('VYNEX_API_KEY'), [
'base_url' => 'https://pay.suaempresa.com', // ou env VYNEX_BASE_URL; /api/v1 é acrescentado
'merchant_id' => '00000000-0000-4000-8000-000000000000', // opcional
'max_retries' => 2, 'timeout' => 60,
]);
$customer = $vynex->customers->create(['name' => 'Maria', 'cpf_cnpj' => '12345678909']); // Idempotency-Key automática em POST
foreach ($vynex->charges->listAll(['status' => 'PENDING']) as $charge) { /* paginação automática */ }
try {
$vynex->transfers->create(['value' => 5000, 'pix_address_key' => '[email protected] ', 'pix_address_key_type' => 'EMAIL'], ['idempotency_key' => 'saque-001']);
} catch (ApiException $e) {
echo $e->status, ' ', $e->errorCode, ' ', $e->getMessage(), ' ', $e->requestId;
}
$ok = Webhook::verify($rawBody, $_SERVER['HTTP_X_VYNEX_SIGNATURE'] ?? null, $secret, 300);