ichavezrg/heybanco-client
Composer 安装命令:
composer require ichavezrg/heybanco-client
包简介
Cliente PHP para la API de HeyBanco
README 文档
README
Cliente PHP para la API de HeyBanco que proporciona una interfaz simple y elegante para interactuar con los servicios CAAS (Customer as a Service) de HeyBanco.
Características
- ✅ Autenticación mTLS: Soporte completo para autenticación mutua TLS
- ✅ Firma digital: Implementación de firmas JWE/JWS para seguridad
- ✅ CAAS Services: Soporte para Agreement, Collection y User services
- ✅ PSR-4: Autoloading compatible con PSR-4
- ✅ PHP 8.1+: Aprovecha las características modernas de PHP
- ✅ Guzzle HTTP: Cliente HTTP robusto y confiable
Instalación
Puedes instalar el paquete vía Composer:
composer require ichavez/heybanco-client
Requisitos
- PHP 8.1 o superior
- Extensión cURL
- Extensión JSON
- Certificados mTLS válidos de HeyBanco
Uso Básico
Configuración Inicial
<?php require_once 'vendor/autoload.php'; use Ichavez\HeyBancoClient\Client; use Ichavez\HeyBancoClient\Auth; use Ichavez\HeyBancoClient\Signature; use Ichavez\HeyBancoClient\Caas; use Ichavez\HeyBancoClient\HeyBancoClient; // Configuración de conexión $bApplication = "tu-b-application-id"; $mtlsKeystorePath = 'path/to/your/keystore.p12'; $mtlsKeystorePassword = 'tu-keystore-password'; // Crear cliente base $client = new Client( host: 'https://sbox-api-tech.hey.inc', bApplication: $bApplication, mtlsKeystorePath: $mtlsKeystorePath, mtlsKeystorePassword: $mtlsKeystorePassword ); // Configurar autenticación $auth = new Auth($client); // Configurar firma digital $signature = new Signature( bApplication: $bApplication, mtlsCertificatePath: $mtlsKeystorePath, mtlsCertificatePassword: $mtlsKeystorePassword, privateKeyPath: 'path/to/private_key.pem', privateKeyPhrase: '', publicServerKeyPath: 'path/to/server_public_key.pem' ); // Inicializar servicios CAAS $caas = new Caas( new Caas\Agreement($client, $auth, $signature), new Caas\Collection($client, $auth), new Caas\User($client, $auth) ); // Crear cliente principal $heybanco = new HeyBancoClient($caas);
Trabajar con Agreements
// Obtener agreements $agreements = $heybanco->caas->agreement->find( accountNumber: '220914510015', bTransaction: 'unique-transaction-id', clientId: 'your-client-id', clientSecret: 'your-client-secret' );
Trabajar con Collections
// Operaciones con collections $collections = $heybanco->caas->collection->find($agreementId);
Trabajar con Users
// Operaciones con usuarios $users = $heybanco->caas->user->find($agreementId);
Configuración de Entorno
Variables de Entorno
Se recomienda usar variables de entorno para datos sensibles:
# .env
HEYBANCO_B_APPLICATION=tu-b-application-id
HEYBANCO_HOST=https://sbox-api-tech.hey.inc
HEYBANCO_MTLS_KEYSTORE_PATH=/path/to/keystore.p12
HEYBANCO_MTLS_KEYSTORE_PASSWORD=tu-password
HEYBANCO_PRIVATE_KEY_PATH=/path/to/private_key.pem
HEYBANCO_PUBLIC_SERVER_KEY_PATH=/path/to/server_public_key.pem
HEYBANCO_CLIENT_ID=tu-client-id
HEYBANCO_CLIENT_SECRET=tu-client-secret
Ejemplo con Variables de Entorno
$client = new Client( host: $_ENV['HEYBANCO_HOST'], bApplication: $_ENV['HEYBANCO_B_APPLICATION'], mtlsKeystorePath: $_ENV['HEYBANCO_MTLS_KEYSTORE_PATH'], mtlsKeystorePassword: $_ENV['HEYBANCO_MTLS_KEYSTORE_PASSWORD'] );
Manejo de Errores
try { $agreements = $heybanco->caas->agreement->getAgreements( accountNumber: '220914510015', bTransaction: 'unique-transaction-id', clientId: 'your-client-id', clientSecret: 'your-client-secret' ); } catch (\Exception $e) { echo "Error: " . $e->getMessage(); }
Testing
Ejecutar las pruebas:
# Ejecutar todas las pruebas composer test # Ejecutar pruebas con coverage composer test-coverage # Análisis estático con PHPStan composer phpstan # Verificar estilo de código composer cs-check # Corregir estilo de código automáticamente composer cs-fix
Desarrollo
Estructura del Proyecto
src/
├── Auth.php # Manejo de autenticación
├── Client.php # Cliente HTTP base
├── HeyBancoClient.php # Cliente principal
├── Signature.php # Manejo de firmas digitales
├── Caas.php # Contenedor de servicios CAAS
└── Caas/
├── Agreement.php # Servicio de agreements
├── Collection.php # Servicio de collections
└── User.php # Servicio de usuarios
Contribuir
- Fork el proyecto
- Crea una rama para tu feature (
git checkout -b feature/nueva-funcionalidad) - Commit tus cambios (
git commit -am 'Agrega nueva funcionalidad') - Push a la rama (
git push origin feature/nueva-funcionalidad) - Crea un Pull Request
Seguridad
Si descubres alguna vulnerabilidad de seguridad, por favor envía un email a ichavez@redgirasol.com en lugar de usar el issue tracker.
Licencia
Este paquete es software de código abierto licenciado bajo la Licencia MIT.
Changelog
Por favor consulta CHANGELOG para más información sobre los cambios recientes.
Créditos
Soporte
ichavezrg/heybanco-client 适用场景与选型建议
ichavezrg/heybanco-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.44k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「client」 「Banking」 「fintech」 「caas」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ichavezrg/heybanco-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ichavezrg/heybanco-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ichavezrg/heybanco-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
统计信息
- 总下载量: 1.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-10