PHPackages                             ajay-patidar/laravel-quickbooks - 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. ajay-patidar/laravel-quickbooks

ActiveLibrary[API Development](/categories/api)

ajay-patidar/laravel-quickbooks
===============================

Laravel Quickbooks integration

041PHPCI failing

Since Jun 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ajay-patidar/laravel-quickbooks)[ Packagist](https://packagist.org/packages/ajay-patidar/laravel-quickbooks)[ RSS](/packages/ajay-patidar-laravel-quickbooks/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-quickbooks
==================

[](#laravel-quickbooks)

Installation
------------

[](#installation)

Via Composer

```
$ composer require ajay-patidar/laravel-quickbooks
```

Publish package and run migrations

```
$ php artisan vendor:publish --provider="AjayPatidar\LaravelQuickBooks\LaravelQuickBooksServiceProvider" --tag="quickbooks.config"
$ php artisan migrate
```

Usage
-----

[](#usage)

### Configuration

[](#configuration)

These are the variables you need to set in your .env.

```
# Client ID from the app's keys tab.
QB_CLIENT_ID=

# Client Secret from the app's keys tab.
QB_CLIENT_SECRET=

# The redirect URI provided on the Redirect URIs part under keys tab.
QB_REDIRECT_URI=

# Quickbooks scope com.intuit.quickbooks.accounting or com.intuit.quickbooks.payment
QB_SCOPE=

# Development/Production
QB_BASE_URL=

```

### Token Handling

[](#token-handling)

Since every application is setup differently, you will need to create a class that extends `QuickBooksTokenHandler` to persist the tokens in your database. By default, the tokens are stored using the Laravel Cache API for 7 days.

For example, if you use the [Laravel Options](https://github.com/appstract/laravel-options) package you would create the following class somewhere in your project:

```
namespace App\QuickBooks;

use AjayPatidar\LaravelQuickBooks\QuickBooksTokenHandler;

class TokenHandler extends QuickBooksTokenHandler
{
    public function set($key, $value)
    {
        option([$key => $value]);
    }

    public function get($key)
    {
        return option($key);
    }
}
```

Then bind it in your `AppServiceProvider.php`:

```
public function boot()
{
    $this->app->bind(
        \AjayPatidar\LaravelQuickBooks\QuickBooksTokenHandlerInterface::class,
        \App\QuickBooks\TokenHandler::class
    );
}
```

### Connect QuickBooks account

[](#connect-quickbooks-account)

To connect your application with your QuickBooks company you can use `QuickBooksAuthenticator` helper. It has two methods:

- `getAuthorizationUrl()` - Returns redirect URL and puts `quickbooks_auth` cookie into Laravel cookie queue. Cookie is valid for 30 minutes.
- `processHook()` - Validates `quickbooks_auth` cookie and sets realm id, access token and refresh token.

Usage example:

```
namespace App\Http\Controllers;

use AjayPatidar\LaravelQuickBooks\QuickBooksAuthenticator;
use Cookie;

class QuickBooksController extends Controller
{
    public function connect()
    {
        return redirect(QuickBooksAuthenticator::getAuthorizationUrl())
            ->withCookies(Cookie::getQueuedCookies());
    }

    public function refreshTokens()
    {
        if (QuickBooksAuthenticator::processHook()) {
            return 'Tokens successfully refreshed.';
        }

        return 'There were some problems refreshing tokens.';
    }
}
```

### Sync Eloquent model to QuickBooks

[](#sync-eloquent-model-to-quickbooks)

You can either extend the `AjayPatidar\LaravelQuickBooks\QuickBooksEntity` class which is already extending the Eloquent model or you can use the `AjayPatidar\LaravelQuickBooks\SyncsToQuickBooks` trait.

Then you have to define:

- `quickBooksResource` - One of the QuickBooks resources classes (e.g.. `\AjayPatidar\LaravelQuickBooks\Resources\Company::class`).
- `getQuickBooksArray()` - This method must return the associative array which will be synced to QuickBooks.
- `quickBooksIdColumn` (optional) - The column to use for storing the QuickBooks ID (defaults to `quickbooks_id`)

Usage example:

```
namespace App\Models\Company;

use AjayPatidar\LaravelQuickBooks\QuickBooksEntity;
use AjayPatidar\LaravelQuickBooks\Resources\Customer;

class Company extends QuickBooksEntity
{
    /**
     * Database column name
     * This is optional default value is 'quickbooks_id'
     * @var string
     */
    protected $quickBooksIdColumn = 'quickbooks_id';

    /**
     * Use one of AjayPatidar\LaravelQuickBooks\Resources classes
     * @var array
     */
    protected $quickBooksResource = Customer::class;

    /**
     * @return array
     */
    protected function getQuickBooksArray(): array
    {
        return [
            'CompanyName'  => 'Example name',
            'DisplayName'  => 'Example display name',
            //...
        ];
    }
}
```

When you want to sync a resource you must call `syncToQuickBooks()`. Method returns true if syncing is successful. You can get last QuickBooks error with method `getLastQuickBooksError()`.

Syncing example:

```
/**
 * @return string
 * @throws \Exception
 */
public function syncExample()
{
    $company = Company::find(1);
    if ($company->syncToQuickBooks()){
        return 'Success';
    }
    return $company->getLastQuickBooksError();
}
```

### Using the QuickBooks Resource Classes

[](#using-the-quickbooks-resource-classes)

You can use the included resource classes in `AjayPatidar\LaravelQuickBooks\Resources` to create, update, and query resources from QuickBooks.

Examples:

```
$customer = new AjayPatidar\LaravelQuickBooks\Resources\Customer;

// create
$customer->create([
    'GivenName'  => 'John',
    'FamilyName' => 'Smith',
]);

// update item with ID "123"
$customer->update(123, [
    'GivenName'  => 'John',
    'FamilyName' => 'Smith',
]);

// find by ID:
$customer->find(123);

// find by a specific field:
$customer->findBy('FamilyName', 'Smith');

// find multiple items:
$customer->query();

```

See `QuickBooksResource.php` for further documentation.

Security
--------

[](#security)

If you discover any security related issues, please email author instead of using the issue tracker.

Credits
-------

[](#credits)

- [LifeOnScreen](https://github.com/LifeOnScreen)

License
-------

[](#license)

MIT license. Please see the [license file](license.md) for more information.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2856600?v=4)[ajaypatidar](/maintainers/ajaypatidar)[@ajaypatidar](https://github.com/ajaypatidar)

---

Top Contributors

[![ajay-patidar](https://avatars.githubusercontent.com/u/5493868?v=4)](https://github.com/ajay-patidar "ajay-patidar (3 commits)")

### Embed Badge

![Health badge](/badges/ajay-patidar-laravel-quickbooks/health.svg)

```
[![Health](https://phpackages.com/badges/ajay-patidar-laravel-quickbooks/health.svg)](https://phpackages.com/packages/ajay-patidar-laravel-quickbooks)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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