b2brouter/b2brouter-php
B2Brouter PHP SDK - Official library for the B2Brouter API
v1.3.0
100K downloads/mo
#4910 most downloaded on Packagist
B2Brouter/b2brouter-php
What this package is like to depend on
Last release 3 months ago
25 May 2026
Ships fairly regularly
a new release about every 2 months
Nearly every release is documented
notes for 6 of 6 stable releases
Nothing withdrawn
no release was ever pulled
9 months old
6 releases · first in 2025
6 releases in the last 12 months
see the full history below
Release timeline
6 releases · Nov 2025 to May 2026Releases
latest 6-
v1.3.025 May 2026Release notes
Open source →What's changed
This is a docs + default-version release. The SDK default API version moves to
2026-04-20(minor bump per the versioning policy), and the SDK now self-identifies on every request via aUser-Agentheader.New features
User-Agentheader on every request — the SDK identifies itself asB2BRouter-PHP/1.3.0 (PHP/{version}; curl/{version}). Applies to JSON and binary endpoints. No caller action required.app_infoconstructor option — applications that wrap the SDK (integrators, plugins) can identify themselves in theUser-Agentheader.B2BRouterClient::VERSIONconstant andB2BRouterClient::getUserAgent()getter.
Default API version → 2026-04-20
The SDK default
api_versionmoves from2026-03-02to2026-04-20. The PHP interface is unchanged; callers can pin the previous API version via theapi_versionconfig option.The CHANGELOG
[1.3.0]entry includes a full migration guide covering the 2026-04-20 API delta (invoice_references[]in place of flat amend fields,classification_code_schemetypo fix, removedpayment_method_inforesponse field, inline contact identifier requirement, stricter contact/parent_id validation, Peppol transport response shape changes, plus all new fields).The CHANGELOG also notes that the new TIN verification endpoint and
tin_verification.finishedwebhook event ship with v2026-04-20 but are not yet surfaced by the SDK.Also included
- New example:
identify_caller_app.php docs/VERSIONING.mdadds a "Supported API versions" section- All examples updated to use the new default
Quick start
// Identify your integrating app in the User-Agent header $client = new B2BRouterClient('your-api-key', [ 'app_info' => [ 'name' => 'B2BRouter-WooCommerce', 'version' => '1.0.3', 'url' => 'https://shop.example.com', ], ]); // Pin the previous API version if you need time to migrate $client = new B2BRouterClient('your-api-key', [ 'api_version' => '2026-03-02', ]);
Full Changelog: v1.2.0...v1.3.0
Release notes
Open source →Added
User-Agentheader on every request — the SDK now identifies itself with a header likeB2BRouter-PHP/1.3.0 (PHP/8.2.10; curl/8.5.0). Applies to both JSON and binary endpoints. No caller action required.app_infoconstructor option — applications that wrap the SDK (e.g. integrators, plugins) can identify themselves in theUser-Agentheader:
Produces:$client = new B2BRouterClient('sk_...', [ 'app_info' => [ 'name' => 'B2BRouter-WooCommerce', // required 'version' => '1.0.3', // optional 'url' => 'https://shop.example.com', // optional ], ]);B2BRouter-PHP/1.3.0 (PHP/8.2.10; curl/8.5.0) B2BRouter-WooCommerce/1.0.3 (https://shop.example.com).B2BRouterClient::VERSIONconstant — the SDK version, also accessible at runtime.B2BRouterClient::getUserAgent()— returns the composedUser-Agentstring (lazy, cached).- New example:
identify_caller_app.php
Changed
- Default API version updated from
2026-03-02to2026-04-20
API version
2026-04-20migration guideThe following changes apply only if you use API version
2026-04-20(the new default). If you pin'api_version' => '2026-03-02', your existing code continues to work unchanged.To keep the previous API version:
$client = new B2BRouterClient('your-api-key', [ 'api_version' => '2026-03-02', ]);Invoice amend fields replaced by
invoice_references[]The flat amend fields on invoices have been removed in favour of a structured
invoice_references[]array. Each entry carries areference_type(amendorprepayment) plus the reference data.Removed fields:
amended_number,amended_date,amended_invoicing_period_start,amended_invoicing_period_end,amend_reason,amend_code_tax,correction_method.Before (API
2026-03-02):$invoice = $client->invoices->create($accountId, [ 'invoice' => [ // ... 'amended_number' => 'INV-2025-001', 'amended_date' => '2025-01-15', 'amend_reason' => 'Corrected line items', ], ]);After (API
2026-04-20):$invoice = $client->invoices->create($accountId, [ 'invoice' => [ // ... 'invoice_references' => [ [ 'reference_type' => 'amend', 'number' => 'INV-2025-001', 'date' => '2025-01-15', 'reason' => 'Corrected line items', ], ], ], ]);Invoice line field typo fix:
clasification_code_scheme→classification_code_schemeThe misspelled
clasification_code_scheme(singles) on invoice lines has been renamed to the correctly-spelledclassification_code_scheme. Update any payloads that set this field.Removed invoice response field
payment_method_infois no longer returned. Use the structured fields instead:payment_method,contact_iban,contact_bic.Inline contact on invoice POST now requires identifier
When creating an invoice with an inline
contactblock viaPOST /accounts/{account}/invoices, the contact must include eithertin_valueorcin_value. The only exception isIssuedSimplifiedInvoice. Previously the inline contact could be created without an identifier; this now returns422 parameter_invalid.Contact
tin_value/tin_schemevalidated against parentWhen a contact is created or updated with
parent_idset,tin_valueandtin_schememust match the parent contact's values. Mismatches now return422 parameter_invalid(previously they were silently ignored).Peppol transport response shape changes
The Peppol transport response replaces
standard_documentsandpending_peppol_directory_publishwith three fields:sml_status,peppol_directory_status,reception_document_types. The SDK does not currently surface Peppol transports through a dedicated service, so this only affects callers parsing the raw response.New API endpoints not yet surfaced by the SDK
The B2BRouter 2026-04-20 platform release adds two capabilities that this SDK does not yet expose. They are noted here so callers are aware they exist at the API level; dedicated SDK support is planned for a future release.
- TIN verification —
POST /tin_verifications?country=essubmits a batch of up to 20,000 TIN+name pairs for verification against the tax authority census (Spain / AEAT only at launch). The request returns202 Accepted; results are retrieved withGET /tin_verifications/{id}or via webhook. A dedicatedTinVerificationServiceis planned. tin_verification.finishedwebhook event — fired when a TIN verification batch reaches a terminal state (successorfailed). The payload carries onlyidandstatus; useGET /tin_verifications/{id}to fetch the full results. Subscribe via the existing webhook configuration; no SDK helpers or event constants are provided yet.
New API fields (no SDK changes required)
These fields are automatically available through the array-based response:
- Accounts:
routing_codes(cin1_value/cin1_scheme…cin5_value/cin5_scheme),auto_remittance,skip_line_taxable_base_rounding. - Invoices:
cin_valueandcin_schemeon the contact object;exchange_rate,exchange_date,order_date(previously write-only, now returned);total_amount_dueaccepted as write-only input. - Invoices (KSeF):
apply_to_local_government_unit,apply_to_vat_group_member,third_party(expandable via?include=). - Invoice
type_code(KSeF):ZAL,ROZ,KOR_ZAL,KOR_ROZ,KOR,VAT,UPR. - Tax reports (KSeF):
customer_party_jst,customer_party_gv,purchase_order_date,despatch_advice_reference,supplier_party_krs,supplier_party_regon,supplier_party_bdo,supplier_contact_phone,supplier_contact_email,previous_advance_total,order_total_amount,prepayment_references[], writablethird_party_*.
-
v1.2.026 Mar 2026Release notes
Open source →What's changed
This release adds full CRUD support for accounts and contacts.
New services
AccountService($client->accounts) — list, create, retrieve, update, delete, unarchive, upload/delete logoContactService($client->contacts) — list, create, retrieve, update, delete
Also included
- New examples:
accounts_edocsync.php,accounts_edocexchange.php,contacts.php docs/VERSIONING.md— SDK versioning policy documentation
Quick start
// List accounts $accounts = $client->accounts->all(['limit' => 10]); // Create a contact $contact = $client->contacts->create($accountId, [ 'contact' => [ 'name' => 'Customer Company', 'email' => '[email protected]', 'tin_value' => 'ESB87654321', 'country' => 'ES', ] ]); Full Changelog: https://github.com/B2Brouter/b2brouter-php/compare/v1.1.0...v1.2.0
Release notes
Open source →Added
AccountService($client->accounts) — full account management:all()— list accounts with Ransack query filteringcreate()— create a new account (eDocSync subscriptions)retrieve()— get account detailsupdate()— update account fieldsdelete()— archive or delete an accountunarchive()— restore an archived accountuploadLogo()— upload account logo (binary)deleteLogo()— remove account logo
ContactService($client->contacts) — full contact management:all()— list contacts with filtering by name, type, and integration codecreate()— create a new contactretrieve()— get contact detailsupdate()— update contact fieldsdelete()— delete a contact
- New examples:
accounts.php,contacts.php docs/VERSIONING.md— SDK versioning policy documentation
-
v1.1.024 Mar 2026Release notes
Open source →This release updates the default B2BRouter API version from
2025-10-13to2026-03-02.This is a safe upgrade. The SDK's PHP interface is unchanged. If you're not ready to adopt the new API version, pin the previous one:
$client = new B2BRouterClient('your-api-key', [ 'api_version' => '2025-10-13', ]);
What changed in the SDK
- Default API version updated to
2026-03-02 - Request ID header updated to
X-B2B-API-Request-Id(falls back toX-Request-Idfor older API versions) - Added versioning policy documentation
- New example:
use_previous_api_version.php
API version
2026-03-02migration guideThe following changes apply only if you use API version
2026-03-02(the new default).Removed invoice fields
Use
allowance_charges_attributesinstead:discount_amount,discount_percent,discount_text→allowance_charge_indicator: "allowance"charge_amount,charge_percent,charge_reason→allowance_charge_indicator: "charge"apply_taxes_to_charge→ individualapply_taxesper allowance/chargecharge_is_reimbursable_expense→ individualis_reimbursable_expenseper allowance/charge
Same removals apply to invoice line fields (
discount_*,charge_*).Invoice search:
taxcodereplaced byquery// Before (API 2025-10-13) $invoices = $client->invoices->all($accountId, ['taxcode' => 'ESB12345678']); // After (API 2026-03-02) $invoices = $client->invoices->all($accountId, ['query' => 'tin_value=ESB12345678']);
Other API changes
type_documentrenamed totype_codeon invoices- Scheme fields (
tin_scheme,cin_scheme,pin_scheme) now return zero-padded 4-char strings (e.g.,"0007"instead of7) - POST create endpoints return
201 Createdinstead of200 OK(SDK handles this transparently) contact_idignored forIssuedSimplifiedInvoice- Contact
is_providerdefaults totruewhen creating via API
New API fields (automatic, no SDK changes needed)
- Invoice:
base_quantity,tax_currency_code,tax_amount_in_tax_currency,payments_on_account - TaxReport:
annulled_by_id,corrected_by_id, KSeF-specific fields - TaxReportLine:
item_seller_identifier,item_standard_identifier - BankAccount:
is_default
Upgrade
composer update b2brouter/b2brouter-php
Full changelog: v1.0.0...v1.1.0
Release notes
Open source →Changed
- Default API version updated from
2025-10-13to2026-03-02 - Request ID header updated to
X-B2B-API-Request-Id(falls back toX-Request-Idfor older API versions)
API version
2026-03-02migration guideThe following changes apply only if you use API version
2026-03-02(the new default). If you pin'api_version' => '2025-10-13', your existing code continues to work unchanged.To keep the previous API version:
$client = new B2BRouterClient('your-api-key', [ 'api_version' => '2025-10-13', ]);Removed invoice fields
The following invoice-level fields have been removed. Use
allowance_charges_attributesinstead:discount_amount,discount_percent,discount_text— useallowance_charges_attributeswithallowance_charge_indicator: "allowance"charge_amount,charge_percent,charge_reason— useallowance_charges_attributeswithallowance_charge_indicator: "charge"apply_taxes_to_charge— useallowance_charges_attributeswith individualapply_taxessettingscharge_is_reimbursable_expense— useallowance_charges_attributeswith individualis_reimbursable_expensesettings
Removed invoice line fields
The following line-level fields have been removed. Use
allowance_charges_attributesinstead:discount_amount,discount_percent,discount_text— useallowance_charges_attributeswithallowance_charge_indicator: "allowance"charge_amount,charge_percent,charge_reason— useallowance_charges_attributeswithallowance_charge_indicator: "charge"
Invoice search:
taxcodereplaced byqueryBefore (API
2025-10-13):$invoices = $client->invoices->all($accountId, ['taxcode' => 'ESB12345678']);After (API
2026-03-02):$invoices = $client->invoices->all($accountId, ['query' => 'tin_value=ESB12345678']);Other API changes
type_documentrenamed totype_codeon invoices for document type codes (Peppol, CII, KSeF, FatturaPA)- Scheme fields (
tin_scheme,cin_scheme,pin_scheme) now return zero-padded 4-character strings (e.g.,"0007"instead of7). Unknown scheme returnsnilinstead of"0001". - POST create endpoints now return
201 Createdinstead of200 OK(SDK handles this transparently) contact_idignored forIssuedSimplifiedInvoice— simplified invoices always use inline contact fields- Contact
is_providernow defaults totruewhen creating contacts via API
New API fields (no SDK changes required)
These fields are automatically available through the array-based response:
- Invoice:
base_quantity(decimal),tax_currency_code(ISO 4217 string),tax_amount_in_tax_currency(decimal),payments_on_account - TaxReport:
annulled_by_id,corrected_by_id(integer, nullable),payment_account_name,purchase_order_reference,sales_order_reference,tax_inclusive_amount_before_allowances_and_charges(KSeF-specific) - TaxReportLine:
item_seller_identifier,item_standard_identifier(TicketBAI/KSeF) - BankAccount:
is_default(boolean)
- Default API version updated to
-
v1.0.005 Dec 2025Release notes
Open source →First Stable Release
This is the first stable release of the B2BRouter PHP SDK. The SDK is production-ready with semantic versioning guarantees. All future 1.x releases will maintain backward compatibility.
Features
Invoice Management
- Complete CRUD operations (create, retrieve, update, delete, list)
- Domain-specific operations:
validate()- Validate invoice structure before sendingsend()- Send invoice to customer and generate tax reportsmarkAs()- Update invoice state (new, sent, paid, etc.)acknowledge()- Mark received invoices as acknowledgedimport()- Import invoices from external sources
- Multi-format document downloads:
downloadAs()- Download in any supported formatdownloadPdf()- Convenience method for PDF downloads- Support for PDF (
pdf.invoice) - Support for Spanish Facturae XML (
xml.facturae.3.2.2) - Support for UBL BIS3 (
xml.ubl.invoice.bis3) - Additional formats based on account configuration
Tax Reports
- Full CRUD operations (create, retrieve, update, delete, list)
- Multi-jurisdiction support:
- Spanish Verifactu (Law 11/2021 Anti-Fraud compliance)
- TicketBAI (Basque Country: Álava, Bizkaia, Gipuzkoa)
- Italian SDI (Sistema di Interscambio)
- Polish KSeF (National e-Invoicing System)
- Saudi Zatca (e-invoicing)
- Automatic tax report generation on invoice send
- QR code generation for invoice verification
- Digital fingerprint and hash chain computation
- Corrections (subsanación) via
update() - Annullations (anulación) via
delete() - XML download support
Tax Report Settings
- Configure tax authority settings (Verifactu, TicketBAI, etc.)
- Full CRUD operations
- Auto-generation and auto-send configuration
- Special regime and exemption settings
HTTP Client & Error Handling
- Automatic retry logic with exponential backoff (configurable, default: 3 retries)
- Configurable timeouts (request: 80s, connection: 30s)
- Custom HTTP client support via
ClientInterface - Comprehensive exception hierarchy:
ApiErrorException- Base exception for all API errorsAuthenticationException- Invalid API key (401)PermissionException- Insufficient permissions (403)ResourceNotFoundException- Resource not found (404)InvalidRequestException- Validation errors (400, 422)ApiConnectionException- Network/connection errors
- Rich exception context with HTTP status, headers, request ID
Collections & Pagination
- Collection class implementing Iterator and Countable interfaces
- Easy iteration with native
foreachloops - Pagination metadata (total, offset, limit)
hasMore()helper for checking additional pages
Developer Experience
- Modern PHP 7.4+ with type hints throughout
- PSR-4 autoloading
- PSR-12 coding standards compliant
- Zero dependencies (only PHP extensions: cURL, JSON, mbstring)
- 15 working examples covering all features
- Comprehensive documentation:
- README.md with quick start and examples
- API_REFERENCE.md with complete method documentation
- SPANISH_INVOICING.md with Verifactu compliance guide
- TAX_REPORTS.md with tax reporting details
- DEVELOPER_GUIDE.md with setup and best practices
- Environment configuration support via
.envfiles - Composer scripts for testing (
test,test:all,test:coverage)
Upgrade from 0.9.x
No breaking changes. Update your composer.json:
{ "require": { "b2brouter/b2brouter-php": "^1.0" } }Then run:
composer update b2brouter/b2brouter-phpAll 0.9.x code is fully compatible with 1.0.0.
Requirements
- PHP 7.4 or higher
- cURL extension
- JSON extension
- mbstring extension
Support
- Documentation: https://developer.b2brouter.net
- Email: [email protected]
- Issues: https://github.com/B2Brouter/b2brouter-php/issues
Release notes
Open source →First Stable Release
This is the first stable release of the B2BRouter PHP SDK. The SDK is production-ready with semantic versioning guarantees. All future 1.x releases will maintain backward compatibility.
Features
Invoice Management
- Complete CRUD operations (create, retrieve, update, delete, list)
- Domain-specific operations:
validate()- Validate invoice structure before sendingsend()- Send invoice to customer and generate tax reportsmarkAs()- Update invoice state (new, sent, paid, etc.)acknowledge()- Mark received invoices as acknowledgedimport()- Import invoices from external sources
- Multi-format document downloads:
downloadAs()- Download in any supported formatdownloadPdf()- Convenience method for PDF downloads- Support for PDF (
pdf.invoice) - Support for Spanish Facturae XML (
xml.facturae.3.2.2) - Support for UBL BIS3 (
xml.ubl.invoice.bis3) - Additional formats based on account configuration
Tax Reports
- Full CRUD operations (create, retrieve, update, delete, list)
- Multi-jurisdiction support:
- Spanish Verifactu (Law 11/2021 Anti-Fraud compliance)
- TicketBAI (Basque Country: Álava, Bizkaia, Gipuzkoa)
- Italian SDI (Sistema di Interscambio)
- Polish KSeF (National e-Invoicing System)
- Saudi Zatca (e-invoicing)
- Automatic tax report generation on invoice send
- QR code generation for invoice verification
- Digital fingerprint and hash chain computation
- Corrections (subsanación) via
update() - Annullations (anulación) via
delete() - XML download support
Tax Report Settings
- Configure tax authority settings (Verifactu, TicketBAI, etc.)
- Full CRUD operations
- Auto-generation and auto-send configuration
- Special regime and exemption settings
HTTP Client & Error Handling
- Automatic retry logic with exponential backoff (configurable, default: 3 retries)
- Configurable timeouts (request: 80s, connection: 30s)
- Custom HTTP client support via
ClientInterface - Comprehensive exception hierarchy:
ApiErrorException- Base exception for all API errorsAuthenticationException- Invalid API key (401)PermissionException- Insufficient permissions (403)ResourceNotFoundException- Resource not found (404)InvalidRequestException- Validation errors (400, 422)ApiConnectionException- Network/connection errors
- Rich exception context with HTTP status, headers, request ID
Collections & Pagination
- Collection class implementing Iterator and Countable interfaces
- Easy iteration with native
foreachloops - Pagination metadata (total, offset, limit)
hasMore()helper for checking additional pages
Developer Experience
- Modern PHP 7.4+ with type hints throughout
- PSR-4 autoloading
- PSR-12 coding standards compliant
- Zero dependencies (only PHP extensions: cURL, JSON, mbstring)
- 15 working examples covering all features
- Comprehensive documentation:
- README.md with quick start and examples
- API_REFERENCE.md with complete method documentation
- SPANISH_INVOICING.md with Verifactu compliance guide
- TAX_REPORTS.md with tax reporting details
- DEVELOPER_GUIDE.md with setup and best practices
- Environment configuration support via
.envfiles - Composer scripts for testing (
test,test:all,test:coverage)
Upgrade from 0.9.x
No breaking changes. Update your composer.json:
{ "require": { "b2brouter/b2brouter-php": "^1.0" } }Then run:
composer update b2brouter/b2brouter-phpAll 0.9.x code is fully compatible with 1.0.0.
Requirements
- PHP 7.4 or higher
- cURL extension
- JSON extension
- mbstring extension
Support
- Documentation: https://developer.b2brouter.net
- Email: [email protected]
- Issues: https://github.com/B2Brouter/b2brouter-php/issues
-
v0.9.119 Nov 2025Release notes
Open source →Added
- Invoice document download support - Download invoices in various formats
InvoiceService::downloadAs($id, $documentType, $params)- Download invoice in any supported formatInvoiceService::downloadPdf($id, $params)- Convenience method for PDF downloads- Support for PDF format (
pdf.invoice) - Support for XML formats (Facturae
xml.facturae.3.2.2, UBL BIS3xml.ubl.invoice.bis3, and more) - Optional query parameters for disposition and custom filename
- Binary response handling - New
ApiResource::requestBinary()method for non-JSON responses- Automatic Accept header determination based on document type
- Proper error handling for binary endpoints (still parses JSON errors)
- Returns raw binary data for PDF/XML downloads
Documentation
- Added invoice document download examples to README
- Updated PHPDoc with comprehensive documentation for new methods
- Added unit tests for PDF, Facturae, and UBL downloads
- Documented available document type codes
- Added
examples/download_invoice_documents.php- Complete example showing invoice creation and downloading in PDF and UBL BIS3 formats
Technical Details
- Binary downloads return raw string data (PDF bytes, XML text, etc.)
- Accept headers automatically set:
application/pdffor PDF formats,application/xmlfor XML formats - All existing exception types work with download methods (404, 401, 403, etc.)
- Automatic retry logic applies to document downloads
- Invoice document download support - Download invoices in various formats
-
v0.9.018 Nov 2025Release notes
Open source →Core SDK Features
- Invoice CRUD operations (create, retrieve, update, delete, list)
- Invoice domain-specific operations:
validate()- Validate invoice structure before sendingsend()- Send invoice to customer and/or tax authoritymarkAs()- Update invoice state (sent, paid, etc.)acknowledge()- Mark received invoices as acknowledgedimport()- Bulk import invoices
- Tax report management:
retrieve()- Get tax report detailsall()- List tax reports with filteringdownload()- Download XML tax reportcreate(),update(),delete()- CRUD operations
- Tax report settings configuration (CRUD operations)
- Collection-based pagination with Iterator and Countable interfaces
Tax Compliance
- Spanish Verifactu compliance support (Law 11/2021 Anti-Fraud)
- TicketBAI tax reporting (Basque Country: Álava, Bizkaia, Gipuzkoa)
- Support for multiple tax jurisdictions:
- Spain (Verifactu)
- Basque Country (TicketBAI)
- Italy (SDI)
- Poland (KSeF)
- Saudi Arabia (Zatca)
- Automatic tax report generation on invoice send
- QR code generation for invoice verification
- Digital fingerprint and hash chain computation
Error Handling
- Comprehensive exception hierarchy:
ApiErrorException- Base exception for all API errorsAuthenticationException- Invalid API key (401)PermissionException- Insufficient permissions (403)ResourceNotFoundException- Resource not found (404)InvalidRequestException- Validation errors (400, 422)ApiConnectionException- Network/connection errors
- Rich exception context:
- HTTP status code
- Raw HTTP body
- Parsed JSON response
- HTTP headers
- Request ID for support tracking
HTTP Client
- Automatic retry logic with exponential backoff (default: 3 retries)
- Configurable timeouts (request: 80s, connection: 30s)
- Custom HTTP client support via
ClientInterface - cURL-based default implementation
- Mock HTTP client for testing
Testing & Quality
- Comprehensive test suite with PHPUnit 9.x
- Unit tests for all major components:
- B2BRouterClientTest
- InvoiceServiceTest
- TaxReportServiceTest
- TaxReportSettingServiceTest
- CollectionTest
- ExceptionTest
- HttpClientTest
- Mock HTTP client for isolated testing
- Test grouping (unit, integration, external)
- GitHub Actions CI/CD pipeline:
- Automated testing on push/PR
- Composer validation
- Dependency caching
- Static analysis with PHPStan
- Code standards checking with PHP_CodeSniffer
Documentation
- Comprehensive README.md with:
- Quick start guide
- Configuration options
- Core concepts (Invoices, Tax Reports, Spanish Invoicing)
- Pagination examples
- Error handling examples
- Specialized guides:
DEVELOPER_GUIDE.md- Setup, IDE configuration, testing, best practicesSPANISH_INVOICING.md- Verifactu compliance guideTAX_REPORTS.md- Tax reporting system documentation
- 14 working examples:
create_simple_invoice.phpcreate_detailed_invoice.phplist_invoices.phppaginate_all_invoices.phpupdate_invoice.phpinvoice_workflow.phpinvoices.phpinvoicing_in_spain_with_verifactu.phptax_reports.phpverifactu_tax_report.phpticketbai_tax_report.php- And more...
- Environment configuration support (
.env.example)
Developer Experience
- Modern PHP 7.4+ with type hints throughout
- PSR-4 autoloading
- Composer scripts for testing:
composer test- Unit tests (fast)composer test:all- All tests including integrationcomposer test:external- External integration testscomposer test:coverage- HTML coverage report
- Clean service-based API design
- Lazy service loading (services created on first access)
- Iterator support for collections (native
foreachloops)
Requirements
- PHP 7.4 or higher
- cURL extension
- JSON extension
- mbstring extension
Notes
This is a beta release (v0.9.x) intended for early adopters and development/testing purposes.
Stability:
- ✅ The SDK is feature-complete and well-tested
- ✅ Suitable for WooCommerce plugin development and testing
- ⚠️ API may undergo minor refinements before v1.0.0
- ⚠️ Production use should pin to specific version:
"b2brouter/b2brouter-php": "0.9.0"
What's Coming in v1.0.0:
- Potential minor API refinements based on early adopter feedback
Upgrade Path:
- Beta users:
^0.9.0(allows 0.9.1, 0.9.2, etc.) - After v1.0.0:
^1.0(semantic versioning guarantees)
Release notes
Open source →Added
Core SDK Features
- Invoice CRUD operations (create, retrieve, update, delete, list)
- Invoice domain-specific operations:
validate()- Validate invoice structure before sendingsend()- Send invoice to customer and/or tax authoritymarkAs()- Update invoice state (sent, paid, etc.)acknowledge()- Mark received invoices as acknowledgedimport()- Bulk import invoices
- Tax report management:
retrieve()- Get tax report detailsall()- List tax reports with filteringdownload()- Download XML tax reportcreate(),update(),delete()- CRUD operations
- Tax report settings configuration (CRUD operations)
- Collection-based pagination with Iterator and Countable interfaces
Tax Compliance
- Spanish Verifactu compliance support (Law 11/2021 Anti-Fraud)
- TicketBAI tax reporting (Basque Country: Álava, Bizkaia, Gipuzkoa)
- Support for multiple tax jurisdictions:
- Spain (Verifactu)
- Basque Country (TicketBAI)
- Italy (SDI)
- Poland (KSeF)
- Saudi Arabia (Zatca)
- Automatic tax report generation on invoice send
- QR code generation for invoice verification
- Digital fingerprint and hash chain computation
Error Handling
- Comprehensive exception hierarchy:
ApiErrorException- Base exception for all API errorsAuthenticationException- Invalid API key (401)PermissionException- Insufficient permissions (403)ResourceNotFoundException- Resource not found (404)InvalidRequestException- Validation errors (400, 422)ApiConnectionException- Network/connection errors
- Rich exception context:
- HTTP status code
- Raw HTTP body
- Parsed JSON response
- HTTP headers
- Request ID for support tracking
HTTP Client
- Automatic retry logic with exponential backoff (default: 3 retries)
- Configurable timeouts (request: 80s, connection: 30s)
- Custom HTTP client support via
ClientInterface - cURL-based default implementation
- Mock HTTP client for testing
Testing & Quality
- Comprehensive test suite with PHPUnit 9.x
- Unit tests for all major components:
- B2BRouterClientTest
- InvoiceServiceTest
- TaxReportServiceTest
- TaxReportSettingServiceTest
- CollectionTest
- ExceptionTest
- HttpClientTest
- Mock HTTP client for isolated testing
- Test grouping (unit, integration, external)
- GitHub Actions CI/CD pipeline:
- Automated testing on push/PR
- Composer validation
- Dependency caching
- Static analysis with PHPStan
- Code standards checking with PHP_CodeSniffer
Documentation
- Comprehensive README.md with:
- Quick start guide
- Configuration options
- Core concepts (Invoices, Tax Reports, Spanish Invoicing)
- Pagination examples
- Error handling examples
- Specialized guides:
DEVELOPER_GUIDE.md- Setup, IDE configuration, testing, best practicesSPANISH_INVOICING.md- Verifactu compliance guideTAX_REPORTS.md- Tax reporting system documentation
- 14 working examples:
create_simple_invoice.phpcreate_detailed_invoice.phplist_invoices.phppaginate_all_invoices.phpupdate_invoice.phpinvoice_workflow.phpinvoices.phpinvoicing_in_spain_with_verifactu.phptax_reports.phpverifactu_tax_report.phpticketbai_tax_report.php- And more...
- Environment configuration support (
.env.example)
Developer Experience
- Modern PHP 7.4+ with type hints throughout
- PSR-4 autoloading
- Composer scripts for testing:
composer test- Unit tests (fast)composer test:all- All tests including integrationcomposer test:external- External integration testscomposer test:coverage- HTML coverage report
- Clean service-based API design
- Lazy service loading (services created on first access)
- Iterator support for collections (native
foreachloops)
Requirements
- PHP 7.4 or higher
- cURL extension
- JSON extension
- mbstring extension
Notes
This is a beta release (v0.9.x) intended for early adopters and development/testing purposes.
Stability:
- ✅ The SDK is feature-complete and well-tested
- ✅ Suitable for WooCommerce plugin development and testing
- ⚠️ API may undergo minor refinements before v1.0.0
- ⚠️ Production use should pin to specific version:
"b2brouter/b2brouter-php": "0.9.0"
What's Coming in v1.0.0:
- Potential minor API refinements based on early adopter feedback
Upgrade Path:
- Beta users:
^0.9.0(allows 0.9.1, 0.9.2, etc.) - After v1.0.0:
^1.0(semantic versioning guarantees)
Support
- Documentation: https://developer.b2brouter.net
- Email: [email protected]
- Issues: https://github.com/B2Brouter/b2brouter-php/issues