Skip to content

Commit f65e9b7

Browse files
author
Yury Stryker
committed
Public release
Public release
1 parent 5696adb commit f65e9b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2617
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
.php-cs-fixer.cache
3+
.idea

.php-cs-fixer.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
6+
7+
$finder = Finder::create()
8+
->in(__DIR__)
9+
->exclude(['vendor', 'bootstrap', 'storage'])
10+
->name('*.php')
11+
->notName('*.blade.php');
12+
13+
$config = new Config();
14+
15+
return $config
16+
->setFinder($finder)
17+
->setRiskyAllowed(true)
18+
->setRules([
19+
'@PSR12' => true,
20+
'binary_operator_spaces' => [
21+
'default' => 'single_space',
22+
'operators' => [
23+
'=>' => 'align_single_space_minimal',
24+
'=' => 'align_single_space_minimal',
25+
],
26+
],
27+
'blank_line_before_statement' => ['statements' => ['return']],
28+
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments']],
29+
'method_argument_space' => [
30+
'on_multiline' => 'ensure_fully_multiline',
31+
'keep_multiple_spaces_after_comma' => false,
32+
'after_heredoc' => false,
33+
],
34+
]);

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.9.0] - 2025-05-20
9+
10+
- Public release
11+
-

README.md

Lines changed: 138 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,138 @@
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+
```

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "dv-net/dv-net-php-client",
3+
"description": "A convenient way to integrate DV.net to your platform",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"DvNet\\DvNetClient\\": "src/"
9+
}
10+
},
11+
"require": {
12+
"php": "^8.1",
13+
"psr/http-client": "^1.0"
14+
},
15+
"require-dev": {
16+
"friendsofphp/php-cs-fixer": "^3.68",
17+
"phpstan/phpstan": "^2.1",
18+
"phpunit/phpunit": "^11.5",
19+
"phpstan/phpstan-strict-rules": "^2.0",
20+
"spaze/phpstan-disallowed-calls": "^4.4"
21+
}
22+
}

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
includes:
2+
- vendor/phpstan/phpstan-strict-rules/rules.neon
3+
- vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
4+
- vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon
5+
- vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon
6+
- vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon
7+
- vendor/spaze/phpstan-disallowed-calls/extension.neon
8+
9+
parameters:
10+
level: 8
11+
paths:
12+
- src
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DvNet\DvNetClient\Dto\MerchantClient\Dto;
6+
7+
class AccountDto
8+
{
9+
public function __construct(
10+
public string $balance,
11+
public string $balanceUsd,
12+
public int $count,
13+
public int $countWithBalance,
14+
public CurrencyShortDto $currency
15+
) {
16+
}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DvNet\DvNetClient\Dto\MerchantClient\Dto;
6+
7+
use DateTimeImmutable;
8+
9+
class AddressDto
10+
{
11+
public function __construct(
12+
public readonly string $id,
13+
public readonly string $walletId,
14+
public readonly string $userId,
15+
public readonly string $currencyId,
16+
public readonly string $blockchain,
17+
public readonly string $address,
18+
public readonly bool $dirty,
19+
) {
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DvNet\DvNetClient\Dto\MerchantClient\Dto;
6+
7+
class AssetDto
8+
{
9+
public function __construct(
10+
public readonly string $identity,
11+
public readonly string $amount,
12+
public readonly string $amountUsd,
13+
) {
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DvNet\DvNetClient\Dto\MerchantClient\Dto;
6+
7+
class BalanceDto
8+
{
9+
public function __construct(
10+
public readonly string $nativeToken,
11+
public readonly string $nativeTokenUsd,
12+
) {
13+
}
14+
}

0 commit comments

Comments
 (0)