Downloads
Stars
Version
This package provides Zoho Books integration for Laravel Spark and Laravel Cashier
This package automatically integrates zoho books with Laravel Spark and Laravel Cashier. Specifically:
Zoho Contact
for each new paying subscriber you have, linking it to you User
classZoho Invoice
for each new payment received (just stripe at the moment) and links it to the Invoice
from Cashier or the LocalInvoice
from SparkInvoice Created
and LocalInvoiceCreated
when a new Cashier invoice and a new Spark LocalInvoice are created$ composer require webleit/zohobookslaravelserviceprovider
The service provider gets autodiscovered by Laravel new autodiscover feature.
You can publish configuration and migrations using
php artisan vendor:publish
Run the migrations to add the zohobooks_id
fields to the users and invoices tables.
php artisan migrate
Register the new route for the Stripe Webhook controller. This needs manually because the spark service provider is registered by the application, and therefore is always loaded after any package.
In your RouteSeviceProvider
, inside the map
method, add:
$router->post('webhook/stripe', 'Webleit\ZohoBooksLaravelServiceProvider\Http\Controllers\StripeWebhookController@handleWebhook');
so that your final code looks like this:
public function map(Router $router)
{
$this->mapWebRoutes($router);
$this->mapApiRoutes($router);
$router->post('webhook/stripe', 'Webleit\ZohoBooksLaravelServiceProvider\Http\Controllers\StripeWebhookController@handleWebhook');
}
If you want the user to download the zoho invoice instead of the spark invoice from his settings page,
add the HasZohoBooksInvoices
to the App\User
class.
If you have overridden the LocalInvoice
class for spark, you can add to it the handy trait UseZohoBooksInvoice
which adds a lots of useful methods to it:
asInvoice()
to get the Cashier InvoiceasZohoBooksInvoice()
to get the ZohoBooks Invoicepdf($storagePath = null)
to get the PDF content of the invoicedownloadPdf($storagePath = null)
to download the PDF content of the invoiceWhen you publish the config file, you can add 3 parameters to it:
authtoken
(set through the env variable ZOHOBOOKS_AUTHTOKEN
), which is the zoho auth token to be used, which you can get here
organization_id
(set through the env variable ZOHOBOOKS_ORGANIZATION_ID
), which is the organization ID you want to work on.If the account you provided has just one organization, this can be null.invoice_storage_path
When you need the zoho books invoice PDF, it gets stored locally for cache. This is the path in the storage dir where it gets stored as a pdf file. Defaults to invoices
All the interactions that you might need are stored in the ZohoBooksInvoiceRepository
class:
createOnZohoBooks (App\User $billable, Laravel\Cashier\Invoice $invoice, Laravel\Spark\LocalInvoice $localInvoice)
creates both contact and invoice on ZohoBooks, checking if this wasn't already done.updateZohoContact (App\User $billable)
updates an existing contact on zohobooksgetZohoInvoice($invoiceId)
get the zoho books invoice using the zoho's invoice idstoreAndGetZohoInvoicePdf(Laravel\Spark\LocalInvoice $localInvoice, $storagePath = null)
get the pdf content of the zoho books invoice, storing it locally for cachedownloadZohoInvoicePdf(LocalInvoice $localInvoice, $storagePath = null)
download the pdf of the zoho invoice, storing it locally for cachePlease see CHANGELOG for more information on what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.