|
1 |
| -# dv-net-php-client |
2 |
| -PHP client for dv.net merchant. Documentation https://docs.dv.net |
| 1 | +# DV Net Client |
| 2 | + |
| 3 | +A PHP client for DV Net API integration. |
| 4 | + |
| 5 | +# Extended documentation |
| 6 | + |
| 7 | +You can find extended documentation at https://docs.dv.net/ |
| 8 | + |
| 9 | +## Installation |
| 10 | +```bash |
| 11 | +composer require dv-net/dv-net-php-client |
| 12 | +``` |
| 13 | + |
| 14 | +## Setup |
| 15 | +Initialize the client with your API configuration: |
| 16 | + |
| 17 | +```php |
| 18 | +// Create HTTP client (you can use the built-in SimpleHttpClient or your own implementation) |
| 19 | +$httpClient = new SimpleHttpClient(); |
| 20 | + |
| 21 | +// Initialize the merchant client with your API host |
| 22 | +$client = new MerchantClient( |
| 23 | + httpClient: $httpClient, |
| 24 | + host: 'https://api.example.com' // Your DV Net API host |
| 25 | +); |
| 26 | + |
| 27 | +// Alternatively, you can pass the host in each request: |
| 28 | +$client = new MerchantClient( |
| 29 | + httpClient: $psrHttpClient, |
| 30 | + xApiKey: 'your-api-key', |
| 31 | + host: 'https://api.example.com' |
| 32 | +); |
| 33 | +``` |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +### Signature Verification |
| 38 | +Verify the authenticity of request signatures: |
| 39 | + |
| 40 | +```php |
| 41 | +$hashManager = new HashManager(); |
| 42 | +$isValid = $hashManager->checkSign( |
| 43 | + clientSignature: 'received-signature-hash', |
| 44 | + clientKey: 'your-client-key', |
| 45 | + requestBody: ['data' => 'request-payload'] |
| 46 | +); |
| 47 | +// Returns boolean indicating if the signature is valid |
| 48 | +``` |
| 49 | + |
| 50 | +### Exchange Balances |
| 51 | +Get the total exchange balances across all currencies: |
| 52 | + |
| 53 | +```php |
| 54 | +$client = new MerchantClient($httpClient, $host); |
| 55 | +$response = $client->getExchangeBalances( |
| 56 | + xApiKey: 'your-api-key' |
| 57 | +); |
| 58 | +// Returns TotalExchangeBalanceResponse object with total USD value and individual currency balances |
| 59 | +``` |
| 60 | + |
| 61 | +### External Wallet |
| 62 | +Create or retrieve an external wallet for a user: |
| 63 | + |
| 64 | +```php |
| 65 | +$response = $client->getExternalWallet( |
| 66 | + xApiKey: 'your-api-key', |
| 67 | + |
| 68 | + ip: '127.0.0.1', |
| 69 | + storeExternalId: 'store-123', |
| 70 | + amount: '100.00', |
| 71 | + currency: 'USD' |
| 72 | +); |
| 73 | +// Returns ExternalAddressesResponse object with wallet details and payment URL |
| 74 | +``` |
| 75 | + |
| 76 | +### Processing Wallets Balances |
| 77 | +Get balances for all processing wallets: |
| 78 | + |
| 79 | +```php |
| 80 | +$balances = $client->getProcessingWalletsBalances( |
| 81 | + xApiKey: 'your-api-key' |
| 82 | +); |
| 83 | +// Returns ProcessingWalletBalancesResponse object with detailed balance information |
| 84 | +``` |
| 85 | + |
| 86 | +### Store Currencies |
| 87 | +Get list of available currencies for the store: |
| 88 | + |
| 89 | +```php |
| 90 | +$currencies = $client->getStoreCurrencies( |
| 91 | + xApiKey: 'your-api-key' |
| 92 | +); |
| 93 | +// Returns CurrenciesResponse object with detailed currency information |
| 94 | +``` |
| 95 | + |
| 96 | +### Store Currency Rate |
| 97 | +Get current exchange rate for a specific currency: |
| 98 | + |
| 99 | +```php |
| 100 | +$rate = $client->getStoreCurrencyRate( |
| 101 | + xApiKey: 'your-api-key', |
| 102 | + currencyId: 'BTC' |
| 103 | +); |
| 104 | +// Returns CurrencyRate object with current rate and source information |
| 105 | +``` |
| 106 | + |
| 107 | +### Withdrawal Processing Status |
| 108 | +Check the status of a withdrawal: |
| 109 | + |
| 110 | +```php |
| 111 | +$status = $client->getWithdrawalProcessingStatus( |
| 112 | + xApiKey: 'your-api-key', |
| 113 | + withdrawalId: 'withdrawal-123' |
| 114 | +); |
| 115 | +// Returns ProcessingWithdrawal object with detailed withdrawal status |
| 116 | +``` |
| 117 | + |
| 118 | +### Initialize Transfer |
| 119 | +Initialize a new withdrawal transfer: |
| 120 | + |
| 121 | +```php |
| 122 | +$withdrawal = $client->initializeTransfer( |
| 123 | + xApiKey: 'your-api-key', |
| 124 | + addressTo: '0x123...', |
| 125 | + currencyId: 'ETH', |
| 126 | + amount: '1.5' |
| 127 | +); |
| 128 | +// Returns WithdrawalResponse object with transfer details |
| 129 | +``` |
| 130 | + |
| 131 | +### Webhook Processing |
| 132 | +Process incoming webhooks: |
| 133 | + |
| 134 | +```php |
| 135 | +$mapper = new WebhookMapper(); |
| 136 | +$webhook = $mapper->mapWebhook($rawWebhookData); |
| 137 | +// Returns either ConfirmedWebhook or UnconfirmedWebhook object |
| 138 | +``` |
0 commit comments