Laravel Quickbooks is a token manager and wrapper for the QuickBooks PHP SDK. See Quickbooks API Reference for more details on how to interact with the API.
Version | |
---|---|
PHP | ^8.1 |
Laravel | ^9.0 |
You can install the package via composer:
composer require shawnreid/laravel-quickbooks
Publish assets
php artisan vendor:publish --provider="Shawnreid\LaravelQuickbooks\Providers\QuickbooksProvider"
Create database table quickbooks_tokens
php artisan migrate
-
Before starting you will need a QuickBooks developer account to setup a sandbox environment. You will also need a tool such as ngrok to expose your local dev environment.
-
Quickbooks requires a Redirect URI be provided for OAuth2 authentication. You must set this to:
https://<your_url>/quickbooks/token
-
Add the appropriate values to your
.env
QUICKBOOKS_CLIENT_ID=<Client ID> QUICKBOOKS_CLIENT_SECRET=<Client Secret> QUICKBOOKS_API_URL=<Development|Production> QUICKBOOKS_DEBUG=<true|false>
-
By default this package will attach to the
User
Model. If you wish to use another model this can be configured inconfigs/laravel-quickbooks.php
. A trait will need to be included in the model you wish to use.Example:
use Shawnreid\LaravelQuickbooks\Quickbooks; class User extends Authenticatable { use Quickbooks;
-
The token manager middleware by default is set to
auth
. Depending on your needs you will likely want to change this. This can be configured inconfigs/laravel-quickbooks.php
This package provides a simple interface for managing quickbooks OAuth2 connections.
- Navigate to
https://<your_url>/quickbooks
- Select model you want to attach connection to and click
Create Connection
. If configured properly you will be redirected to a QuickBooks authentication page.
You may also revoke tokens or refresh tokens from this interface. Note that anytime an API call is made to QuickBooks this package will automatically refresh the token.
This package provides syntatic sugar to wrap QuickBooks PHP SDK. Please see QuickBooks Sample CRUD App for additional examples.
$user = User::find(1);
$user
// resolve data service
->quickbooks()
// resolve invoice entity
->invoice()
// create invoice
->create(
body: [...]
)
$user
// resolve data service
->quickbooks()
// resolve customer entity
->customer()
// update customer
->update(
id: 'id'
body: [...]
)
$user
// resolve data service
->quickbooks()
// resolve bill entity
->bill()
// delete bill
->delete(
id: 'id'
)
$user
// resolve data service
->quickbooks()
// resolve vendor entity
->vendor()
// find vendor
->find(
id: 'id'
)
$user
// resolve data service
->quickbooks()
// Custom SQL query
// https://developer.intuit.com/app/developer/qbo/docs/learn/explore-the-quickbooks-online-api/data-queries
->query('SELECT * FROM Invoice')
$user->quickbooks()->account();
$user->quickbooks()->bill();
$user->quickbooks()->billPayment();
$user->quickbooks()->customer();
$user->quickbooks()->estimate();
$user->quickbooks()->invoice();
$user->quickbooks()->item();
$user->quickbooks()->journalEntry();
$user->quickbooks()->payment();
$user->quickbooks()->timeActivity();
$user->quickbooks()->vendor();
$user->quickbooks()->vendorCredit();
$user->quickbooks()->companyCurrency();
$user->quickbooks()->creditMemo();
$user->quickbooks()->department();
$user->quickbooks()->deposit();
$user->quickbooks()->employee();
$user->quickbooks()->purchase();
$user->quickbooks()->purchaseOrder();
$user->quickbooks()->refundReceipt();
$user->quickbooks()->salesReceipt();
$user->quickbooks()->taxAgency();
$user->quickbooks()->taxRate();
$user->quickbooks()->taxService();
$user->quickbooks()->transfer();
$user->quickbooks()->invoice()->create([...]);
$user->quickbooks()->invoice()->update('id', [...]);
$user->quickbooks()->invoice()->delete('id');
$user->quickbooks()->invoice()->find('id');
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.