square-bit/invoicexpress-for-laravel
Composer 安装命令:
composer require square-bit/invoicexpress-for-laravel
包简介
Laravel package to integrate invoicexpress
README 文档
README
Integrate your Laravel application with InvoiceXpress' API
Concept
This package can be used on 2 different layers:
- via the provided Models.
- interacting directly with the API endpoint.
Using the former allows you to transparently create, update and delete entities both in your application's database and in InvoiceXpress.
Installation
You can install the package via composer:
composer require square-bit/invoicexpress-for-laravel
Optionally, you can publish and run the migrations:
php artisan vendor:publish --tag="invoicexpress-for-laravel-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="invoicexpress-for-laravel-config"
This is the contents of the published config file:
return [ 'account' => [ 'name' => env('IX_ACCOUNT_NAME'), 'api_key' => env('IX_API_KEY'), ], 'service_endpoint' => 'app.invoicexpress.com', 'eloquent' => [ 'persist' => false, ], ];
IX_ACCOUNT_NAME is your InvoiceXpress account name (the XXX in https://XXX.app.invoicexpress.com).
IX_API_KEY is the API key you can get from your InvoiceXpress account settings page.
persist defines whether to store the entities in your database, when using the "Model" layer. Default is false.
If you set it to true, make sure you ran the migrations.
Usage
Option 1 - Via the model layer
With this approach, the package handles both local and remote changes to the entities.
This however is not enabled by default. To enable it:
- publish and run the migrations (see Installation)
- set
persist => truein the config file (see Installation)
You can get a specific Item and update it:
use Squarebit\InvoiceXpress\API\Data\ItemData; use Squarebit\InvoiceXpress\Model\IxItem; $item = IxItem::find(1234); $item->description = "a serious description"; $item->save();
Or you can create one:
$data = ItemData::from([...]); $item = (new IxItem())->fromData($data) ->save();
Or even delete it:
$item->delete();
Invoice lifecycle:
use Squarebit\InvoiceXpress\API\Data\PdfData; $invoice = (new IxInvoice()) ->setClient(IxClient::findOrFail(1234)) // set the invoice's client ->addItem(IxItem::find(2345)) // add an IxItem model ->addItem(ItemData::from([....])) // you can also add from an ItemData ->addItems([ // or from an array ItemData::from([...]), IxItem::find(3579), ... ]) ->save(); // creates the new invoice (locally and in InvoiceXpress) ->finalizeDocument() // formally registers the invoice ->email(); // email the invoice to the client // Store the pdf locally $pdf = $invoice->getPdf()->pdfUrl; Storage::put('file.jpg', $pdf); // Pay the invoice and email the receipt $receipt = $invoice ->pay() ->email();
Option 2 - Directly using the endpoints
With this approach, only remote changes are handled. If you want, you'll have to manage local changes (in your database) manually.
You can get a specific Item and update it:
use Squarebit\InvoiceXpress\Facades\InvoiceXpress; $itemsEndpoint = InvoiceXpress::items(); $itemData = $itemsEndpoint->get(1234); $itemData->description = "a serious description"; $itemsEndpoint->update($itemData);
Or you can create one:
$data = ItemData::from([...]); $itemData = InvoiceXpress::items()->create($itemData);
Or even delete it:
InvoiceXpress::items()->delete(1234);
Invoice lifecycle:
use Squarebit\InvoiceXpress\API\Data\ClientData; use Squarebit\InvoiceXpress\API\Data\EmailClientData; use Squarebit\InvoiceXpress\API\Data\EmailData; use Squarebit\InvoiceXpress\API\Data\InvoiceData; use Squarebit\InvoiceXpress\API\Data\ItemData; use Squarebit\InvoiceXpress\API\Data\PartialPaymentData; use Squarebit\InvoiceXpress\API\Data\StateData; use Squarebit\InvoiceXpress\Enums\DocumentEventEnum; use Squarebit\InvoiceXpress\Enums\EntityTypeEnum; use Squarebit\InvoiceXpress\Facades\InvoiceXpress; $invoiceEndpoint = InvoiceXpress::invoices(); // Create an Invoice $invoiceData = $invoiceEndpoint->create( EntityTypeEnum::SimplifiedInvoice, InvoiceData::from([ ... 'client' => ClientData::from([ ... ]), 'items' => [ ItemData::from([]) ] ]) ); // Formally register it $invoiceEndpoint->changeState( EntityTypeEnum::SimplifiedInvoice, $invoiceData->id, StateData::from([ 'state' => DocumentEventEnum::Finalized ]) ); // Email the Invoice $invoiceEndpoint->sendByEmail( EntityTypeEnum::SimplifiedInvoice, $invoiceData->id, EmailData::from([ 'client_data' => EmailClientData::from([ 'email' => 'someone@somewhere.com' ]), 'subject' => '...', 'body' => '...', 'cc' => '...', 'bcc' => '...', ]) ); // Get the pdf $pdfData = $invoiceEndpoint->generatePDF($invoiceData->id) // Pay the invoice (in total) $receiptData = $invoiceEndpoint->generatePayment([ EntityTypeEnum::SimplifiedInvoice, $invoiceData->id, PartialPaymentData::from([ 'amount' => $invoiceData->total, ]) ])
You can mix both options, if you want
$itemsEndpoint = InvoiceXpress::items(); // get an Item by querying the endpoint directly $itemData = $itemsEndpoint->get(1234); // create an IxItem model with that data and update it $item = (new IxItem())->fromData($itemData); $item->description = 'a more serious description'; // send the modifed data to InvoiceXpress $itemsEndpoint->update($item->getData());
Available entities
| InvoiceXpress entity | Model class | Endpoint class |
|---|---|---|
| Items | IxItem | ItemsEndpoint |
| Taxes | IxTax | TaxesEndpoint |
| Clients | IxIClient | ClientsEndpoint |
| Invoices (Invoice) | IxInvoice | InvoicesEndpoint |
| Invoices (SimplifiedInvoice) | IxSimplifiedInvoice | InvoicesEndpoint |
| Invoices (InvoiceReceipt) | IxInvoiceReceipt | InvoicesEndpoint |
| Invoices (Receipt) | IxReceipt | InvoicesEndpoint |
| Invoices (CreditNote) | IxCreditNote | InvoicesEndpoint |
| Invoices (DebitNote) | IxDebitNote | InvoicesEndpoint |
| Invoices (CashInvoice) | IxCashInvoice | InvoicesEndpoint |
| Invoices (VatMossInvoice) | IxVatMossInvoice | InvoicesEndpoint |
| Invoices (VatMossReceipt) | IxVatMossReceipt | InvoicesEndpoint |
| Invoices (VatMossCreditNote) | IxVatMossCreditNote | InvoicesEndpoint |
| Estimates (Quote) | IxQuote | EstimatesEndpoint |
| Estimates (Proforma) | IxProforma | EstimatesEndpoint |
| Estimates (FeesNote) | IxFeesNote | EstimatesEndpoint |
| Guides (Shipping) | IxShipping | GuidesEndpoint |
| Guides (Transport) | IxTransport | GuidesEndpoint |
| Guides (Devolution) | IxDevolution | GuidesEndpoint |
| Sequences | IxSequence | SequencesEndpoint |
| SAF-T | - | SaftEndpoint |
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
square-bit/invoicexpress-for-laravel 适用场景与选型建议
square-bit/invoicexpress-for-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 798 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「square-bit」 「invoicexpress-for-laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 square-bit/invoicexpress-for-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 square-bit/invoicexpress-for-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 square-bit/invoicexpress-for-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Database-driven code execution: make your objects smart!
Filament resources for square-bit/laravel-volition!
Add workflow support to your Laravel models.
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 798
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-20