- Manage different connections (credentials)
- Store tokens in the database
- Refresh token automatically
- Functionality for tokens acquiring
- Webhooks management
- Api SDK included
- Logging
composer require hotrush/quickbooks-manager
You have to migrate the database
php artisan migrate
Also you can publish config file
php artisan vendor:publish --provider="Hotrush\QuickBooksManager\QuickBooksManagerServiceProvider" --tag="config"
To redirect to OAuth authorization page use qbm.redirect
route e.g.:
redirect(route('qbm.redirect', ['connection' => 'default']));
On successful auth token will be stored in the database and used automatically for API requests. You can configure redirect-back route for success authorization in config file changing redirect_route
option.
When token received you can use connection manager to send api requests. To get manager instance you can use laravel's container resolving stuff and resolve for Hotrush\QuickBooksManager\QuickBooksManager
class.
Then just get needed connection and send request.
$invoiceToCreate = Invoice::create([...]);
$manager = resolve(\Hotrush\QuickBooksManager\QuickBooksManager::class);
$manager->connection('default')->Add($invoiceToCreate);
Each connection has it's own webhook endpoint e.g.
/qbm/webhook/{connection?}
You can also define verifier_token
for each connection to verify data received by webhook (read more).
Each webhook's notification will spawn a new laravel's event. You can easily create your own event listener to handle it.
Events list:
Hotrush\QuickBooksManager\Events\EntityCreate
Hotrush\QuickBooksManager\Events\EntityUpdate
Hotrush\QuickBooksManager\Events\EntityDelete
Hotrush\QuickBooksManager\Events\EntityMerge
Hotrush\QuickBooksManager\Events\EntityVoid
Each event has next arguments:
connection
namerealmId
entityName
- the name of the entity type that changed (Customer, Invoice, etc.)entityId
- changed entity idlastUpdated
- carbon-parsed date objectdeletedId
- the ID of the entity that was deleted and merged (only for Merge events)
Schedule refreshing in App\Console\Kernel
. Schedule docs.
$schedule->command(RefreshTokensCommand::class)->everyMinute();
Now you can configure token's table name, just change table_name
in config file.