pittacusw/touchef
Composer 安装命令:
composer require pittacusw/touchef
包简介
Wrapper to connect a Laravel application to the Touchef API
README 文档
README
Small Laravel wrapper around the Touchef API for Chilean electronic invoicing workflows.
It provides:
- A
Touchefservice class for the Touchef HTTP API - Laravel service provider + facade auto-discovery
- Config driven credentials via
TOUCHEF_RUTandTOUCHEF_TOKEN - Publishing for package config and the bundled Codex agent skill
Requirements
- PHP 8.1+
- Laravel 9.23, 12.x, or 13.x
Installation
composer require pittacusw/touchef
Publish the package config if you want a local config file:
php artisan vendor:publish --tag=touchef-config
Add your credentials to .env:
TOUCHEF_RUT=76111111-1 TOUCHEF_TOKEN=
Usage
Resolve from the container
use Pittacusw\Touchef\Touchef; $touchef = app(Touchef::class);
Use the facade
use Touchef; $business = Touchef::info();
Instantiate directly
use Pittacusw\Touchef\Touchef; $touchef = new Touchef(); // Override the configured RUT for this runtime instance. $touchef = new Touchef('76123456-7');
Authentication
$touchef->login('your-password'); $token = $touchef->refresh(); $touchef->logout();
login() and refresh() update the in-memory config token and also persist TOUCHEF_TOKEN to .env when that file exists. login() also persists the active TOUCHEF_RUT.
Common operations
Tenant and reference data
$info = $touchef->info(); $counties = $touchef->counties(); $activities = $touchef->economic_activities(); $lookup = $touchef->get_data('12345678-9');
Sales
$sales = $touchef->sales(2025, 3); $summary = $touchef->sales_summary(2025, 3); $sale = $touchef->sale('uuid-value'); $byNumber = $touchef->show_by_number(33, 1200); $track = $touchef->track_id(77); $siiStatus = $touchef->sii_status(77); $providerStatus = $touchef->provider_status(77); $pdf = $touchef->get_pdf(33, 1200); $touchef->send_email(1200, 33);
Create a document
$document = $touchef->create_document( document_type: 33, issued_at: '2025-03-15', lines: [[ 'name' => 'Servicio', 'quantity' => 1, 'unit_price' => 10000, ]], mode: 'issue', receiver: [ 'rut' => '98765432-1', 'name' => 'Cliente SpA', 'activity' => 'Servicios', 'address' => 'Av. Siempre Viva 123', 'county' => 'Santiago', ], payment: [ 'due_date' => '2025-04-15', ], notifications: ['facturacion@cliente.cl'], );
Optional payload sections supported by create_document():
receiverglobal_adjustmentsreferencestransportpaymentnotifications
Queue documents
$queued = $touchef->queue_documents([ [ 'document_type' => 33, 'issued_at' => '2025-03-15', 'receiver' => [ 'rut' => '98765432-1', 'name' => 'Cliente SpA', 'activity' => 'Servicios', 'address' => 'Av. Siempre Viva 123', 'county' => 'Santiago', ], 'lines' => [[ 'name' => 'Servicio', 'quantity' => 1, 'unit_price' => 10000, ]], ], ]);
Expenses
$expenses = $touchef->expenses(2025, 3); $summary = $touchef->expenses_summary(2025, 3); $expense = $touchef->expense('uuid-value'); $pending = $touchef->pending(); $accepted = $touchef->manage_expense(42, 'ACD');
Supported expense management codes:
ACDRCDRFPRFT
Business management
$updated = $touchef->update_client( county: 1, economic_activity: 5, name: 'Mi Empresa SpA', rut: '12345678-9', activity: 'Servicios de software', address: 'Av. Providencia 1234', resolution_date: '2020-01-15', resolution_number: 80, email: 'admin@miempresa.cl', ); $created = $touchef->create_client( county_id: 1, economic_activity_id: 5, name: 'Nueva Empresa SpA', rut: '12345678-9', activity: 'Servicios de software', address: 'Av. Providencia 1234', resolution_date: '2020-01-15', resolution_number: 80, email: 'admin@nuevaempresa.cl', password: 'securepassword123', website: 'https://nuevaempresa.cl', );
Certificates and folios
$certificate = $touchef->certificate(); $updated = $touchef->update_certificate(storage_path('certs/company.pfx'), 'pfx-password'); $caf = $touchef->caf();
Response behavior
Most wrapper methods expect the API to return a JSON object containing records and will return that value directly.
The exception is queue_documents(), which returns the full decoded object and expects a queued property.
Failed HTTP responses abort with the response status code.
Agent skill publishing
This package also ships with a Codex skill for Touchef-specific workflows. You can publish it with:
php artisan vendor:publish --tag=touchef-agent-skill
Or via the dedicated command:
php artisan touchef:install-agent-skill
That publishes the skill into:
.agents/skills/touchef
Testing
composer test
Notes
- The wrapper sends the
businessheader using the configured RUT formatted byfreshwork/chilean-bundle. - The bearer token is only attached when
TOUCHEF_TOKENis present. update_certificate()now throws aRuntimeExceptionif the provided certificate file cannot be read.
pittacusw/touchef 适用场景与选型建议
pittacusw/touchef 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 08 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「chile」 「dte」 「sii」 「facturacion-electronica」 「touchef」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pittacusw/touchef 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pittacusw/touchef 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pittacusw/touchef 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LibreDTE: Biblioteca PHP (Núcleo)
PHP SDK for signing Documentos Tributarios Electrónicos (DTE) for El Salvador using JWS RS512
Cliente para realizar la integración con los servicios web de LibreDTE desde PHP.
Consulta de indicadores al API de la SBIF (Chile)
This class is able to do integrity verification on chilean RUTs and RUNs
SDK para integrar Simple Factura
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2022-08-06