mirror of
https://github.com/wearepixel/laravel-quickbooks.git
synced 2026-11-14 14:01:46 +00:00
32266f6dd56adb836e03b60a51d5e5be7b97ece2
v2.0.1's useJson() workaround was wrong: the JSON request serializer silently drops nested single-object fields (e.g. CustomerRef, which QuickBooks requires), and the JSON response deserializer never returns a typed entity, so $result->Id is always null downstream. That breaks every dsCall() site, worse than the bug it was meant to fix. The actual root cause was that quickbooks/v3-php-sdk 5.4.7 predates QuickBooks Online's new invoice AllowOnlinePayPalPayment field, so its XML deserializer throws on responses that include it. SDK 6.3.1 declares the field, so upgrading resolves the original error while keeping the fully-supported XML path (and closes out the SDK bump Dependabot already had queued in #3). Verified: deserializing a response containing AllowOnlinePayPalPayment throws RuntimeException on 5.4.7 and returns a correctly typed IPPInvoice (with Id populated) on 6.3.1.
Laravel QuickBooks Client
A Laravel package wrapping the QuickBooks PHP SDK. Provides OAuth 2.0 authentication, automatic token management, and access to the QuickBooks Online API.
Compatibility
| Laravel | PHP | Package |
|---|---|---|
| 12.x | ^8.3 | ^2.0 |
| 11.x | ^8.3 | ^2.0 |
| 10.x | ^8.3 | ^1.0 |
Installation
- Install the package:
composer require wearepixel/laravel-quickbooks
- Run the migration to create the
quickbooks_tokenstable:
php artisan migrate
The package uses Laravel's auto-discovery, so no manual provider registration is needed.
Configuration
1. Add the trait to your User model
use Wearepixel\QuickBooks\HasQuickBooksToken;
class User extends Authenticatable
{
use HasQuickBooksToken;
}
If your User model is not App\Models\User, publish the config and update the user.model value.
2. Set your environment variables
QUICKBOOKS_CLIENT_ID=<your client id>
QUICKBOOKS_CLIENT_SECRET=<your client secret>
Optional:
QUICKBOOKS_API_URL=<Development|Production> # Defaults based on APP_ENV
QUICKBOOKS_DEBUG=<true|false> # Defaults to APP_DEBUG
3. Publish config and views (optional)
php artisan vendor:publish --tag=quickbooks-config
php artisan vendor:publish --tag=quickbooks-views
Usage
First, direct users to /quickbooks/connect to authorize their QuickBooks account. Once connected, you can access the API:
$quickbooks = app(\Wearepixel\QuickBooks\Client::class);
// Get company info
$company = $quickbooks->getDataService()->getCompanyInfo();
// Access reports
$reportService = $quickbooks->getReportService();
You can call any of the resources documented in the QuickBooks PHP SDK.
Middleware
Protect routes that require a QuickBooks connection using the quickbooks middleware. Users without a valid token will be redirected to the connect page.
Route::get('quickbooks/invoices', InvoiceController::class)
->middleware('quickbooks');
Testing
./vendor/bin/pest
License
MIT
Languages
PHP
96.8%
Blade
3.2%