|
11 | 11 |
|
12 | 12 | **Demo:** https://github.com/HPWebdeveloper/demo-pay-pocket |
13 | 13 |
|
14 | | -**Videos:** |
| 14 | +**Videos:** |
15 | 15 |
|
16 | | -- [Laravel Pay Pocket Package: Virtual Wallets in Your Project](https://www.youtube.com/watch?v=KoQyURiwsA4) |
| 16 | +- [Laravel Pay Pocket Package: Virtual Wallets in Your Project](https://www.youtube.com/watch?v=KoQyURiwsA4) |
17 | 17 |
|
18 | | -- [Laravel Exceptions: Why and How to Use? Practical Example.](https://www.youtube.com/watch?v=-Sr18w91v8Q) |
19 | | - |
20 | | -- [PHP Enums in Laravel: Practical Example from Package](https://www.youtube.com/watch?v=iUOb-3HQtK8) |
| 18 | +- [Laravel Exceptions: Why and How to Use? Practical Example.](https://www.youtube.com/watch?v=-Sr18w91v8Q) |
21 | 19 |
|
| 20 | +- [PHP Enums in Laravel: Practical Example from Package](https://www.youtube.com/watch?v=iUOb-3HQtK8) |
22 | 21 |
|
23 | 22 | **Note:** This package does not handle payments from payment platforms, but instead offers the concept of virtual money, deposit, and withdrawal. |
24 | 23 |
|
|
33 | 32 |
|
34 | 33 | ### Support Policy |
35 | 34 |
|
36 | | -| Version | Laravel | PHP | Release date | End of improvements | End of support | |
37 | | -|-------------------------------------------------|--------------|-------------|---------------|---------------------| -------------- | |
38 | | -| 1.x | ^10.0 | 8.1, 8.2, 8.3 | Nov 30, 2023 | Mar 1, 2024 | | |
39 | | -| 2.x | ^10.0, ^11.0 |8.2, 8.3| June 27, 2024 | January 30, 2025 | | |
40 | | -| 3.x (atomic operations and restricted wallets) | ^11.0 |8.2, 8.3| comming soon | | | |
| 35 | +| Version | Laravel | PHP | Release date | End of improvements | End of support | |
| 36 | +| ------- | ------------ | ------------- | ------------- | ------------------- | -------------- | |
| 37 | +| 1.x | ^10.0 | 8.1, 8.2, 8.3 | Nov 30, 2023 | Mar 1, 2024 | | |
| 38 | +| 2.x | ^10.0, ^11.0 | 8.2, 8.3 | June 27, 2024 | January 30, 2025 | | |
41 | 39 |
|
42 | 40 | ## Installation: |
43 | 41 |
|
@@ -178,6 +176,71 @@ $user = auth()->user(); |
178 | 176 | LaravelPayPocket::pay($user, 12.34); |
179 | 177 | ``` |
180 | 178 |
|
| 179 | +#### Payment Transaction Logs |
| 180 | + |
| 181 | +The `pay()` method returns a collection of `WalletsLog` instances representing all wallet transactions that occurred during the payment. This enables you to track exactly which wallets were used and access detailed transaction information. |
| 182 | + |
| 183 | +**Return Value:** |
| 184 | + |
| 185 | +```php |
| 186 | +@return \Illuminate\Database\Eloquent\Collection<WalletsLog> |
| 187 | +``` |
| 188 | + |
| 189 | +**Basic Usage:** |
| 190 | + |
| 191 | +```php |
| 192 | +$user = auth()->user(); |
| 193 | +$logs = $user->pay(120.00, 'Order #1234'); |
| 194 | + |
| 195 | +// Access transaction details |
| 196 | +foreach ($logs as $log) { |
| 197 | + echo "Wallet: {$log->wallet_name}, Amount: {$log->value}"; |
| 198 | +} |
| 199 | +``` |
| 200 | + |
| 201 | +**Practical Examples:** |
| 202 | + |
| 203 | +```php |
| 204 | +// Get the number of wallets used in the payment |
| 205 | +$walletCount = $logs->count(); |
| 206 | + |
| 207 | +// Calculate total amount deducted (verification) |
| 208 | +$totalDeducted = $logs->sum('value'); |
| 209 | + |
| 210 | +// Get all wallet names used in the transaction |
| 211 | +$walletsUsed = $logs->pluck('wallet_name'); |
| 212 | + |
| 213 | +// Access specific log details |
| 214 | +$firstLog = $logs->first(); |
| 215 | +echo "From: {$firstLog->from}, To: {$firstLog->to}"; |
| 216 | +echo "Reference: {$firstLog->reference}"; |
| 217 | +``` |
| 218 | + |
| 219 | +**Use Cases:** |
| 220 | + |
| 221 | +- **Receipt Generation:** Display detailed payment breakdown showing amounts from each wallet |
| 222 | +- **Audit Trail:** Maintain comprehensive records of payment sources |
| 223 | +- **Transaction Verification:** Confirm the exact amount deducted from each wallet |
| 224 | +- **Analytics:** Track wallet usage patterns across payments |
| 225 | + |
| 226 | +**Example: Multi-Wallet Payment** |
| 227 | + |
| 228 | +```php |
| 229 | +$user = auth()->user(); |
| 230 | + |
| 231 | +// User has: wallet_1 = $100, wallet_2 = $50 |
| 232 | +$logs = $user->pay(120.00, 'Premium subscription'); |
| 233 | + |
| 234 | +// Returns collection with 2 logs: |
| 235 | +// Log 1: wallet_1 deducted $100 (100.00 -> 0.00) |
| 236 | +// Log 2: wallet_2 deducted $20 (50.00 -> 30.00) |
| 237 | + |
| 238 | +echo "Payment completed using {$logs->count()} wallet(s)"; |
| 239 | +// Output: Payment completed using 2 wallet(s) |
| 240 | +``` |
| 241 | + |
| 242 | +**Note:** This feature is backward compatible. Existing code that doesn't capture the return value will continue to work without any modifications. |
| 243 | + |
181 | 244 | ### Balance |
182 | 245 |
|
183 | 246 | - **Wallets** |
|
0 commit comments