Skip to content

Commit 6c2fdbb

Browse files
committed
Updating README
1 parent c0df115 commit 6c2fdbb

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed

README.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,46 @@
77
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/hpwebdeveloper/laravel-pay-pocket/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/hpwebdeveloper/laravel-pay-pocket/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
88
[![Imports](https://github.com/HPWebdeveloper/laravel-pay-pocket/actions/workflows/check_imports.yml/badge.svg?branch=main)](https://github.com/HPWebdeveloper/laravel-pay-pocket/actions/workflows/check_imports.yml)
99

10-
1110
**Laravel Pay Pocket** is a package designed for Laravel applications, offering the flexibility to manage multiple wallet types within two dedicated database tables, `wallets` and `wallets_logs`.
1211

1312
**Demo** https://github.com/HPWebdeveloper/demo-pay-pocket
1413

1514
**Note:** This package does not handle payments from payment platforms, but instead offers the concept of virtual money, deposit, and withdrawal.
1615

17-
* **Author**: Hamed Panjeh
18-
* **Vendor**: hpwebdeveloper
19-
* **Package**: laravel-pay-pocket
20-
* **Alias name**: Laravel PPP (Laravel Pay Pocket Package)
21-
* **Version**: `1.x`
22-
* **PHP Version**: 8.1+
23-
* **Laravel Version**: `10.x`
24-
* **[Composer](https://getcomposer.org/):** `composer require hpwebdeveloper/laravel-pay-pocket`
25-
16+
- **Author**: Hamed Panjeh
17+
- **Vendor**: hpwebdeveloper
18+
- **Package**: laravel-pay-pocket
19+
- **Alias name**: Laravel PPP (Laravel Pay Pocket Package)
20+
- **Version**: `1.x`
21+
- **PHP Version**: 8.1+
22+
- **Laravel Version**: `10.x`
23+
- **[Composer](https://getcomposer.org/):** `composer require hpwebdeveloper/laravel-pay-pocket`
2624

2725
### Support Policy
2826

29-
| Version | Laravel | PHP | Release date | End of improvements | End of support |
30-
|---------|----------------|---------------|--------------|---------------------|----------------|
31-
| 1.x | ^10.0 | 8.1, 8.2, 8.3 | Nov 30, 2023 | Mar 1, 2024 | | |
32-
| x.x | | | | | | |
33-
27+
| Version | Laravel | PHP | Release date | End of improvements | End of support |
28+
| ------- | ------- | ------------- | ------------ | ------------------- | -------------- | --- |
29+
| 1.x | ^10.0 | 8.1, 8.2, 8.3 | Nov 30, 2023 | Mar 1, 2024 | | |
30+
| x.x | | | | | | |
3431

3532
## Installation:
3633

37-
- **Step 1:** You can install the package via composer:
34+
- **Step 1:** You can install the package via composer:
3835

3936
```bash
4037
composer require hpwebdeveloper/laravel-pay-pocket
4138
```
4239

43-
- **Step 2:** Publish and run the migrations with:
40+
- **Step 2:** Publish and run the migrations with:
4441

4542
```bash
4643
php artisan vendor:publish --tag="pay-pocket-migrations"
4744
php artisan migrate
4845
```
46+
4947
You have successfully added two dedicated database tables, `wallets` and `wallets_logs`, without making any modifications to the `users` table.
5048

51-
- **Step 3:** Publish the wallet types using
49+
- **Step 3:** Publish the wallet types using
5250

5351
```bash
5452
php artisan vendor:publish --tag="pay-pocket-wallets"
@@ -60,7 +58,7 @@ This command will automatically publish the `WalletEnums.php` file into your app
6058

6159
### Prepare User Model
6260

63-
To use this package you need to implement the `WalletOperations` into `User` model and utilize the `ManagesWallet` trait.
61+
To use this package you need to implement the `WalletOperations` into `User` model and utilize the `ManagesWallet` trait.
6462

6563
```php
6664

@@ -75,9 +73,10 @@ class User extends Authenticatable implements WalletOperations
7573

7674
### Prepare Wallets
7775

78-
In Laravel Pay Pocket, you have the flexibility to define the order in which wallets are prioritized for payments through the use of Enums. The order of wallets in the Enum file determines their priority level. The first wallet listed has the highest priority and will be used first for deducting order values.
76+
In Laravel Pay Pocket, you have the flexibility to define the order in which wallets are prioritized for payments through the use of Enums. The order of wallets in the Enum file determines their priority level. The first wallet listed has the highest priority and will be used first for deducting order values.
7977

8078
For example, consider the following wallet types defined in the Enum class (published in step 3 of installation):
79+
8180
```php
8281
namespace App\Enums;
8382

@@ -88,15 +87,17 @@ enum WalletEnums: string
8887
}
8988

9089
```
91-
**You have complete freedom to name your wallets as per your requirements and even add more wallet types to the Enum list.**
9290

91+
**You have complete freedom to name your wallets as per your requirements and even add more wallet types to the Enum list.**
9392

9493
In this particular setup, `wallet_1` (`WALLET1`) is given the **highest priority**. When an order payment is processed, the system will first attempt to use `wallet_1` to cover the cost. If `wallet_1` does not have sufficient funds, `wallet_2` (`WALLET2`) will be used next.
9594

9695
### Example:
96+
9797
If the balance in `wallet_1` is 10 and the balance in `wallet_2` is 20, and you need to pay an order value of 15, the payment process will first utilize the entire balance of `wallet_1`. Since `wallet_1`'s balance is insufficient to cover the full amount, the remaining 5 will be deducted from `wallet_2`. After the payment, `wallet_2` will have a remaining balance of 15."
9898

9999
## Usage, APIs and Operations:
100+
100101
### Deposit
101102

102103
```php
@@ -113,13 +114,24 @@ use HPWebdeveloper\LaravelPayPocket\Facades\LaravelPayPocket;
113114
LaravelPayPocket::deposit($user, 'wallet_1', 123.45);
114115

115116
```
117+
116118
Note: `wallet_1` and `wallet_2` must already be defined in the `WalletEnums`.
117119

120+
#### Transaction Info ([#8][i8])
121+
122+
In a case where you want to enter descriptions for a particular transaction, the `$notes` param allows you to provide information about why a transaction happened.
123+
124+
```php
125+
$user = auth()->user();
126+
$user->deposit('wallet_1', 67.89, 'You ordered pizza.');
127+
```
128+
118129
### Pay
130+
119131
```php
120132
// Pay the value using the total combined balance available across all wallets
121133
$user->pay(12.34);
122-
134+
123135
// Or using provided facade
124136

125137
use HPWebdeveloper\LaravelPayPocket\Facades\LaravelPayPocket;
@@ -129,7 +141,8 @@ LaravelPayPocket::pay($user, 12.34);
129141

130142
### Balance
131143

132-
- **Wallets**
144+
- **Wallets**
145+
133146
```php
134147
$user->walletBalance // Total combined balance available across all wallets
135148

@@ -138,7 +151,8 @@ $user->walletBalance // Total combined balance available across all wallets
138151
LaravelPayPocket::checkBalance($user);
139152
```
140153

141-
- **Particular Wallet**
154+
- **Particular Wallet**
155+
142156
```php
143157
$user->getWalletBalanceByType('wallet_1') // Balance available in wallet_1
144158
$user->getWalletBalanceByType('wallet_2') // Balance available in wallet_2
@@ -149,15 +163,15 @@ LaravelPayPocket::walletBalanceByType($user, 'wallet_1');
149163
```
150164

151165
### Exceptions
152-
Upon examining the `src/Exceptions` directory within the source code,
166+
167+
Upon examining the `src/Exceptions` directory within the source code,
153168
you will discover a variety of exceptions tailored to address each scenario of invalid entry. Review the [demo](https://github.com/HPWebdeveloper/demo-pay-pocket) that accounts for some of the exceptions.
154169

155170
### Log
156171

157172
A typical `wallets_logs` table.
158173
![Laravel Pay Pocket Log](https://github.com/HPWebdeveloper/laravel-pay-pocket/assets/16323354/a242d335-8bd2-4af1-aa38-4e95b8870941)
159174

160-
161175
## Testing
162176

163177
```bash
@@ -185,9 +199,9 @@ Please review [our security policy](../../security/policy) on how to report secu
185199

186200
## Credits
187201

188-
- [Hamed Panjeh](https://github.com/HPWebdeveloper)
189-
- [All Contributors](../../contributors)
190-
- Icon in the above image: pocket by Creative Mahira from [Noun Project](https://thenounproject.com/browse/icons/term/pocket/) (CC BY 3.0)
202+
- [Hamed Panjeh](https://github.com/HPWebdeveloper)
203+
- [All Contributors](../../contributors)
204+
- Icon in the above image: pocket by Creative Mahira from [Noun Project](https://thenounproject.com/browse/icons/term/pocket/) (CC BY 3.0)
191205

192206
## License
193207

0 commit comments

Comments
 (0)