diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..8edef45 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,71 @@ +name: Run tests + +on: [push, pull_request] + +jobs: + coding-standards: + name: "Coding Standards" + + runs-on: "ubuntu-latest" + + strategy: + matrix: + php: + - "8.3" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4.1.7" + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Update composer + run: composer self-update --2 + + - name: "Install dependencies" + run: "composer install --no-interaction --no-progress" + + - name: "Run normalize" + run: "composer normalize --dry-run" + + tests: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, ubuntu-20.04] + laravel: + - 11.* + php: + - 8.2 + - 8.3 + dependency-version: [prefer-stable] + exclude: + - os: ubuntu-20.04 + include: + - os: ubuntu-20.04 + laravel: 10.* + php: 8.1 + + name: PHP ${{ matrix.php }} / Laravel ${{ matrix.laravel }} (${{ matrix.os }}) + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Update composer + run: composer self-update --2 + + - name: Install dependencies + run: composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-progress + + - name: Execute tests + run: composer test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index ef00cf5..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Run tests - -on: [push, pull_request] - -jobs: - php-tests: - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [ubuntu-latest,ubuntu-20.04] - php: [8.1,8.2,8.3] - laravel: [11.*, 10.*] - dependency-version: [prefer-stable] - exclude: - - laravel: 11.* - php: 8.1 - - name: ${{ matrix.os }}, PHP ${{ matrix.php }} / Laravel ${{ matrix.laravel }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - - name: Update composer - run: composer self-update --2 - - - name: Install dependencies - run: composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-progress - - - name: Execute tests - run: composer test diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yaml similarity index 100% rename from .github/workflows/update-changelog.yml rename to .github/workflows/update-changelog.yaml diff --git a/README.md b/README.md index 11385e8..a4554db 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,16 @@ [![Supported PHP-versions](https://img.shields.io/packagist/php-v/olssonm/swish-php?style=flat-square)](https://packagist.org/packages/olssonm/swish-php) [![Latest Version on Packagist](https://img.shields.io/packagist/v/olssonm/swish-php.svg?style=flat-square)](https://packagist.org/packages/olssonm/swish-php) -[![Build Status](https://img.shields.io/github/actions/workflow/status/olssonm/swish-php/test.yml?branch=main&style=flat-square)](https://github.com/olssonm/swish-php/actions?query=workflow%3A%22Run+tests%22) +[![Build Status](https://img.shields.io/github/actions/workflow/status/olssonm/swish-php/test.yaml?branch=main&style=flat-square)](https://github.com/olssonm/swish-php/actions?query=workflow%3A%22Run+tests%22) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) A simple and easy to use wrapper for the Swish-API in PHP. Also includes providers and facades for quick setup with Laravel. ## Prerequisites -This package supports PHP ^8.1, as well as Laravel 7 and up to the latest version. PHP needs to be compiled with the cURL and SSL extensions (in an absolute majority of cases, they should be available by default). +This package supports PHP ^8.1. Tested against Laravel 10 & 11. PHP needs to be compiled with the cURL and SSL extensions (in an absolute majority of cases, they should be available by default). -*Using PHP 7.4 or 8.0? v1.0 has support for these.* +*Using an older version of PHP or Laravel? Check out v1 and v2 of this package.* ## Installation @@ -23,7 +23,7 @@ composer require olssonm/swish-php You will need to have access to your Swish-certificates to use this package in production. You can however use their testing/Merchant Swish Similator-environment without being a Swish-customer during development. -Read more about testing in their MSS-environment in their [official documentation](https://developer.swish.nu/documentation/environments#:~:text=the%20certificate%20again.-,Merchant%20Swish%20Simulator,-The%20Swish%20server). A quick rundown on using/creating Swish-certificates [is published here](https://marcusolsson.me/artiklar/hur-man-skapar-certifikat-for-swish) (in Swedish). +Read more about testing in their MSS-environment in their [official documentation](https://developer.swish.nu/documentation/environments#merchant-swish-simulator). A quick rundown on using/creating Swish-certificates [is published here](https://marcusolsson.me/artiklar/hur-man-skapar-certifikat-for-swish) (in Swedish). When creating the client, you will have to set which environment you are working with (otherwise it defaults to the production environment, `https://cpc.getswish.net/swish-cpcapi/api/`), you may use `Client::TEST_ENDPOINT` and `Client::PRODUCTION_ENDPOINT` for this: @@ -41,6 +41,9 @@ $certificate = new Certificate( $client = new Client($certificate, $endpoint = Client::TEST_ENDPOINT) ``` +> [!IMPORTANT] +> The paths to the certificates should be absolute. You can use `realpath -s YOUR_CERT.pem` for this. + ### Laravel With the Laravel service provider and facades you can work with the package more eloquently. Just require the package and publish the configuration: diff --git a/composer.json b/composer.json index 24a1ab9..e8b4371 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "name": "olssonm/swish-php", "description": "Swish API-wrapper. Compatible with Laravel", - "homepage": "https://github.com/olssonm/swish-php", "license": "MIT", "authors": [ { @@ -10,19 +9,27 @@ "homepage": "https://marcusolsson.me" } ], + "homepage": "https://github.com/olssonm/swish-php", "require": { "php": "^8.1", - "guzzlehttp/guzzle": "^6.3.1|^7.0", - "ramsey/uuid": "^4.2", - "nesbot/carbon": "^2|^3" + "guzzlehttp/guzzle": "^6.3.1 || ^7.0", + "nesbot/carbon": "^2 || ^3", + "ramsey/uuid": "^4.2" }, "require-dev": { - "phpunit/phpunit": "^8.3 || ^9.3 || ^10.0", + "ergebnis/composer-normalize": "^2.43", "orchestra/testbench": "^8.0 || ^9.0", - "squizlabs/php_codesniffer": "^3.5", "pestphp/pest": "^1.0 || ^2.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8.3 || ^9.3 || ^10.0", + "squizlabs/php_codesniffer": "^3.5" }, + "suggest": { + "illuminate/contracts": "Required to use the Laravel integration (^10.0|^11.0).", + "illuminate/support": "Required to use the Laravel integration (^10.0|^11.0)." + }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "Olssonm\\Swish\\": "src" @@ -33,35 +40,30 @@ "Olssonm\\Swish\\Test\\": "tests" } }, - "scripts": { - "test": "./vendor/bin/pest", - "phpstan": "./vendor/bin/phpstan", - "coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage", - "phpsniff": "vendor/bin/phpcs --standard=\"PSR12\" ./src", - "phpfix": "vendor/bin/phpcbf --standard=\"PSR12\" ./src" + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true, + "pestphp/pest-plugin": true + } }, "extra": { "branch-alias": { "dev-main": "3.0.x-dev" }, "laravel": { - "providers": [ - "Olssonm\\Swish\\Providers\\SwishServiceProvider" - ], "aliases": { "Swish": "Olssonm\\Swish\\Facades\\Swish" - } - } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "config": { - "allow-plugins": { - "pestphp/pest-plugin": true + }, + "providers": [ + "Olssonm\\Swish\\Providers\\SwishServiceProvider" + ] } }, - "suggest":{ - "illuminate/contracts": "Required to use the Laravel integration (^10.0|^11.0).", - "illuminate/support": "Required to use the Laravel integration (^10.0|^11.0)." + "scripts": { + "coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage", + "phpfix": "vendor/bin/phpcbf --standard=\"PSR12\" ./src", + "phpsniff": "vendor/bin/phpcs --standard=\"PSR12\" ./src", + "phpstan": "./vendor/bin/phpstan", + "test": "./vendor/bin/pest" } }