Skip to content

Commit

Permalink
Minor adjustments for v3 (#13)
Browse files Browse the repository at this point in the history
* Require composer-normalize

* Add CI for normalize

* Use ergebnis/composer-normalize

* Update test matrix

* Cleanup test.yaml

* Test odd exclude/include rules

* Update readme
  • Loading branch information
olssonm authored Aug 12, 2024
1 parent 6dfe278 commit 846a8a2
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 68 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]"

- 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
37 changes: 0 additions & 37 deletions .github/workflows/test.yml

This file was deleted.

File renamed without changes.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:

Expand All @@ -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:
Expand Down
56 changes: 29 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand All @@ -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"
Expand All @@ -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"
}
}

0 comments on commit 846a8a2

Please sign in to comment.