shawnreid / laravel-quickbooks
Quickbooks wrapper for Laravel
Requires
- php: ^8.1
- illuminate/database: ^9.0
- illuminate/http: ^9.0
- illuminate/routing: ^9.0
- illuminate/support: ^9.0
- nesbot/carbon: ^2.0
- quickbooks/v3-php-sdk: ^6.1.0
Requires (Dev)
- laravel/pint: ^1.4
- nunomaduro/larastan: ^2.4
- orchestra/testbench: ^7.1
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-16 06:44:55 UTC
README
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.
Requirements
Installation
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
Configuration
-
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
Connecting to Quickbooks
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.
Usage
This package provides syntatic sugar to wrap QuickBooks PHP SDK. Please see QuickBooks Sample CRUD App for additional examples.
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')
Supported Entities
$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();
Supported CRUD Operations
$user->quickbooks()->invoice()->create([...]); $user->quickbooks()->invoice()->update('id', [...]); $user->quickbooks()->invoice()->delete('id'); $user->quickbooks()->invoice()->find('id');
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.