PHP code example of zerokyc / zkp-sdk-php

1. Go to this page and download the library: Download zerokyc/zkp-sdk-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/ */

    

zerokyc / zkp-sdk-php example snippets


use ZeroKYC\Idempotency\IdempotencyKey;
use ZeroKYC\Invoice\CreateInvoiceRequest;
use ZeroKYC\ZeroKYC;

$zkp = new ZeroKYC([
    'api_key'     => getenv('ZEROKYC_API_KEY'), // pk_test_... (sandbox) / pk_live_... (production)
    'environment' => 'sandbox',
]);

$response = $zkp->createInvoice(
    CreateInvoiceRequest::make('19.90', 'USD')
        ->withOrderId('INV-1042')
        ->withDescription('VPS plan: starter'),
    IdempotencyKey::make('myshop', 'invoice', '1042'), // stable per local order
);

header('Location: ' . $response->invoice->checkoutUrl);

use ZeroKYC\Exception\WebhookVerificationException;

try {
    $event = $zkp->verifyWebhook(
        file_get_contents('php://input'),          // exact raw body
        $_SERVER['HTTP_X_ZKP_SIGNATURE'] ?? '',
    );
} catch (WebhookVerificationException $e) {
    http_response_code(400);
    exit;
}

if ($event->isPaymentConfirmed()) {
    // match invoice id + amount + asset against the local order, then activate
}

IdempotencyKey::make('whmcs', 'invoice', (string) $invoiceId);
// zerokyc:whmcs:invoice:1042  (max 120 chars)

$verifier = new WebhookVerifier('whsec_zkp_test_vector_2026');
$event = $verifier->verify(
    '{"id":"evt_test_001","type":"payment.confirmed","invoice_id":"inv_test_001"}',
    't=1788788073,v1=ade537fa13aec79a6d1648bd7f197872066c161676c389243ab5c6b13fea7f52',
    now: 1788788073,
);
bash
composer 
bash
composer config repositories.zkp vcs https://github.com/zerokyc-payments/zkp-sdk-php
composer