PHPackages                             iamfredric/fortnox - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. iamfredric/fortnox

ActiveLibrary[API Development](/categories/api)

iamfredric/fortnox
==================

Fortnox api integration

0.0.5(4y ago)01.5kMITPHPPHP ^8.0CI failing

Since Mar 29Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/iamfredric/fortnox)[ Packagist](https://packagist.org/packages/iamfredric/fortnox)[ RSS](/packages/iamfredric-fortnox/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

Fortnox
=======

[](#fortnox)

This package is a wrapper for the Fortnox API.

### Requirements

[](#requirements)

php ^8.0 Fortnox developer account

### Installation

[](#installation)

```
composer reqiure "iamfredric/fortnox"

```

### Configuration

[](#configuration)

```
\Iamfredric\Fortnox\Fortnox::setClientCredentials(
    clientId: 'your-app-client-id',
    clientSecret: 'your-app-client-secret',
    redirectUrl: 'http://your-app-url/fortnox/callback',
    scope: 'your scopes separated by spaces'
);
```

#### Authenticate user

[](#authenticate-user)

```
// Redirect user to Fortnox for authentication
$url = \Iamfredric\Fortnox\Fortnox::authUrl();

// In your response handler, when fortnox redirects user back to your app,
$response = \Iamfredric\Fortnox\Fortnox::verifyAuthCode($_GET['code']);
$response['access_token'];
$response['refresh_token'];
$response['scope'];
$response['expires_in'];
$response['token_type'];
```

#### Working with resources

[](#working-with-resources)

Before you can use the resources, you need to authenticate the user.

```
// You need to pass an object that implements \Iamfredric\Fortnox\Contracts\Authenticatable
// to the authenticateAs method. This object will be used to get the access token and refresh
// your access token when it expires.
\Iamfredric\Fortnox\Fortnox::authenticateAs(new class implements \Iamfredric\Fortnox\Contracts\Authenticatable {
    public function getFortnoxAccessToken(): string
    {
        return 'your-access-token';
    }

    public function getFortnoxRefreshToken(): string
    {
        return 'your-refresh-token';
    }

    public function getFortnoxExpiresAt(): DateTime
    {
        return new DateTime('Expiration date for token');
    }

    public function onFortnoxUpdate($data): void
    {
        // Update your database with the new access token and refresh token
    }
});
```

##### Get all customers

[](#get-all-customers)

```
use \Iamfredric\Fortnox\Resources\Customer;

$customers = Customer::all()

foreach ($customers as $customer) {
    /**  @var $customer Customer */
}
```

##### Get a customer

[](#get-a-customer)

```
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::find(1);
```

##### Create a customer

[](#create-a-customer)

```
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::create([
    'Name' => 'Acme INC'
]);
```

##### Update a customer

[](#update-a-customer)

```
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::find(1);
// Or
$customer = new Customer([
    "CustomerNumber" => "1",
])

$customer->update([
    'Name' => 'Acme INC';
])
// Or
$customer->Name = 'Acme INC';
$customer->save();
```

##### Delete a customer

[](#delete-a-customer)

```
use \Iamfredric\Fortnox\Resources\Customer;

$customer = Customer::find(1);

$customer->delete();
```

---

### Extending current package

[](#extending-current-package)

```
class Order extends \Iamfredric\Fortnox\Resources\Resource
{
    protected function getIdKey(): string
    {
        return 'DocumentNumber';
    }
}

Order::all();
$order = Order::find(1);
$order->update([]);
$order->save();
$order->delete();
```

Testing
-------

[](#testing)

```
composer run test
composer run analyze
composer run sniff
```

Contributing
------------

[](#contributing)

Contributing
============

[](#contributing-1)

Contributions are **welcome**.

Procedure
---------

[](#procedure)

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

Requirements
------------

[](#requirements-1)

If the project maintainer has any additional requirements, you will find them listed here.

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

**Happy coding**!

License
-------

[](#license)

The MIT License (MIT).

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.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance54

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

1506d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/118cd33ebbd3560bc197564b00ce7fd091944bb78111a7c5db4e867e0f8f2118?d=identicon)[iamfredric](/maintainers/iamfredric)

---

Top Contributors

[![iamfredric](https://avatars.githubusercontent.com/u/3515553?v=4)](https://github.com/iamfredric "iamfredric (11 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/iamfredric-fortnox/health.svg)

```
[![Health](https://phpackages.com/badges/iamfredric-fortnox/health.svg)](https://phpackages.com/packages/iamfredric-fortnox)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
