Download the PHP package b2brouter/b2brouter-php without Composer

On this page you can find all versions of the php package b2brouter/b2brouter-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package b2brouter-php

B2BRouter PHP SDK

Official PHP SDK for the B2BRouter API - Electronic Invoicing and Tax Reporting

PHP Version

Table of Contents

Features

Core Functionality

Developer Experience

Compliance and Tax Reporting

Requirements

Installation

Install via Composer:

Quick Start

Running Examples

The SDK includes comprehensive examples demonstrating all features. To run them:

1. Setup Environment

Your .env file should look like:

2. Install Dependencies

3. Run Examples

All examples use the environment variables from your .env file automatically.

Configuration

The client accepts several configuration options:

Default Environment: The SDK defaults to the staging environment (https://api-staging.b2brouter.net) for safe testing. To use production, set api_base to https://api.b2brouter.net.

Multi-version support: The SDK defaults to API version 2026-04-20. To use an older API version, pass it explicitly in the configuration:

Identifying your application

The SDK sends a User-Agent header on every request, identifying itself, the PHP runtime, and libcurl. Applications that wrap the SDK (integrators, plugins, custom tools) can identify themselves by passing app_info:

The resulting User-Agent is:

This helps B2BRouter support identify the SDK version and the integrating application when investigating support requests. See examples/identify_caller_app.php for a runnable demo.

Core Concepts

Invoice Operations

Create an Invoice

Retrieve an Invoice

Update an Invoice

Delete an Invoice

List Invoices

Download Invoice Documents

Download invoices as PDF or in various XML formats:

Note: Available document types depend on your B2Brouter account configuration and the invoice type. Use the B2Brouter API to get a complete list of available document types.

Import Invoices

Import invoices from external sources or systems:

Additional Operations

Account Operations

List Accounts

Retrieve an Account

Create an Account

Update, Delete, and Unarchive

Logo Management

Contact Operations

List Contacts

Create a Contact

Retrieve, Update, and Delete

Tax Reports

Tax reports are automatically generated based on the fiscal obligations of the invoice issuer. For example, issuers subject to Spanish Verifactu requirements will have tax reports automatically created when they send invoices.

Important: Before tax reports can be generated, you must configure your TaxReportSettings for the account. This can be done either:

Once configured, tax reports will contain critical compliance information including QR codes for verification.

Configure Tax Report Settings

Configure Verifactu or TicketBAI settings for your account:

Create Tax Reports Directly

For Point of Sale systems or when not using B2BRouter invoices:

Retrieve Tax Reports

List Tax Reports

Download Tax Report XML

Update Tax Reports (Corrections)

Create corrections (subsanación) for Verifactu tax reports:

Delete Tax Reports (Annullations)

Create annullations (anulación) for tax reports:

Tax Report States

Tax reports go through several states:

For more details, see Tax Reports Documentation.

Spanish Invoicing with Verifactu

B2BRouter provides full compliance with the Spanish Anti-Fraud Law (Law 11/2021) and Verifactu requirements. When you create invoices for Spanish customers, B2BRouter automatically:

Complete Example

For comprehensive information about Spanish invoicing and Verifactu compliance, see the Spanish Invoicing Guide.

Pagination

The SDK provides automatic pagination support through the Collection class:

Paginate Through All Results

Error Handling

The SDK provides specific exception types for different error scenarios:

Request ID Logging

Always log the request ID when reporting errors to support:

Examples

The examples/ directory contains complete working examples demonstrating all SDK features:

Invoice Operations

Tax Reporting

Spanish Compliance

Running Examples

  1. Setup environment variables:

  2. Install dependencies:

  3. Run any example:

All examples automatically load credentials from your .env file via examples/bootstrap.php.

Development

Running Tests

The SDK includes a comprehensive test suite. To run tests:

By default, composer test excludes external integration tests that make real HTTP requests to external services. This keeps the test suite fast and reliable for development.

For more information about contributing, setting up your development environment, and coding standards, see the Developer Guide.

API Reference

Complete Feature Matrix

The SDK provides comprehensive coverage of the B2BRouter API with the following operations:

Invoice Service ($client->invoices)

Method HTTP Endpoint Description
create() POST /accounts/{account}/invoices Create a new invoice
retrieve() GET /invoices/{id} Retrieve invoice details
update() PUT /invoices/{id} Update an existing invoice
delete() DELETE /invoices/{id} Delete an invoice
all() GET /accounts/{account}/invoices List invoices (paginated)
import() POST /accounts/{account}/invoices/import Import invoice from external source
validate() GET /invoices/{id}/validate Validate invoice structure
send() POST /invoices/send_invoice/{id} Send invoice and generate tax reports
acknowledge() POST /invoices/{id}/ack Acknowledge received invoice
markAs() POST /invoices/{id}/mark_as Update invoice state
downloadAs() GET /invoices/{id}/as/{documentType} Download in specified format
downloadPdf() GET /invoices/{id}/as/pdf.invoice Download as PDF (convenience)

Supported Download Formats:

Common Query Parameters:

Tax Report Service ($client->taxReports)

Method HTTP Endpoint Description
create() POST /accounts/{account}/tax_reports Create tax report directly
retrieve() GET /tax_reports/{id} Retrieve tax report with QR code
all() GET /accounts/{account}/tax_reports List tax reports (paginated)
download() GET /tax_reports/{id}/download Download XML representation
update() PATCH /tax_reports/{id} Create correction (subsanación)
delete() DELETE /tax_reports/{id} Create annullation (anulación)

Supported Tax Report Types:

Tax Report States:

Query Parameters:

Tax Report Setting Service ($client->taxReportSettings)

Method HTTP Endpoint Description
create() POST /accounts/{account}/tax_report_settings Configure tax authority settings
retrieve() GET /accounts/{account}/tax_report_settings/{code} Get specific settings
update() PUT /accounts/{account}/tax_report_settings/{code} Update settings
all() GET /accounts/{account}/tax_report_settings List all settings
delete() DELETE /accounts/{account}/tax_report_settings/{code} Delete settings

Common Setting Codes:

Account Service ($client->accounts)

Method HTTP Endpoint Description
all() GET /accounts List accounts (paginated)
create() POST /accounts Create a new account
retrieve() GET /accounts/{id} Retrieve an account
update() PUT /accounts/{id} Update an account
delete() DELETE /accounts/{id} Archive/delete an account
unarchive() POST /accounts/{id}/unarchive Unarchive an account
uploadLogo() POST /accounts/{id}/logo Upload account logo
deleteLogo() DELETE /accounts/{id}/logo Delete account logo

Query Parameters:

Contact Service ($client->contacts)

Method HTTP Endpoint Description
all() GET /accounts/{account}/contacts List contacts (paginated)
create() POST /accounts/{account}/contacts Create a contact
retrieve() GET /contacts/{id} Retrieve a contact
update() PUT /contacts/{id} Update a contact
delete() DELETE /contacts/{id} Delete a contact

Query Parameters:

SDK Architecture

Core Classes

Service Classes

Exception Hierarchy

All exceptions extend ApiErrorException and include:

Configuration Options

Default Values:

Documentation

SDK Documentation

B2BRouter Platform Documentation

Support

When reporting issues, please include:

License

This library is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


All versions of b2brouter-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-curl Version *
ext-json Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package b2brouter/b2brouter-php contains the following files

Loading the files please wait ...