定制 comfino/php-sdk 二次开发

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

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

comfino/php-sdk

Composer 安装命令:

composer require comfino/php-sdk

包简介

Comfino PHP SDK - backend routines for e-commerce platforms integration.

README 文档

README

Comfino

Comfino PHP SDK

Latest Version PHP Version Build Status Software License Total Downloads API Documentation

Comfino PHP SDK with backend routines for e-commerce platforms integration

A complete PHP backend library for integrating any application or e-commerce platform with the Comfino payment gateway API. Whether you are building a custom integration for a closed platform, writing a payment plugin for an open-source e-commerce system, or embedding Comfino financing into your own application, this SDK provides all the backend building blocks you need.

The library covers the full integration lifecycle: API communication, secure webhook handling, configuration management, payment product filtering, category-based eligibility checks, and frontend widget support. All integration points are defined as interfaces, so the SDK adapts to any PHP application stack without imposing a concrete HTTP client, logger, or cache implementation.

Lightweight integration? If you only need the HTTP API layer — requests, responses, DTOs, retry, and auth — without the full plugin infrastructure, you can depend directly on the lower-level package:

composer require comfino/php-api-client

comfino/php-api-client is the standalone API client that this SDK builds upon. It ships the PSR-18 HTTP client, all request/response classes, error types, and the webhook signature verifier, but nothing else. See the php-api-client documentation for details.

Features

  • PSR-18 HTTP Client / PSR-7 Messages / PSR-17 Factories support.
  • PSR-6 cache and PSR-3 logging interfaces.
  • Production and sandbox environment support.
  • Exponential backoff retry for transient API errors.
  • Secure webhook handling with CR-Signature (SHA3-256) verification.
  • Configuration manager with a pluggable storage adapter.
  • Payment product type filter chain based on cart value and category.
  • Hierarchical category tree with ancestor/descendant traversal.
  • Frontend helpers for widget init script and paywall logo authentication.

Requirements

  • PHP 8.1 or higher
  • Extensions: ext-json, ext-sodium, ext-zlib
  • PSR-18 HTTP Client and PSR-17 HTTP Factories implementations
  • Composer

Installation

composer require comfino/php-sdk

Suggested companion packages:

composer require sunrise/http-client-curl                  # PSR-18 cURL client
composer require monolog/monolog                           # PSR-3 logger
composer require cache/filesystem-adapter league/flysystem # PSR-6 filesystem cache

Quick start

use Comfino\Backend\Factory\ApiClientFactory;
use Comfino\Backend\Factory\OrderFactory;
use Comfino\Enum\LoanType;

// 1. Create the API client.
$client = (new ApiClientFactory())->createClient(
    httpClient: $httpClient,
    requestFactory: $requestFactory,
    streamFactory: $streamFactory,
    apiKey: 'your-api-key'
);

// 2. Build an order.
$order = (new OrderFactory())->createOrder(
    orderId: 'ORDER-123',
    orderTotal: 150000, // in cents/grosz
    deliveryCost: 1500, // in cents/grosz
    loanTerm: 12, // months
    loanType: LoanType::INSTALLMENTS_ZERO_PERCENT,
    cartItems: $cartItems,
    customer: $customer,
    returnUrl: 'https://my-shop.com/order/confirm',
    notificationUrl: 'https://my-shop.com/comfino/webhook/status'
);

// 3. Submit the loan application.
$response = $client->createOrder($order);
header('Location: ' . $response->applicationUrl);

Documentation

Topic Guide
Architecture, design patterns, namespace map docs/architecture.md
API client: all operations, error handling, retry docs/api-client.md
Building order, cart and customer objects docs/order-and-cart.md
Webhook handling and custom endpoints docs/webhooks.md
Configuration management docs/configuration.md
Payment filtering and category tree docs/payment-filtering.md
Standalone API client (lightweight integration) comfino/php-api-client

Development

The bin/ wrappers delegate to Docker containers when docker-compose is available, or fall back to the host PHP. Two containers are used:

  • php-sdk — standard container, no Xdebug. Start it once with docker-compose up -d.
  • php-sdk-coverage — built with Xdebug (XDEBUG_MODE=coverage). Started on demand automatically by bin/phpunit whenever a --coverage* flag is detected; no manual up needed.
# Start the standard development container.
docker-compose up -d

# Install dependencies.
./bin/composer install

# Run all tests.
./bin/composer test

# Run unit tests only.
./bin/phpunit --testsuite Unit

# Run integration tests against the sandbox (requires a sandbox API key).
COMFINO_SANDBOX_API_KEY=your-key ./bin/phpunit --testsuite Integration

# Generate HTML coverage report (Xdebug container starts automatically).
./bin/phpunit --coverage-html coverage

# Check PSR-12 code style.
./bin/composer cs

# Auto-fix PSR-12 violations.
./bin/composer cs-fix

# Run PHPStan static analysis (level 6).
./bin/composer analyse

PSR standards

  • PSR-4 autoloading
  • PSR-6 cache
  • PSR-7 HTTP messages
  • PSR-17 HTTP factories
  • PSR-18 HTTP client
  • PSR-12 coding style

Changelog

See CHANGELOG for recent changes.

License

BSD 3-Clause License. See LICENSE for details.

Support

Bug reports and feature requests: GitHub issue tracker.

Contributing

The GitHub repository is a read-only public mirror that receives automated clean-snapshot releases. Please report bugs and suggest improvements via the issue tracker.

comfino/php-sdk 适用场景与选型建议

comfino/php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ecommerce」 「api」 「client」 「payment」 「sdk」 「gateway」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 comfino/php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 comfino/php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-04-17