Skip to content

Commit

Permalink
Merge branch 'main' of github.com:SSEsmaeeli/laravel-pay-pocket into …
Browse files Browse the repository at this point in the history
…fix/transactional-statements
  • Loading branch information
SSEsmaeeli committed Jul 6, 2024
2 parents 170d4f4 + 8846355 commit 55df323
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.6.0
uses: dependabot/fetch-metadata@v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@2.3.1
uses: aglipanci/laravel-pint-action@2.4

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
9 changes: 7 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.1, 8.2, 8.3]
laravel: [10.*]
php: [8.2, 8.3]
laravel: [10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
php: 8.1
- laravel: 11.*
testbench: 9.*
carbon: ^3.0
php: 8.2

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@

All notable changes to `laravel-pay-pocket` will be documented in this file.

## 2.2.0 - 2024-06-27

### What's Changed

* Update: Change log_reference_length to log_reference_params by @3m1n3nc3 in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/34
* Modify comments by @HPWebdeveloper in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/36

**Full Changelog**: https://github.com/HPWebdeveloper/laravel-pay-pocket/compare/2.1.0...2.2.0

## 2.1.0 - 2024-06-27

### What's Changed

* Bump aglipanci/laravel-pint-action from 2.3.1 to 2.4 by @dependabot in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/26
* Bump dependabot/fetch-metadata from 2.0.0 to 2.1.0 by @dependabot in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/27
* Add check Laravel 11 compatibility by @HPWebdeveloper in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/28
* Test over the correct php version by @HPWebdeveloper in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/29
* Support Laravel 11 by @samehdoush in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/25

### New Contributors

* @samehdoush made their first contribution in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/25

**Full Changelog**: https://github.com/HPWebdeveloper/laravel-pay-pocket/compare/2.0.3...2.1.0

## 2.0.3 - 2024-04-12

### What's Changed

* Update create_wallets_logs_table.php.stub by @josecarpio99 in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/21

### New Contributors

* @josecarpio99 made their first contribution in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/21

**Full Changelog**: https://github.com/HPWebdeveloper/laravel-pay-pocket/compare/2.0.2...2.0.3

## 2.0.2 - 2024-04-12

### What's Changed

* Bump ramsey/composer-install from 2 to 3 by @dependabot in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/20
* Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 by @dependabot in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/23

**Full Changelog**: https://github.com/HPWebdeveloper/laravel-pay-pocket/compare/2.0.1...2.0.2

## 2.0.1 - 2024-04-12

### What's Changed

* Update README.md by @3m1n3nc3 in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/15
* Fix/style fix by @SSEsmaeeli in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/17
* Types by @HPWebdeveloper in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/16

**Full Changelog**: https://github.com/HPWebdeveloper/laravel-pay-pocket/compare/2.0.0...2.0.1

## v2.0.0 - 2024-01-12

- [2.x] Add Transaction note by @3m1n3nc3 in https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/10
Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,35 @@

**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`.

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

**Videos:**

- [Laravel Pay Pocket Package: Virtual Wallets in Your Project](https://www.youtube.com/watch?v=KoQyURiwsA4)

- [Laravel Exceptions: Why and How to Use? Practical Example.](https://www.youtube.com/watch?v=-Sr18w91v8Q)

- [PHP Enums in Laravel: Practical Example from Package](https://www.youtube.com/watch?v=iUOb-3HQtK8)


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

- **Author**: Hamed Panjeh
- **Vendor**: hpwebdeveloper
- **Package**: laravel-pay-pocket
- **Alias name**: Laravel PPP (Laravel Pay Pocket Package)
- **Version**: `1.x`
- **Version**: `2.x`
- **PHP Version**: 8.1+
- **Laravel Version**: `10.x`
- **Laravel Version**: `10.x`, `11.x`
- **[Composer](https://getcomposer.org/):** `composer require hpwebdeveloper/laravel-pay-pocket`

### Support Policy

| Version | Laravel | PHP | Release date | End of improvements | End of support |
| ------- | ------- | ------------- | ------------ | ------------------- | -------------- |
| 1.x | ^10.0 | 8.1, 8.2, 8.3 | Nov 30, 2023 | Mar 1, 2024 | |
| x.x | | | | | |
| Version | Laravel | PHP | Release date | End of improvements | End of support |
|-------------------------------------------------|--------------|-------------|---------------|---------------------| -------------- |
| 1.x | ^10.0 | 8.1, 8.2, 8.3 | Nov 30, 2023 | Mar 1, 2024 | |
| 2.x | ^10.0, ^11.0 |8.2, 8.3| June 27, 2024 | January 30, 2025 | |
| 3.x (atomic operations and restricted wallets) | ^11.0 |8.2, 8.3| comming soon | | |

## Installation:

Expand Down Expand Up @@ -199,7 +209,7 @@ you will discover a variety of exceptions tailored to address each scenario of i
### Log

A typical `wallets_logs` table.
![Laravel Pay Pocket Log](https://github.com/HPWebdeveloper/laravel-pay-pocket/assets/16323354/a242d335-8bd2-4af1-aa38-4e95b8870941)
![Laravel Pay Pocket Log](https://github.com/HPWebdeveloper/laravel-pay-pocket/assets/16323354/0d7f2237-88e1-4ac0-a4f2-ac200bad9273)

## Testing

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^10.0"
"illuminate/contracts": "^10.0 || ^11.0"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down
31 changes: 20 additions & 11 deletions config/pay-pocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@

// config for HPWebdeveloper/LaravelPayPocket

/**
* The 'log_reference_generator' should be a numeric array with three elements:
* - The first element should be the fully qualified name of a class that contains static methods.
* This includes the namespace of the class.
* - The second element should be the name of a static method available in the specified class.
* - The third element should be an array of optional parameters to pass to the static method.
* For example, the default generator is configured as follows:
* [\Illuminate\Support\Str::class, 'random', [12]], which uses the 'random' static method
* from the \Illuminate\Support\Str class with 12 as a parameter.
*/
return [
'log_reference_length' => 12,

/*
|--------------------------------------------------------------------------
| Reference Generator Configuration
|--------------------------------------------------------------------------
|
| This configuration allows you to customize the generation of log reference strings
| within the LaravelPayPocket package.
|
| - [array] log_reference_params: An array of parameters to pass to the log_reference_generator_method.
| - [string] log_reference_prefix: Prefix for the generated reference string.
| - [class-string] log_reference_generator_class: Fully qualified name of the class containing static methods for generation.
| - [string] log_reference_generator_method: Name of the static method available in the generator class.
|
| By default, the following generator is set up:
| Illuminate\Support\Str::random(12)
|
*/

'log_reference_params' => [12],
'log_reference_prefix' => '',
'log_reference_generator_class' => Illuminate\Support\Str::class,
'log_reference_generator_method' => 'random',
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/create_wallets_logs_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ return new class () extends Migration {
*/
public function down(): void
{
Schema::dropIfExists('balance_logs');
Schema::dropIfExists('wallets_logs');
}
};
4 changes: 2 additions & 2 deletions src/Traits/BalanceOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ protected function generateReference(): string
{
$className = config('pay-pocket.log_reference_generator_class');
$methodName = config('pay-pocket.log_reference_generator_method');
$length = config('pay-pocket.log_reference_length');
$params = (array) config('pay-pocket.log_reference_params', [12]);
$prefix = config('pay-pocket.log_reference_prefix');

if (! is_callable([$className, $methodName])) {
throw new InvalidArgumentException('Invalid configuration: The combination of log_reference_generator_class and log_reference_generator_method is not callable.');
}

$reference = call_user_func([$className, $methodName], $length);
$reference = call_user_func([$className, $methodName], ...$params);

return $prefix.$reference;
}
Expand Down

0 comments on commit 55df323

Please sign in to comment.