From 902dd2af1fd75e8bdafa2808913a0ab504cc026b Mon Sep 17 00:00:00 2001 From: Manoj Hortulanus Date: Thu, 29 Jan 2026 14:15:01 +0100 Subject: [PATCH 1/8] Rename --- .editorconfig | 15 +++ .gitattributes | 20 ++++ .github/FUNDING.yml | 1 + .github/ISSUE_TEMPLATE/bug.yml | 66 +++++++++++ .github/ISSUE_TEMPLATE/config.yml | 11 ++ .github/workflows/run-tests.yml | 60 ++++++++++ .github/workflows/update-changelog.yml | 32 +++++ .gitignore | 32 +++++ CHANGELOG.md | 3 + LICENSE.md | 21 ++++ README.md | 84 ++++++++++++++ composer.json | 60 ++++++++++ phpunit.xml.dist | 31 +++++ src/CheckoutDriver.php | 53 +++++++++ src/Contracts/InteractsWithShop.php | 12 ++ src/Contracts/PaymentGateway.php | 142 +++++++++++++++++++++++ src/Contracts/PaymentResult.php | 66 +++++++++++ src/Facades/AvailableCheckoutDrivers.php | 22 ++++ src/Gateways/AbstractGateway.php | 99 ++++++++++++++++ src/ShopContractsServiceProvider.php | 20 ++++ 20 files changed, 850 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/workflows/run-tests.yml create mode 100644 .github/workflows/update-changelog.yml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpunit.xml.dist create mode 100644 src/CheckoutDriver.php create mode 100644 src/Contracts/InteractsWithShop.php create mode 100644 src/Contracts/PaymentGateway.php create mode 100644 src/Contracts/PaymentResult.php create mode 100644 src/Facades/AvailableCheckoutDrivers.php create mode 100644 src/Gateways/AbstractGateway.php create mode 100644 src/ShopContractsServiceProvider.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dd9a2b5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c09f81e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,20 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpunit.xml.dist export-ignore +/art export-ignore +/docs export-ignore +/tests export-ignore +/workbench export-ignore +/.editorconfig export-ignore +/.php_cs.dist.php export-ignore +/psalm.xml export-ignore +/psalm.xml.dist export-ignore +/testbench.yaml export-ignore +/UPGRADING.md export-ignore +/phpstan.neon.dist export-ignore +/phpstan-baseline.neon export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..29313eb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: Backstage diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..8136330 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,66 @@ +name: Bug Report +description: Report an Issue or Bug with the Package +title: "[Bug]: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + - type: textarea + id: what-happened + attributes: + label: What happened? + description: What did you expect to happen? + placeholder: I cannot currently do X thing because when I do, it breaks X thing. + validations: + required: true + - type: textarea + id: how-to-reproduce + attributes: + label: How to reproduce the bug + description: How did this occur, please add any config values used and provide a set of reliable steps if possible. + placeholder: When I do X I see Y. + validations: + required: true + - type: input + id: package-version + attributes: + label: Package Version + description: What version of our Package are you running? Please be as specific as possible + placeholder: 2.0.0 + validations: + required: true + - type: input + id: php-version + attributes: + label: PHP Version + description: What version of PHP are you running? Please be as specific as possible + placeholder: 8.2.0 + validations: + required: true + - type: input + id: laravel-version + attributes: + label: Laravel Version + description: What version of Laravel are you running? Please be as specific as possible + placeholder: 9.0.0 + validations: + required: true + - type: dropdown + id: operating-systems + attributes: + label: Which operating systems does this happen with? + description: You may select more than one. + multiple: true + options: + - macOS + - Windows + - Linux + - type: textarea + id: notes + attributes: + label: Notes + description: Use this field to provide any other notes that you feel might be relevant to the issue. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..e7f9b0e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a question + url: https://github.com/backstage/shop-contracts/discussions/new?category=q-a + about: Ask the community for help + - name: Request a feature + url: https://github.com/backstage/shop-contracts/discussions/new?category=ideas + about: Share ideas for new features + - name: Report a security issue + url: https://github.com/backstage/shop-contracts/security/policy + about: Learn how to notify us for sensitive bugs diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..b668642 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,60 @@ +name: run-tests + +on: + push: + paths: + - '**.php' + - '.github/workflows/run-tests.yml' + - 'phpunit.xml.dist' + - 'composer.json' + - 'composer.lock' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.4, 8.3] + laravel: [12.*, 11.*] + stability: [prefer-lowest, prefer-stable] + include: + - laravel: 12.* + testbench: 10.* + - laravel: 11.* + testbench: 9.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: List Installed Dependencies + run: composer show -D + + - name: Execute tests + run: vendor/bin/pest --ci diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml new file mode 100644 index 0000000..277821c --- /dev/null +++ b/.github/workflows/update-changelog.yml @@ -0,0 +1,32 @@ +name: "Update Changelog" + +on: + release: + types: [released] + +permissions: + contents: write + +jobs: + update: + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.name }} + release-notes: ${{ github.event.release.body }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v7 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b60507f --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# Composer Related +composer.lock +/vendor + +# Frontend Assets +/node_modules + +# Logs +npm-debug.log +yarn-error.log + +# Caches +.phpunit.cache +.phpunit.result.cache +/build + +# IDE Helper +_ide_helper.php +_ide_helper_models.php +.phpstorm.meta.php + +# Editors +/.idea +/.fleet +/.vscode + +# Misc +phpunit.xml +phpstan.neon +testbench.yaml +/docs +/coverage diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5342dc0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +All notable changes to `shop-contracts` will be documented in this file. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..cc26ee3 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Backstage + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..83ba84f --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# Shop contracts + +[![Latest Version on Packagist](https://img.shields.io/packagist/v/backstage/shop-contracts.svg?style=flat-square)](https://packagist.org/packages/backstage/shop-contracts) +[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/backstage/shop-contracts/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/backstage/shop-contracts/actions?query=workflow%3Arun-tests+branch%3Amain) +[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/backstage/shop-contracts/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/backstage/shop-contracts/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) +[![Total Downloads](https://img.shields.io/packagist/dt/backstage/shop-contracts.svg?style=flat-square)](https://packagist.org/packages/backstage/shop-contracts) + +This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. + +## Support us + +[](https://spatie.be/github-ad-click/shop-contracts) + +We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). + +We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). + +## Installation + +You can install the package via composer: + +```bash +composer require backstage/shop-contracts +``` + +You can publish and run the migrations with: + +```bash +php artisan vendor:publish --tag="shop-contracts-migrations" +php artisan migrate +``` + +You can publish the config file with: + +```bash +php artisan vendor:publish --tag="shop-contracts-config" +``` + +This is the contents of the published config file: + +```php +return [ +]; +``` + +Optionally, you can publish the views using + +```bash +php artisan vendor:publish --tag="shop-contracts-views" +``` + +## Usage + +```php +$shopContracts = new Backstage\ShopContracts(); +echo $shopContracts->echoPhrase('Hello, Backstage!'); +``` + +## Testing + +```bash +composer test +``` + +## Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + +## Security Vulnerabilities + +Please review [our security policy](../../security/policy) on how to report security vulnerabilities. + +## Credits + +- [Manoj Hortulanus](https://github.com/arduinomaster22) +- [All Contributors](../../contributors) + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..eb52b4f --- /dev/null +++ b/composer.json @@ -0,0 +1,60 @@ +{ + "name": "backstage/shop-support", + "description": "Shop support", + "keywords": [ + "Backstage", + "laravel", + "shop-support" + ], + "homepage": "https://github.com/backstage/shop-support", + "license": "MIT", + "authors": [ + { + "name": "Manoj Hortulanus", + "email": "manoj@backstagephp.com", + "role": "Developer" + } + ], + "require": { + "php": "^8.4", + "laravel/framework": "^10.0 || ^11.0 || ^12.0", + "spatie/laravel-package-tools": "^1.16" + }, + "autoload": { + "psr-4": { + "Backstage\\Shop\\Support\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Workbench\\App\\": "workbench/app/" + } + }, + "scripts": { + "post-autoload-dump": "@composer run prepare", + "prepare": "@php vendor/bin/testbench package:discover --ansi", + "analyse": "vendor/bin/phpstan analyse", + "test": "vendor/bin/pest", + "test-coverage": "vendor/bin/pest --coverage", + "format": "vendor/bin/pint" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true + } + }, + "extra": { + "laravel": { + "providers": [ + "Backstage\\Shop\\Contracts\\ShopContractsServiceProvider" + ], + "aliases": { + "AvailableCheckoutDrivers": "Backstage\\Shop\\Contracts\\Facades\\AvailableCheckoutDrivers" + } + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..80dc22a --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + tests + + + + + + + + ./src + + + diff --git a/src/CheckoutDriver.php b/src/CheckoutDriver.php new file mode 100644 index 0000000..9b8dfc7 --- /dev/null +++ b/src/CheckoutDriver.php @@ -0,0 +1,53 @@ +> + */ + protected array $drivers = []; + + /** + * Register a driver. + * + * @param class-string $driverClass + */ + public function setupDriver(string $driver, string $driverClass): static + { + $this->drivers[$driver] = $driverClass; + + return $this; + } + + /** + * Get all registered drivers. + * + * @return array> + */ + public function getDrivers(): array + { + return $this->drivers; + } + + /** + * Check if a driver is registered. + */ + public function hasDriver(string $driver): bool + { + return isset($this->drivers[$driver]); + } + + /** + * Get a specific driver class. + * + * @return class-string|null + */ + public function getDriver(string $driver): ?string + { + return $this->drivers[$driver] ?? null; + } +} diff --git a/src/Contracts/InteractsWithShop.php b/src/Contracts/InteractsWithShop.php new file mode 100644 index 0000000..34a47eb --- /dev/null +++ b/src/Contracts/InteractsWithShop.php @@ -0,0 +1,12 @@ +config = $config; + } + + abstract public function getName(): string; + + abstract public function createPayment(Model $order, array $options = []): PaymentResultContract; + + abstract public function getPayment(string $paymentId): ?PaymentResultContract; + + abstract public function refundPayment(string $paymentId, ?int $amount = null): PaymentResultContract; + + abstract public function createCustomer(Model $customer): string; + + abstract public function getCustomer(string $gatewayCustomerId): ?array; + + abstract public function updateCustomer(string $gatewayCustomerId, array $data): bool; + + abstract public function deleteCustomer(string $gatewayCustomerId): bool; + + abstract public function handleWebhook(array $payload): void; + + abstract public function verifyWebhookSignature(string $payload, string $signature): bool; + + abstract public function getPaymentUrl(string $paymentId): ?string; + + abstract public function getAvailablePaymentMethods(): array; + + abstract public function createProduct(Model $product): string; + + abstract public function getProduct(string $gatewayProductId): ?array; + + abstract public function updateProduct(string $gatewayProductId, Model $product): bool; + + abstract public function deleteProduct(string $gatewayProductId): bool; + + abstract public function syncProduct(Model $product): string; + + abstract public function createPrice(Model $product, int $amount, string $currency, array $options = []): string; + + abstract public function getPrice(string $gatewayPriceId): ?array; + + abstract public function updatePrice(string $gatewayPriceId, array $data): bool; + + abstract public function archivePrice(string $gatewayPriceId): bool; + + abstract public function syncPrice(Model $product, int $amount, string $currency, array $options = []): string; + + abstract public function listPrices(string $gatewayProductId): array; + + public function supports(string $feature): bool + { + return in_array($feature, $this->supportedFeatures); + } + + protected function getConfig(string $key, mixed $default = null): mixed + { + return $this->config[$key] ?? $default; + } + + protected function createResult( + string $id, + string $status, + int $amount, + string $currency, + array $rawData = [], + ?string $redirectUrl = null, + ?string $errorMessage = null, + ): PaymentResultContract { + return new PaymentResult( + id: $id, + status: $status, + amount: $amount, + currency: $currency, + rawData: $rawData, + redirectUrl: $redirectUrl, + errorMessage: $errorMessage, + ); + } +} diff --git a/src/ShopContractsServiceProvider.php b/src/ShopContractsServiceProvider.php new file mode 100644 index 0000000..fb29f30 --- /dev/null +++ b/src/ShopContractsServiceProvider.php @@ -0,0 +1,20 @@ +name('shop-support'); + } + + public function packageRegistered(): void + { + $this->app->singleton(CheckoutDriver::class, fn () => new CheckoutDriver); + } +} From 048e29e90a7036c921b80a6f32879b1a989e25c4 Mon Sep 17 00:00:00 2001 From: Manoj Hortulanus Date: Thu, 29 Jan 2026 14:21:01 +0100 Subject: [PATCH 2/8] Add correct setup --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index eb52b4f..0c2039f 100644 --- a/composer.json +++ b/composer.json @@ -48,10 +48,10 @@ "extra": { "laravel": { "providers": [ - "Backstage\\Shop\\Contracts\\ShopContractsServiceProvider" + "Backstage\\Shop\\Support\\ShopContractsServiceProvider" ], "aliases": { - "AvailableCheckoutDrivers": "Backstage\\Shop\\Contracts\\Facades\\AvailableCheckoutDrivers" + "AvailableCheckoutDrivers": "Backstage\\Shop\\Support\\Facades\\AvailableCheckoutDrivers" } } }, From 17fa364aa3f4d0e8e38499736f332c0aebde4321 Mon Sep 17 00:00:00 2001 From: Manoj Hortulanus Date: Thu, 29 Jan 2026 15:23:22 +0100 Subject: [PATCH 3/8] Update stripe config --- src/Gateways/AbstractGateway.php | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 8aa78dd..c4e7ecb 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -2,12 +2,8 @@ namespace Backstage\Shop\Support\Gateways; -use Backstage\Shop\Checkout\PaymentResult; use Backstage\Shop\Support\Contracts\PaymentGateway; use Backstage\Shop\Support\Contracts\PaymentResult as PaymentResultContract; -use Backstage\Shop\Models\Customer; -use Backstage\Shop\Models\Order; -use Backstage\Shop\Models\Product; use Illuminate\Database\Eloquent\Model; abstract class AbstractGateway implements PaymentGateway @@ -67,6 +63,8 @@ abstract public function syncPrice(Model $product, int $amount, string $currency abstract public function listPrices(string $gatewayProductId): array; + abstract protected function createResult(string $id, string $status, int $amount, string $currency, array $rawData = [], ?string $redirectUrl = null, ?string $errorMessage = null): PaymentResultContract; + public function supports(string $feature): bool { return in_array($feature, $this->supportedFeatures); @@ -76,24 +74,4 @@ protected function getConfig(string $key, mixed $default = null): mixed { return $this->config[$key] ?? $default; } - - protected function createResult( - string $id, - string $status, - int $amount, - string $currency, - array $rawData = [], - ?string $redirectUrl = null, - ?string $errorMessage = null, - ): PaymentResultContract { - return new PaymentResult( - id: $id, - status: $status, - amount: $amount, - currency: $currency, - rawData: $rawData, - redirectUrl: $redirectUrl, - errorMessage: $errorMessage, - ); - } } From 2624b8008b0e7154b568138a4ffdee2699dba4b6 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Fri, 30 Jan 2026 13:04:28 +0100 Subject: [PATCH 4/8] Remove matrix in github workflows --- .github/workflows/run-tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b668642..6123d47 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,15 +20,15 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, windows-latest] - php: [8.4, 8.3] - laravel: [12.*, 11.*] - stability: [prefer-lowest, prefer-stable] + os: [ubuntu-latest] + php: [8.3] + laravel: [12.*] + stability: [prefer-stable] include: - laravel: 12.* testbench: 10.* - - laravel: 11.* - testbench: 9.* + carbon: 3.* + collision: 8.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} From fbe4480bab9b1609eb4ae9e9a61d0b78a439b53d Mon Sep 17 00:00:00 2001 From: Baspa <10845460+Baspa@users.noreply.github.com> Date: Mon, 2 Feb 2026 09:59:56 +0000 Subject: [PATCH 5/8] fix: styling --- src/Facades/AvailableCheckoutDrivers.php | 2 +- src/ShopContractsServiceProvider.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Facades/AvailableCheckoutDrivers.php b/src/Facades/AvailableCheckoutDrivers.php index f0e6754..f826efb 100644 --- a/src/Facades/AvailableCheckoutDrivers.php +++ b/src/Facades/AvailableCheckoutDrivers.php @@ -2,8 +2,8 @@ namespace Backstage\Shop\Support\Facades; -use Illuminate\Support\Facades\Facade; use Backstage\Shop\Support\CheckoutDriver; +use Illuminate\Support\Facades\Facade; /** * @method static CheckoutDriver setupDriver(string $driver, string $driverClass) diff --git a/src/ShopContractsServiceProvider.php b/src/ShopContractsServiceProvider.php index fb29f30..49dd03c 100644 --- a/src/ShopContractsServiceProvider.php +++ b/src/ShopContractsServiceProvider.php @@ -3,7 +3,6 @@ namespace Backstage\Shop\Support; use Spatie\LaravelPackageTools\Package; -use Backstage\Shop\Support\CheckoutDriver; use Spatie\LaravelPackageTools\PackageServiceProvider; class ShopContractsServiceProvider extends PackageServiceProvider From d38b34da6bc1fd5d14b613246a66313851d5f53a Mon Sep 17 00:00:00 2001 From: Baspa Date: Fri, 13 Mar 2026 09:49:39 +0100 Subject: [PATCH 6/8] chore: upgrade Laravel Pint to 1.29.0 and apply code style fixes Upgraded Pint from 1.27.1 to 1.29.0 to align local development with CI workflow. Applied new code style rules across 225 files including: - fully_qualified_strict_types - ordered_imports - braces_position - class_definition Co-Authored-By: Claude Opus 4.5 --- src/Contracts/PaymentGateway.php | 17 ++++++++++------- src/Facades/AvailableCheckoutDrivers.php | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Contracts/PaymentGateway.php b/src/Contracts/PaymentGateway.php index ab990d4..3a7e992 100644 --- a/src/Contracts/PaymentGateway.php +++ b/src/Contracts/PaymentGateway.php @@ -2,6 +2,9 @@ namespace Backstage\Shop\Support\Contracts; +use Backstage\Shop\Models\Customer; +use Backstage\Shop\Models\Order; +use Backstage\Shop\Models\Product; use Illuminate\Database\Eloquent\Model; interface PaymentGateway @@ -14,7 +17,7 @@ public function getName(): string; /** * Create a payment for an order. * - * @param \Backstage\Shop\Models\Order $order + * @param Order $order */ public function createPayment(Model $order, array $options = []): PaymentResult; @@ -31,7 +34,7 @@ public function refundPayment(string $paymentId, ?int $amount = null): PaymentRe /** * Create a customer in the payment gateway. * - * @param \Backstage\Shop\Models\Customer $customer + * @param Customer $customer */ public function createCustomer(Model $customer): string; @@ -78,7 +81,7 @@ public function getAvailablePaymentMethods(): array; /** * Create a product in the payment gateway. * - * @param \Backstage\Shop\Models\Product $product + * @param Product $product */ public function createProduct(Model $product): string; @@ -90,7 +93,7 @@ public function getProduct(string $gatewayProductId): ?array; /** * Update a product in the payment gateway. * - * @param \Backstage\Shop\Models\Product $product + * @param Product $product */ public function updateProduct(string $gatewayProductId, Model $product): bool; @@ -102,14 +105,14 @@ public function deleteProduct(string $gatewayProductId): bool; /** * Sync a product to the payment gateway (create or update). * - * @param \Backstage\Shop\Models\Product $product + * @param Product $product */ public function syncProduct(Model $product): string; /** * Create a price for a product in the payment gateway. * - * @param \Backstage\Shop\Models\Product $product + * @param Product $product */ public function createPrice(Model $product, int $amount, string $currency, array $options = []): string; @@ -131,7 +134,7 @@ public function archivePrice(string $gatewayPriceId): bool; /** * Sync a price to the payment gateway (create or update). * - * @param \Backstage\Shop\Models\Product $product + * @param Product $product */ public function syncPrice(Model $product, int $amount, string $currency, array $options = []): string; diff --git a/src/Facades/AvailableCheckoutDrivers.php b/src/Facades/AvailableCheckoutDrivers.php index f826efb..cf917c5 100644 --- a/src/Facades/AvailableCheckoutDrivers.php +++ b/src/Facades/AvailableCheckoutDrivers.php @@ -11,7 +11,7 @@ * @method static bool hasDriver(string $driver) * @method static string|null getDriver(string $driver) * - * @see \Backstage\Shop\Support\CheckoutDriver + * @see CheckoutDriver */ class AvailableCheckoutDrivers extends Facade { From 14a89b06edd80691307a0ac3f7c84233f33ba2c7 Mon Sep 17 00:00:00 2001 From: Manoj Hortulanus Date: Mon, 22 Jun 2026 11:05:49 +0200 Subject: [PATCH 7/8] chore: migrate branding to backstagephp.com Update author emails, seeders, mail tests, LICENSE and SECURITY docs from ux.nl/vormkracht10.nl to backstagephp.com across packages. Co-Authored-By: Claude Opus 4.8 (1M context) --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index 0c2039f..d768a0e 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,11 @@ "homepage": "https://github.com/backstage/shop-support", "license": "MIT", "authors": [ + { + "name": "Mark van Eijk", + "email": "mark@backstagephp.com", + "role": "Owner & Developer" + }, { "name": "Manoj Hortulanus", "email": "manoj@backstagephp.com", From bd03267c6658e86fe76b68df96278eda3c5dab3e Mon Sep 17 00:00:00 2001 From: Mathieu Date: Tue, 7 Jul 2026 15:54:45 +0200 Subject: [PATCH 8/8] ci: fix the Security workflow (pin actions, dependabot cooldown, real security-check gate) (#279) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(ci): pin GitHub Actions to commit SHAs across the monorepo Pin every `uses:` reference to a full commit SHA (with a version comment so Dependabot keeps them current) across the root workflows and all packages/*/.github workflows. Resolves the semgrep github-actions-mutable-action-tag findings. Applied with pinact. Co-Authored-By: Claude Opus 4.8 (1M context) * chore(ci): add a 7-day Dependabot cooldown to every update entry Add `cooldown: { default-days: 7 }` to each ecosystem in every dependabot.yml across the monorepo (and normalise the one pre-existing cooldown to 7 days). Resolves the semgrep dependabot-missing-cooldown findings and delays pulling freshly-published (possibly compromised) releases. Co-Authored-By: Claude Opus 4.8 (1M context) * fix(security-check): treat empty $guarded as a warning, not a failure Backstage's 17 core models deliberately use `$guarded = []` because writes go through validated Filament admin forms, not raw request mass assignment. The security check flagged all of them as a high-severity failure — a false positive relative to the architecture. Split the mass-assignment check so empty $guarded is a medium warning while sensitive fields in $fillable remain a hard failure. Add a Pest test asserting `backstage:security-check --package-only` exits 0, and record the decision in ADR-0003. Co-Authored-By: Claude Opus 4.8 (1M context) * chore(ci): pin actions pinact could not auto-resolve, add pinact config Three pint.yml refs pointed at non-existent tags (laravel-pint-action @latest / @2.4.0, git-auto-commit-action @v5.0) that pinact could not resolve; pin them to valid release SHAs by hand. Add .pinact.yaml so both the one-shot pin and the CI guard cover packages/*/.github workflows, not just the root. Co-Authored-By: Claude Opus 4.8 (1M context) * ci(security): gate on the security check, add an action-pinning guard The Backstage Security Check job never actually ran: this is a package repo with no `artisan` binary, and it passed a non-existent `--ci` flag, all masked by continue-on-error. Run it through the test harness instead (a Pest test that boots the full provider stack), mirroring the run-tests MySQL service + extensions + DB env, and drop continue-on-error so it genuinely gates CI. Add an Action Pinning job (pinact-action, fix disabled) that fails when any workflow reintroduces an unpinned action. Co-Authored-By: Claude Opus 4.8 (1M context) --------- Co-authored-by: Claude Opus 4.8 (1M context) --- .github/workflows/run-tests.yml | 4 ++-- .github/workflows/update-changelog.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6123d47..de66992 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -34,10 +34,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - name: Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 with: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml index 277821c..91d8d81 100644 --- a/.github/workflows/update-changelog.yml +++ b/.github/workflows/update-changelog.yml @@ -14,18 +14,18 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 with: ref: main - name: Update Changelog - uses: stefanzweifel/changelog-updater-action@v1 + uses: stefanzweifel/changelog-updater-action@a938690fad7edf25368f37e43a1ed1b34303eb36 # v1.12.0 with: latest-version: ${{ github.event.release.name }} release-notes: ${{ github.event.release.body }} - name: Commit updated CHANGELOG - uses: stefanzweifel/git-auto-commit-action@v7 + uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0 with: branch: main commit_message: Update CHANGELOG