承接 csarcrr/invoicing-integration 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

csarcrr/invoicing-integration

Composer 安装命令:

composer require csarcrr/invoicing-integration

包简介

This package aims to help integrations with invoicing systems

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Invoicing Integration is a Laravel package that aggregates invoicing software providers in Portugal. It offers a fluent, provider-agnostic API so you can issue compliant documents without re-learning each vendor's HTTP contract.

Supported provider (today): Cegid Vendus. The package architecture allows more providers to be added without changing your application code.

Why Invoicing Integration?

Issuing fiscally compliant invoices in Portugal can be challenging. Each provider has its own API, authentication flow, and data formats.

This package solves that by giving you:

  • One API for all providers - Switch providers without rewriting your integration
  • Fluent builders - Intuitive, chainable methods that read like natural language
  • Built-in validation - Catch errors before they reach the provider
  • Type safety - Strongly typed DTOs powered by spatie/laravel-data

Highlights

  • Fluent builders for all fiscal document types (FT, FR, FS, RG, NC, GT)
  • DTO-first workflows via InvoiceData, so requests/responses share the same typed object
  • First-class client management via the Client facade (create, get, find)
  • Strongly typed DTOs powered by spatie/laravel-data
  • Built-in PDF / ESC/POS outputs with secure file persistence helpers
  • Centralized HTTP error handling and provider configuration facades

Table of Contents

Important Legal Disclaimer

This package facilitates invoicing provider API usage and is not intended to serve as legal guidance.

It is your responsibility to:

  • Comply with all invoicing laws and regulations in your jurisdiction
  • Understand each provider's specific requirements
  • Ensure proper invoicing practices according to your legal obligations
  • Validate that your usage complies with tax laws and accounting standards

Always consult with legal and accounting professionals when implementing invoicing solutions.

Requirements

  • PHP 8.2+
  • Laravel 11.x or 12.x (illuminate/contracts: ^11.0 || ^12.0)

Installation

composer require csarcrr/invoicing-integration

Publish the configuration file once the package is installed:

php artisan vendor:publish --tag="invoicing-integration-config"

See the documentation section: Getting Started - 4. Configuration File for detailed configuration instructions.

Runtime access to provider configuration

Use the ProviderConfiguration facade when you need to inspect or cache the active provider during runtime:

use CsarCrr\InvoicingIntegration\Facades\ProviderConfiguration;

$activeProvider = ProviderConfiguration::getProvider();
$config = ProviderConfiguration::getConfig();

Environment reference

Variable Description
INVOICING_INTEGRATION_PROVIDER Provider key (CegidVendus for now)
CEGID_VENDUS_API_KEY API token generated in Vendus
CEGID_VENDUS_MODE tests (sandbox/training) or production (fiscal)
CEGID_VENDUS_PAYMENT_* Mapping between PaymentMethod enums and Vendus payment IDs

The package validates configuration lazily when you issue invoices or clients, so misconfigured payment IDs will raise descriptive exceptions before the HTTP call is sent.

Usage

Creating an invoice

Every invoice now starts with a populated InvoiceData DTO. Pass the DTO to the Invoice facade and the package handles provider translation for you.

use CsarCrr\InvoicingIntegration\Data\ClientData;
use CsarCrr\InvoicingIntegration\Data\InvoiceData;
use CsarCrr\InvoicingIntegration\Data\ItemData;
use CsarCrr\InvoicingIntegration\Data\PaymentData;
use CsarCrr\InvoicingIntegration\Enums\InvoiceType;
use CsarCrr\InvoicingIntegration\Enums\PaymentMethod;
use CsarCrr\InvoicingIntegration\Facades\Invoice;

$invoiceData = InvoiceData::make([
    'type' => InvoiceType::InvoiceReceipt,
    'client' => ClientData::make([
        'name' => 'Maria Silva',
        'vat' => 'PT123456789',
        'email' => 'maria.silva@email.pt',
        'address' => 'Rua Augusta, 25',
        'city' => 'Lisboa',
        'postalCode' => '1100-053',
        'country' => 'PT',
    ]),
    'items' => [
        ItemData::make([
            'reference' => 'HEADPHONES-PRO',
            'note' => 'Wireless Noise-Cancelling Headphones',
            'price' => 14999, // 149.99 in cents
            'quantity' => 1,
        ]),
        ItemData::make([
            'reference' => 'SHIPPING-STD',
            'note' => 'Standard Delivery (2-3 business days)',
            'price' => 499, // 4.99 in cents
        ]),
    ],
    'payments' => [
        PaymentData::make([
            'method' => PaymentMethod::CREDIT_CARD,
            'amount' => 15498, // Total: 154.98
        ]),
    ],
]);

$invoice = Invoice::create($invoiceData)->execute()->getInvoice();

if ($invoice->output) {
    $invoice->output->save('invoices/' . $invoice->output->fileName());
}

The result contains everything you need:

{
    "id": 4567,
    "sequence": "FR 01P2025/1",
    "total": 15498,
    "totalNet": 12600,
    "atcudHash": "FR 01P2025/1 ABC123"
}

ClientData, ItemData, PaymentData, and other value objects extend spatie/laravel-data\Data. Instantiate them with ::make([...]) (or via dependency injection) so validation and transformers run before each HTTP request.

Prefer the Invoice facade for day-to-day usage. If you need to resolve the underlying action for dependency injection (e.g., in jobs), bind CsarCrr\InvoicingIntegration\InvoiceAction from the container.

Key rules:

  • At least one item is required for FT/FR/FS/NC documents
  • Payments are required for FR, FS, RG, and NC types
  • Tax exemptions require ItemTax::EXEMPT plus a valid TaxExemptionReason

Manage clients via the facade

You can register customers in the provider so they can be reused across orders:

use CsarCrr\InvoicingIntegration\Data\ClientData;
use CsarCrr\InvoicingIntegration\Facades\Client;

// Register a new customer
$client = Client::create(
    ClientData::make([
        'name' => 'TechStore Portugal Lda',
        'vat' => 'PT509876543',
        'email' => 'invoices@techstore.pt',
        'address' => 'Zona Industrial do Porto, Lote 15',
        'city' => 'Porto',
        'postalCode' => '4100-000',
        'country' => 'PT',
    ])
)->execute()->getClient();

// Retrieve the customer later by their provider ID
$fetched = Client::get(ClientData::make(['id' => $client->id]))->execute()->getClient();

// Search for customers by email domain
$filters = ClientData::make(['email' => 'techstore.pt']);
$results = Client::find($filters)->execute();

See docs/clients/README.md for pagination and filtering options.

All DTOs expose public typed properties. Access values via $client->name, $invoice->sequence, etc. - legacy getter methods no longer exist.

Common validation rules

  • Receipts (RG) are the only document without items
  • Credit notes require related document references, payments, and a reason
  • Transport details require a client, origin date, and valid ISO 3166-1 codes
  • Output formats (PDF_BASE64, ESCPOS) can be persisted via the Output value object (save(), getPath(), etc.)

Quick Start

For detailed workflows per document type, visit:

Error Handling

The Http::handleUnwantedFailures() macro maps HTTP status codes to package-specific exceptions:

  • UnauthorizedException - invalid or missing credentials (401)
  • FailedReachingProviderException - provider error/unreachable (500)
  • RequestFailedException - provider returned structured errors

Refer to docs/handling-errors.md for the full exception matrix and troubleshooting steps.

Testing & Quality

composer test        # Pest (parallel) test suite
composer analyse     # PHPStan (Larastan) analysis
composer format      # Laravel Pint code style
composer complete    # Format + analyse + test

Documentation

Browse the full documentation at csarcrr.github.io/invoicing-integration.

Contributing

Please see CONTRIBUTING.md for coding standards, branching strategy, and release process.

Security

Please review the security policy to learn how to report vulnerabilities.

License

The MIT License (MIT). See LICENSE.md for the full text.

Last updated: February 2026

csarcrr/invoicing-integration 适用场景与选型建议

csarcrr/invoicing-integration 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「csarcrr」 「invoicing-integration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 csarcrr/invoicing-integration 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 csarcrr/invoicing-integration 我们能提供哪些服务?
定制开发 / 二次开发

基于 csarcrr/invoicing-integration 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 63
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-06