https://github.com/spinen/laravel-quickbooks-client
SPINEN's Laravel Client for QuickBooks.
https://github.com/spinen/laravel-quickbooks-client
api api-client client laravel quickbooks spinen
Last synced: 6 months ago
JSON representation
SPINEN's Laravel Client for QuickBooks.
- Host: GitHub
- URL: https://github.com/spinen/laravel-quickbooks-client
- Owner: spinen
- Created: 2018-03-21T03:24:36.000Z (about 8 years ago)
- Default Branch: develop
- Last Pushed: 2024-06-05T18:50:02.000Z (about 2 years ago)
- Last Synced: 2025-10-20T23:56:56.358Z (8 months ago)
- Topics: api, api-client, client, laravel, quickbooks, spinen
- Language: PHP
- Homepage: https://spinen.com
- Size: 88.9 KB
- Stars: 47
- Watchers: 8
- Forks: 70
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SPINEN's Laravel QuickBooks Client
[](https://packagist.org/packages/spinen/laravel-quickbooks-client)
[](https://packagist.org/packages/spinen/laravel-quickbooks-client)
[](https://packagist.org/packages/spinen/laravel-quickbooks-client)
[](https://packagist.org/packages/spinen/laravel-quickbooks-client)
PHP client wrapping the [QuickBooks PHP SDK](https://github.com/intuit/QuickBooks-V3-PHP-SDK).
We solely use [Laravel](https://www.laravel.com) for our applications, so this package is written with Laravel in mind. If there is a request from the community to split this package into 2 parts to allow it to be used outside of Laravel, then we will consider doing that work.
## Build Status
| Branch | Status | Coverage | Code Quality |
| ------ | :----: | :------: | :----------: |
| Develop | [](https://github.com/spinen/laravel-quickbooks-client/workflows/CI/badge.svg?branch=develop) | [](https://scrutinizer-ci.com/g/spinen/laravel-quickbooks-client/?branch=develop) | [](https://scrutinizer-ci.com/g/spinen/laravel-quickbooks-client/?branch=develop) |
| Master | [](https://github.com/spinen/laravel-quickbooks-client/workflows/CI/badge.svg?branch=master) | [](https://scrutinizer-ci.com/g/spinen/laravel-quickbooks-client/?branch=master) | [](https://scrutinizer-ci.com/g/spinen/laravel-quickbooks-client/?branch=master) |
## Installation
1. Install QuickBooks PHP Client:
```bash
$ composer require spinen/laravel-quickbooks-client
```
2. Run our migration to install the `quickbooks_tokens` table:
```bash
$ php artisan migrate --package=spinen/laravel-quickbooks-client
```
The package uses the [auto registration feature](https://laravel.com/docs/packages#package-discovery) of Laravel.
## Configuration
1. You will need a ```quickBooksToken``` relationship on your ```User``` model. There is a trait named ```Spinen\QuickBooks\HasQuickBooksToken```, which you can include on your ```User``` model, which will setup the relationship. To do this implement the following:
Add ```use Spinen\QuickBooks\HasQuickBooksToken;``` to your service container at the top of User.php
and also add the trait within the class. For example:
```php
class User extends Authenticatable
{
use Notifiable, HasQuickBooksToken;
```
**NOTE: If your ```User``` model is not ```App\Models\User```, then you will need to configure the path in the ```configs/quickbooks.php```.**
2. Add the appropriate values to your ```.env```
#### Minimal Keys
```bash
QUICKBOOKS_CLIENT_ID=
QUICKBOOKS_CLIENT_SECRET=
```
#### Optional Keys
```bash
QUICKBOOKS_API_URL= # Defaults to App's env value
QUICKBOOKS_DEBUG= # Defaults to App's debug value
```
3. _[Optional]_ Publish configs & views
#### Config
A configuration file named ```quickbooks.php``` can be published to ```config/``` by running...
```bash
php artisan vendor:publish --tag=quickbooks-config
```
#### Views
View files can be published by running...
```bash
php artisan vendor:publish --tag=quickbooks-views
```
## Usage
Here is an example of getting the company information from QuickBooks:
### NOTE: Before doing these commands, go to your connect route (default: /quickbooks/connect) to get a QuickBooks token for your user
```php
php artisan tinker
Psy Shell v0.8.17 (PHP 7.1.14 — cli) by Justin Hileman
>>> Auth::logInUsingId(1)
=> App\Models\User {#1668
id: 1,
// Other keys removed for example
}
>>> $quickbooks = app('Spinen\QuickBooks\Client') // or app('QuickBooks')
=> Spinen\QuickBooks\Client {#1613}
>>> $quickbooks->getDataService()->getCompanyInfo();
=> QuickBooksOnline\API\Data\IPPCompanyInfo {#1673
+CompanyName: "Sandbox Company_US_1",
+LegalName: "Sandbox Company_US_1",
// Other properties removed for example
}
>>>
```
You can call any of the resources as documented [in the SDK](https://intuit.github.io/QuickBooks-V3-PHP-SDK/quickstart.html).
## Middleware
If you have routes that will be dependent on the user's account having a usable QuickBooks OAuth token, there is an included middleware ```Spinen\QuickBooks\Laravel\Filter``` that gets registered as ```quickbooks``` that will ensure the account is linked and redirect them to the `connect` route if needed.
Here is an example route definition:
```php
Route::view('some/route/needing/quickbooks/token/before/using', 'some.view')
->middleware('quickbooks');
```