Skip to content

Commit d236114

Browse files
authored
Merge pull request #913 from bavix/11.x
[11.x] docs
2 parents ba79e58 + 0877cf8 commit d236114

37 files changed

+157
-175
lines changed

config/config.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
* 'scale' - length of the mantissa
6161
*/
6262
'math' => [
63-
'scale' => 64,
63+
'scale' => env('WALLET_MATH_SCALE', 64),
6464
],
6565

6666
/**
@@ -166,28 +166,28 @@
166166
* Base model 'transaction'.
167167
*/
168168
'transaction' => [
169-
'table' => 'transactions',
169+
'table' => env('WALLET_TRANSACTION_TABLE_NAME', 'transactions'),
170170
'model' => Transaction::class,
171171
],
172172

173173
/**
174174
* Base model 'transfer'.
175175
*/
176176
'transfer' => [
177-
'table' => 'transfers',
177+
'table' => env('WALLET_TRANSFER_TABLE_NAME', 'transfers'),
178178
'model' => Transfer::class,
179179
],
180180

181181
/**
182182
* Base model 'wallet'.
183183
*/
184184
'wallet' => [
185-
'table' => 'wallets',
185+
'table' => env('WALLET_WALLET_TABLE_NAME', 'wallets'),
186186
'model' => Wallet::class,
187187
'creating' => [],
188188
'default' => [
189-
'name' => 'Default Wallet',
190-
'slug' => 'default',
189+
'name' => env('WALLET_DEFAULT_WALLET_NAME', 'Default Wallet'),
190+
'slug' => env('WALLET_DEFAULT_WALLET_SLUG', 'default'),
191191
'meta' => [],
192192
],
193193
],

docs/_sidebar.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
- [Introduction](README)
44
- [Installation](installation)
5-
- [Lumen installation](lumen)
65
- [Configuration](configuration)
76
- [Basic Usage](basic-usage)
87
- [Upgrade Guide](upgrade-guide)
@@ -55,6 +54,9 @@
5554
- [Wallet Swap](laravel-wallet-swap)
5655
- [Wallet UUID](laravel-wallet-uuid)
5756

57+
- Helpers
58+
- [Formatter](formatter)
59+
5860
- Events
5961

6062
- [BalanceUpdatedEvent](balance-updated-event)
@@ -65,7 +67,3 @@
6567
- CQRS
6668

6769
- [Create Wallet](command-create-wallet)
68-
69-
- Nova
70-
71-
- [Change of balance](nova-action)

docs/atomic-service.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
Working with atomic wallet operations.
44

5-
> You need wallet version 9.2 or higher
6-
75
Before you start working with atomicity, you need to study the "Race Condition" section and configure the lock.
86

97
Sometimes it is necessary to apply actions to the user and the wallet atomically. For example, you want to raise an ad in the search and withdraw money from your wallet.
@@ -39,4 +37,4 @@ app(AtomicServiceInterface::class)->blocks([$wallet1, $wallet2], function () use
3937

4038
In this case, we blocked both wallets and started the process of debiting funds. Debiting from both wallets will be considered a successful operation. If there are not enough funds on some wallet, the operation is canceled.
4139

42-
It worked!
40+
It's simple!

docs/balance-updated-event.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ class MyBalanceUpdatedListener
3030
}
3131
```
3232

33-
It worked!
33+
It's simple!

docs/batch-transactions.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
### API. Batch Transactions
22

3-
> Since version 9.5+
4-
53
Sometimes situations arise when there is a need to make multiple changes to wallets.
64
For example, we need to change the balance of many wallets at once. For example, the system administrator accrues a bonus for participating in some promotion. Previously, the code would look like this:
75
```php
@@ -78,7 +76,6 @@ use Bavix\Wallet\Services\ConsistencyServiceInterface;
7876
app(AtomicServiceInterface::class)->blocks($wallets, function () use ($wallets, $amount) {
7977
foreach ($wallets as $wallet) {
8078
app(ConsistencyServiceInterface::class)->checkPotential($wallet, $amount);
81-
8279
}
8380

8481
app(TransactionQueryHandlerInterface::class)->apply(
@@ -98,10 +95,15 @@ The main thing is to keep uniqueness.
9895
```php
9996
use Bavix\Wallet\External\Api\TransactionQuery;
10097

101-
TransactionQuery::createDeposit($wallet, $amount, null, uuid: '5f7820d1-1e82-4d03-9414-05d0c44da9a1')
102-
TransactionQuery::createWithdraw($wallet, $amount, null, uuid: '6e87dbf2-7be7-48c2-b688-f46ba4e25786')
98+
// int version
99+
TransactionQuery::createDeposit($wallet, $amount, null, uuid: '5f7820d1-1e82-4d03-9414-05d0c44da9a1');
100+
TransactionQuery::createWithdraw($wallet, $amount, null, uuid: '6e87dbf2-7be7-48c2-b688-f46ba4e25786');
101+
102+
// float version
103+
TransactionFloatQuery::createDeposit($wallet, $amountFloat, null, uuid: '5f7820d1-1e82-4d03-9414-05d0c44da9a1');
104+
TransactionFloatQuery::createWithdraw($wallet, $amountFloat, null, uuid: '6e87dbf2-7be7-48c2-b688-f46ba4e25786');
103105
```
104106

105107
---
106-
It worked!
108+
It's simple!
107109

docs/batch-transfers.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
### API. Batch Transfers
22

3-
> Since version 9.5+
4-
53
If you need multiple transfers between wallets, you can use a high-performance handle. It is worth remembering that the pen does not check the balance of the wallet before transferring, you need to take care of this yourself.
64

75
Previously, you would have written the following code:
@@ -38,6 +36,7 @@ The main thing is to keep uniqueness.
3836
```php
3937
use Bavix\Wallet\External\Api\TransferQuery;
4038

39+
// int version
4140
new TransferQuery($from, $wallet, $amount, new \Bavix\Wallet\External\Dto\Extra(
4241
deposit: new \Bavix\Wallet\External\Dto\Option(
4342
null,
@@ -48,9 +47,24 @@ new TransferQuery($from, $wallet, $amount, new \Bavix\Wallet\External\Dto\Extra(
4847
uuid: '3805730b-39a1-419d-8715-0b7cc3f1ffc2', // withdraw transaction
4948
),
5049
uuid: 'f8becf81-3993-43d7-81f1-7a725c72e976', // transfer uuid
51-
))
50+
extra: ['info' => 'fast deposit'], // metadata in the table transfers
51+
));
52+
53+
// float version
54+
new TransferFloatQuery($from, $wallet, $amountFlaot, new \Bavix\Wallet\External\Dto\Extra(
55+
deposit: new \Bavix\Wallet\External\Dto\Option(
56+
null,
57+
uuid: '71cecafe-da10-464f-9e00-c80437bb4c3e', // deposit transaction
58+
),
59+
withdraw: new \Bavix\Wallet\External\Dto\Option(
60+
null,
61+
uuid: '3805730b-39a1-419d-8715-0b7cc3f1ffc2', // withdraw transaction
62+
),
63+
uuid: 'f8becf81-3993-43d7-81f1-7a725c72e976', // transfer uuid
64+
extra: ['info' => 'fast deposit'], // metadata in the table transfers
65+
));
5266
```
5367

5468
---
55-
It worked!
69+
It's simple!
5670

docs/cart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@ $user->balanceFloat; // 156.27
129129
$user->balanceFloat; // 0
130130
```
131131

132-
It worked!
132+
It's simple!

docs/command-create-wallet.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Asynchronous wallet creation
22

3-
> You need wallet version 9.2 or higher
4-
53
The idea is based on the division into teams for creating wallets, transactions, etc. The creation of a wallet can be accelerated if the client "generates a wallet himself".
64

75
---
@@ -58,4 +56,5 @@ You receive requests to create a wallet on the backend, and you create them asyn
5856

5957
The user no longer needs to wait for the creation of a wallet, it is enough to know the uuid. You get the most stable application.
6058

61-
It worked!
59+
---
60+
It's simple!

docs/configuration.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# Configuration
2+
23
Though this package is crafted to suit most of your needs by default, you can edit the configuration file to suit certain demands.
34

5+
## Environment
6+
7+
| Name | Description | Default |
8+
|---------------------------------|-------------------------------|----------------|
9+
| `WALLET_MATH_SCALE` | Select mathematical precision | 64 |
10+
| `WALLET_CACHE_DRIVER` | Cache for wallet balance | array |
11+
| `WALLET_CACHE_TTL` | Cache TTL for wallet balance | 24h |
12+
| `WALLET_LOCK_DRIVER` | Lock for wallets | array |
13+
| `WALLET_LOCK_TTL` | Lock TTL for wallets | 1s |
14+
| `WALLET_TRANSACTION_TABLE_NAME` | Transaction table name | transactions |
15+
| `WALLET_TRANSFER_TABLE_NAME` | Transfer table name | transfers |
16+
| `WALLET_WALLET_TABLE_NAME` | Wallet table name | wallets |
17+
| `WALLET_DEFAULT_WALLET_NAME` | Default wallet name | Default Wallet |
18+
| `WALLET_DEFAULT_WALLET_SLUG` | Default wallet slug | default |
19+
420
## Configure default wallet
521
Customize `name`,`slug` and `meta` of default wallet.
622

docs/confirm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ $transaction->confirmed; // bool(true)
3333
$user->balance; // 100
3434
```
3535

36-
It worked!
36+
It's simple!

0 commit comments

Comments
 (0)