From 3e7715bb8e2ed0f407cdcdb7ad66056f86fc2e00 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 09:35:57 +0300 Subject: [PATCH 01/17] chore(tests): add unit and integration test suites --- phpunit.xml | 14 +++++++++++--- tests/Integration/.gitkeep | 0 tests/Unit/.gitkeep | 0 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/Integration/.gitkeep create mode 100644 tests/Unit/.gitkeep diff --git a/phpunit.xml b/phpunit.xml index 48306e3..669530a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -11,15 +11,23 @@ convertDeprecationsToExceptions="true" failOnRisky="true" failOnWarning="true" - verbose="true"> + verbose="true" + colors="true"> tests + + + tests/Unit + + + + tests/Integration + - + src diff --git a/tests/Integration/.gitkeep b/tests/Integration/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Unit/.gitkeep b/tests/Unit/.gitkeep new file mode 100644 index 0000000..e69de29 From 3155e137fdef5e248fb7316ac52af33c571d286e Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 09:46:06 +0300 Subject: [PATCH 02/17] chore(security): add security advice script --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3e3efe0..19a9542 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,8 @@ "psalm-info": "vendor/bin/psalm --show-info=true --no-cache", "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", "check-style": "vendor/bin/php-cs-fixer fix --dry-run", - "test": "vendor/bin/phpunit --testdox" + "test": "vendor/bin/phpunit --testdox", + "security-advice": "composer update --dry-run roave/security-advisories" }, "extra": { "laravel": { From 92520f3b17c9d161233ca4f8dc23ccba8c1700b6 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 09:46:33 +0300 Subject: [PATCH 03/17] chore(ci): create CI workflow --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..82d0f42 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI +on: + push: + branches: + - '*' + - '*/*' + - '**' + pull_request: + branches: + - '*' + - '*/*' + - '**' +jobs: + psr-12: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Check PSR-12 + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.dist.php --dry-run + From 7aceaae66db233f04d9e19651db58ce1db382081 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 09:54:21 +0300 Subject: [PATCH 04/17] chore(ci): add static code analysis job --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ composer.json | 3 +-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82d0f42..4857ddb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ on: - '*/*' - '**' jobs: + # PSR-12 Coding standards psr-12: runs-on: ubuntu-latest steps: @@ -22,3 +23,31 @@ jobs: with: args: --config=.php-cs-fixer.dist.php --dry-run + # Static code analysis + static_code_analysis: + name: [ Psalm ] Static code analysis + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: PHP setup + uses: shivammathur/setup-php@v2 + with: + php_version: '7.4' + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + + - name: Install dependencies + run: composer install -n --prefer-dist + + - name: Psalm + run: composer psalm + + diff --git a/composer.json b/composer.json index 19a9542..cbb9516 100644 --- a/composer.json +++ b/composer.json @@ -40,8 +40,7 @@ } }, "scripts": { - "psalm": "vendor/bin/psalm", - "psalm-info": "vendor/bin/psalm --show-info=true --no-cache", + "psalm": "vendor/bin/psalm --show-info=true --no-cache", "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", "check-style": "vendor/bin/php-cs-fixer fix --dry-run", "test": "vendor/bin/phpunit --testdox", From a357551db95f213e4689940765447461fd261abb Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 09:55:59 +0300 Subject: [PATCH 05/17] fix(ci): fix ci syntax --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4857ddb..92e5b01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: # Static code analysis static_code_analysis: - name: [ Psalm ] Static code analysis + name: \[ Psalm \] Static code analysis runs-on: ubuntu-latest steps: - name: Checkout From f89d05f50a54f8e8dd7a903dd946fb15030e6eb2 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:05:37 +0300 Subject: [PATCH 06/17] chore(ci): add tests to ci --- .github/workflows/ci.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92e5b01..c111aff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: # Static code analysis static_code_analysis: - name: \[ Psalm \] Static code analysis + name: Psalm - Static code analysis runs-on: ubuntu-latest steps: - name: Checkout @@ -50,4 +50,31 @@ jobs: - name: Psalm run: composer psalm + # Tests + tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + php: [ 7.4, 8.0, 8.1 ] + name: Tests - ${{ matrix.os }} - ${{ matrix.php }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: PHP setup + uses: shivammathur/setup-php@v2 + with: + php_version: '7.4' + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Install dependencies + run: composer install + + - name: Execute PHPUnit tests + run: composer test From a6eec2d4f15f0a2a13629007da335156ff150602 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:08:57 +0300 Subject: [PATCH 07/17] chore(ci): add fileinfo extension --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c111aff..bf56a6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,8 @@ jobs: uses: shivammathur/setup-php@v2 with: php_version: '7.4' - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, + iconv, imagick,fileinfo coverage: none - name: Install dependencies From 4960dab1d5bbc20e78913fa9b7e8716858992769 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:12:02 +0300 Subject: [PATCH 08/17] chore(ci): add name for psr-12 job --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf56a6f..cb86646 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,7 @@ on: jobs: # PSR-12 Coding standards psr-12: + name: PSR-12 runs-on: ubuntu-latest steps: - name: Checkout From 8bae87bb03e3f1dc8dc165fc55490e11eb661c86 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:12:11 +0300 Subject: [PATCH 09/17] chore(ci): remove un-used code --- .github/workflows/code-analysis.yml | 33 ----------------------- .github/workflows/code-style.yml | 16 ----------- .github/workflows/tests.yml | 41 ----------------------------- 3 files changed, 90 deletions(-) delete mode 100644 .github/workflows/code-analysis.yml delete mode 100644 .github/workflows/code-style.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml deleted file mode 100644 index 20db429..0000000 --- a/.github/workflows/code-analysis.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Static analysis - -on: - push: - paths: - - '**.php' - - 'psalm.xml' - -jobs: - psalm: - name: psalm - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v1 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick - coverage: none - - - name: Cache composer dependencies - uses: actions/cache@v1 - with: - path: vendor - key: composer-${{ hashFiles('composer.lock') }} - - - name: Run composer install - run: composer install -n --prefer-dist - - - name: Run psalm - run: composer psalm-info diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml deleted file mode 100644 index 8a5079c..0000000 --- a/.github/workflows/code-style.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: 'Code Style:PSR12' - -on: [push] - -jobs: - check_code_style: - runs-on: ubuntu-20.04 - - steps: - - name: Checkout code - uses: actions/checkout@v1 - - - name: Check style - uses: docker://oskarstark/php-cs-fixer-ga - with: - args: --config=.php-cs-fixer.dist.php --dry-run diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 6bbba57..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Tests -on: - push: - branches: - - '*' - - '*/*' - - '**' - pull_request: - branches: - - '*' - - '*/*' - - '**' -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [ ubuntu-20.04 ] - php: [ 7.4, 8.0, 8.1 ] - - name: PHP${{ matrix.php }} - ${{ matrix.os }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mbstring, bcmath - coverage: none - - - name: Install requirements - run: composer install - - - name: Execute PHPUnit tests - run: composer test From b1684be35b0df56ee8dc7316cdb5e53a46620d8d Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:23:23 +0300 Subject: [PATCH 10/17] chore(docs): update readme file --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 34283b0..1a827b4 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@

Laravel In-app Purchase cover

- Packagist PHP Version Support - Latest Version on Packagist - Total Downloads - GitHub last commit - Code Style:PSR12 - Tests + Packagist PHP Version Support + + + GitHub last commit + CI

✅ App Store ✅ Google Play

From 9cbfe80d25841c0647cc3b795a17d9d3062273d5 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:25:28 +0300 Subject: [PATCH 11/17] chore(ci): fix attributes --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb86646..bafe581 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - name: PHP setup uses: shivammathur/setup-php@v2 with: - php_version: '7.4' + php-version: '7.4' extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick coverage: none From 738375f8d22ed694af02bbd3a588a98ca7c86383 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:28:03 +0300 Subject: [PATCH 12/17] chore(ci): fix php version attribute --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bafe581..89beb68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: - name: PHP setup uses: shivammathur/setup-php@v2 with: - php_version: '7.4' + php-version: '7.4' extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick,fileinfo coverage: none From 0ed9a70383ea9d04836a2d3e6d1baca75c990728 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:33:31 +0300 Subject: [PATCH 13/17] chore(docs): fix broken link --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a827b4..551b221 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ alt="Latest Version on Packagist"> Total Downloads - GitHub last commit + GitHub last commit CI

✅ App Store ✅ Google Play

From da1143a9fca3562549a650d710b0d1946e2e3396 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 10:57:12 +0300 Subject: [PATCH 14/17] feat(config): document the config file --- config/liap.php | 143 ++++++++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 66 deletions(-) diff --git a/config/liap.php b/config/liap.php index 3169702..fa74f6e 100644 --- a/config/liap.php +++ b/config/liap.php @@ -1,74 +1,85 @@ [ - 'signed' => false, - ], + /* + |-------------------------------------------------------------------------- + | Routing configuration + |-------------------------------------------------------------------------- + | + | This configuration is used to determine the routing behavior of the + | Server notifications handler endpoint. + | + | You can find more information on documentation. + | @see https://imdhemy.com/laravel-iap-docs/docs/get-started/routing + */ + + 'routing' => [ + 'signed' => false, + 'middleware' => [], + 'prefix' => '', + ], + + /* + |-------------------------------------------------------------------------- + | Google Play Default Package name + |-------------------------------------------------------------------------- + | + | This value is the default package name used when the package name is not + | provided while verifying the receipts. + | + */ + 'google_play_package_name' => env('GOOGLE_PLAY_PACKAGE_NAME', 'com.some.thing'), + + /* + |-------------------------------------------------------------------------- + | App Store Password + |-------------------------------------------------------------------------- + | + | This value is the app-specific share password generated by the app store. + | @see https://imdhemy.com/laravel-iap-docs/docs/credentials/app-store + | + */ + 'appstore_password' => env('APPSTORE_PASSWORD', ''), - 'google_play_package_name' => env('GOOGLE_PLAY_PACKAGE_NAME', 'com.some.thing'), + /* + |-------------------------------------------------------------------------- + | Event Listeners + |-------------------------------------------------------------------------- + | + | This configuration is used to determine the event listeners that will be + | registered with the application. + | You can find a list of all available events of the documentation + | + | @see https://imdhemy.com/laravel-iap-docs/docs/server-notifications/event-list + | @see https://imdhemy.com/laravel-iap-docs/docs/get-started/event-listeners + | + */ + 'eventListeners' => [ + /* + |-------------------------------------------------------------------------- + | App Store Events + |-------------------------------------------------------------------------- + | + | These event listeners are triggered when a new notification is received from App Store. + | @see https://imdhemy.com/laravel-iap-docs/docs/server-notifications/event-list#app-store-events + | + */ - 'appstore_password' => env('APPSTORE_PASSWORD', ''), + /* \Imdhemy\Purchases\Events\AppStore\Cancel::class => [ + \App\Listeners\AppStore\Cancel::class, + ],*/ - 'eventListeners' => [ - /** - * -------------------------------------------------------- - * Google Play Events - * -------------------------------------------------------- - */ - SubscriptionPurchased::class => [], - SubscriptionRenewed::class => [], - SubscriptionInGracePeriod::class => [], - SubscriptionExpired::class => [], - SubscriptionCanceled::class => [], - SubscriptionPaused::class => [], - SubscriptionRestarted::class => [], - SubscriptionDeferred::class => [], - SubscriptionRevoked::class => [], - SubscriptionOnHold::class => [], - SubscriptionRecovered::class => [], - SubscriptionPauseScheduleChanged::class => [], - SubscriptionPriceChangeConfirmed::class => [], + /* + |-------------------------------------------------------------------------- + | Google Play Events + |-------------------------------------------------------------------------- + | + | These event listeners are triggered when a new notification is received from Google Play + | @see @see https://imdhemy.com/laravel-iap-docs/docs/server-notifications/event-list#google-play-events + */ - /** - * -------------------------------------------------------- - * App Store Events - * -------------------------------------------------------- - */ - Cancel::class => [], - DidChangeRenewalPref::class => [], - DidChangeRenewalStatus::class => [], - DidFailToRenew::class => [], - DidRecover::class => [], - DidRenew::class => [], - InitialBuy::class => [], - InteractiveRenewal::class => [], - PriceIncreaseConsent::class => [], - Refund::class => [], - Revoke::class => [], - ], + /* \Imdhemy\Purchases\Events\GooglePlay\SubscriptionRecovered::class => [ + \App\Listeners\GooglePlay\SubscriptionRecovered::class, + ],*/ + ], ]; From 40ee35e58afc2f36138fea3994615d2eb4602899 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 11:00:26 +0300 Subject: [PATCH 15/17] chore(routes): fix line length --- routes/routes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routes/routes.php b/routes/routes.php index b1c4b8f..42dbd9e 100644 --- a/routes/routes.php +++ b/routes/routes.php @@ -3,4 +3,5 @@ use Illuminate\Support\Facades\Route; use Imdhemy\Purchases\Http\Controllers\ServerNotificationController; -Route::post('/liap/notifications', ServerNotificationController::class)->name('liap.serverNotifications'); +Route::post('/liap/notifications', ServerNotificationController::class) + ->name('liap.serverNotifications'); From 9a90657e100d9a29d350e48b9ad70280280aad1d Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 12:00:14 +0300 Subject: [PATCH 16/17] Update pull_request_template.md --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index f2d1516..4a8fd46 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -10,7 +10,7 @@ Mention the related issue, either a feature request or a bug report. Describe your solution to the problem. -**Does your code follow the PSR-2 standard?** _(Yes|No)_. +**Does your code follow the PSR-12 standard?** _(Yes|No)_. Answer: ... From 564bb0b03234697c8d25f61967b74c93d49559a6 Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Thu, 25 Aug 2022 12:04:30 +0300 Subject: [PATCH 17/17] chore(ci): add security advice step to ci --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89beb68..b704070 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,6 +77,8 @@ jobs: - name: Install dependencies run: composer install + - name: Security advice + run: composer security-advice + - name: Execute PHPUnit tests run: composer test -