PHP code example of dv-net / dv-net-php-client

1. Go to this page and download the library: Download dv-net/dv-net-php-client 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/ */

    

dv-net / dv-net-php-client example snippets


// Create HTTP client (you can use the built-in SimpleHttpClient or your own implementation)
$httpClient = new SimpleHttpClient();

// Initialize the merchant client with your API host
$client = new MerchantClient(
    httpClient: $httpClient,
    host: 'https://api.example.com' // Your DV Net API host
);

// Alternatively, you can pass the host in each request:
$client = new MerchantClient(
    httpClient: $psrHttpClient,
    xApiKey: 'your-api-key',
    host: 'https://api.example.com'
);

$merchantUtilsManager = new MerchantUtilsManager();
$isValid = $merchantUtilsManager->checkSign(
    clientSignature: 'received-signature-hash',
    clientKey: 'your-client-key',
    requestBody: ['data' => 'request-payload']
);
// Returns boolean indicating if the signature is valid

$client = new MerchantClient($httpClient, $host);
$response = $client->getExchangeBalances(
    xApiKey: 'your-api-key'
);
// Returns TotalExchangeBalanceResponse object with total USD value and individual currency balances

$response = $client->getExternalWallet(
    xApiKey: 'your-api-key',
    email: '[email protected]',
    ip: '127.0.0.1',
    storeExternalId: 'store-123',
    amount: '100.00',
    currency: 'USD'
);
// Returns ExternalAddressesResponse object with wallet details and payment URL

$balances = $client->getProcessingWalletsBalances(
    xApiKey: 'your-api-key'
);
// Returns ProcessingWalletBalancesResponse object with detailed balance information

$currencies = $client->getStoreCurrencies(
    xApiKey: 'your-api-key'
);
// Returns CurrenciesResponse object with detailed currency information

$rates = $client->getStoreCurrenciesRates(
    xApiKey: 'your-api-key'
);
// Returns CurrenciesRatesResponse with rate, originalRate and source for each currency

$status = $client->getWithdrawalProcessingStatus(
    xApiKey: 'your-api-key',
    withdrawalId: 'withdrawal-123'
);
// Returns ProcessingWithdrawal object with detailed withdrawal status

$withdrawal = $client->initializeTransfer(
    xApiKey: 'your-api-key',
    addressTo: '0x123...',
    currencyId: 'ETH',
    amount: '1.5'
);
// Returns WithdrawalResponse object with transfer details

$mapper = new WebhookMapper();
$webhook = $mapper->mapWebhook($rawWebhookData);
// Returns either ConfirmedWebhook or UnconfirmedWebhook object