定制 ichavezrg/heybanco-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ichavezrg/heybanco-client

Composer 安装命令:

composer require ichavezrg/heybanco-client

包简介

Cliente PHP para la API de HeyBanco

README 文档

README

Latest Version Total Downloads License

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

  1. Fork el proyecto
  2. Crea una rama para tu feature (git checkout -b feature/nueva-funcionalidad)
  3. Commit tus cambios (git commit -am 'Agrega nueva funcionalidad')
  4. Push a la rama (git push origin feature/nueva-funcionalidad)
  5. 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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-10