定制 hotpayments/php-sdk 二次开发

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

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

hotpayments/php-sdk

Composer 安装命令:

composer require hotpayments/php-sdk

包简介

Modern PHP SDK for HotPayments API - Handle payments, subscriptions, PIX transactions with a fluent, easy-to-use interface

README 文档

README

A modern, fluent PHP SDK for the HotPayments API. This SDK provides an easy-to-use interface for integrating HotPayments services into your PHP applications.

Installation

Install the SDK via Composer:

composer require hotpayments/php

Quick Start

Basic Usage

<?php

require_once 'vendor/autoload.php';

use HotPayments\Hotpayments;

// Set your API key
Hotpayments::auth('your-api-key-here');

// Create a customer
$customer = Hotpayments::customers()->create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'phone_number' => '1111111111',
    'document' => '11111111111'
]);

// List customers with pagination
$customers = Hotpayments::customers()->list(['per_page' => 10]);

// Create a PIX QR Code transaction
$transaction = Hotpayments::transactions()->createPixQrCode([
    'amount' => 100.50,
    'customer_id' => 'customer-uuid-here',
    'description' => 'Payment for services'
]);

// Check transaction status
$status = Hotpayments::transactions()->check('transaction-uuid-here');

Authentication

The SDK requires an API key for authentication. You can set it globally using the auth method:

Hotpayments::auth('your-api-key-here');

Services

Customers Service

// Create a new customer
$customer = Hotpayments::customers()->create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'phone_number' => '1111111111',
    'document' => '11111111111'
]);

// List all customers with pagination
$customers = Hotpayments::customers()->list([
    'per_page' => 15,
    'page' => 1
]);

Subscriptions Service

// Create a subscription
$subscription = Hotpayments::subscriptions()->create([
    'customer_id' => 'customer-uuid',
    'plan_id' => 'plan-uuid',
    'payment_method' => 'pix'
]);

// Get subscription details
$subscription = Hotpayments::subscriptions()->show('subscription-uuid');

// Cancel a subscription
$result = Hotpayments::subscriptions()->cancel('subscription-uuid', [
    'reason' => 'Customer requested cancellation'
]);

// Suspend a subscription
$result = Hotpayments::subscriptions()->suspend('subscription-uuid', [
    'reason' => 'Payment failure'
]);

// Reactivate a suspended subscription
$result = Hotpayments::subscriptions()->reactivate('subscription-uuid');

Subscription Plans Service

// List all subscription plans
$plans = Hotpayments::subscriptionPlans()->list([
    'per_page' => 20,
    'currency' => 'BRL'
]);

// Alternative method name
$plans = Hotpayments::subscriptionPlans()->all(['currency' => 'BRL']);

Transactions Service

// Create a PIX QR Code
$qrCode = Hotpayments::transactions()->createPixQrCode([
    'amount' => 150.75,
    'customer_id' => 'customer-uuid',
    'description' => 'Payment description',
    'expires_at' => 3600, // 1 hour in seconds
    'splits' => [
        [
            'slug' => 'partner-company',
            'type' => 'percentage',
            'value' => 10.5
        ]
    ]
]);

// Request a PIX cashout
$cashout = Hotpayments::transactions()->pixCashout([
    'amount' => 100.00,
    'pix_key' => 'user@example.com',
    'customer_id' => 'customer-uuid',
    'description' => 'Cashout request'
]);

// Check transaction status
$transaction = Hotpayments::transactions()->check('transaction-uuid');
echo "Status: " . $transaction['data']['status'];

Laravel Integration

First, add your HotPayments configuration to config/services.php:

'hotpayments' => [
    'key' => env('HOTPAYMENTS_API_KEY'),
],

In your laravel application you can set in your boot method of AppServiceProvider:

use HotPayments\Hotpayments;

public function boot()
{
    Hotpayments::auth(config('services.hotpayments.key'));
}

Then you can use the SDK anywhere in your application:

use HotPayments\Hotpayments;

$customers = Hotpayments::customers()->list();

Error Handling

The SDK provides specific exception classes for different error types:

use HotPayments\Exceptions\ValidationException;
use HotPayments\Exceptions\AuthorizationException;
use HotPayments\Exceptions\HotpaymentsException;

try {
    $customer = Hotpayments::customers()->create([
        'name' => 'John Doe',
        'email' => 'invalid-email', // This will cause a validation error
    ]);
} catch (ValidationException $e) {
    // Handle validation errors
    echo "Validation Error: " . $e->getMessage();
    print_r($e->getErrors()); // Get detailed field errors
} catch (AuthorizationException $e) {
    // Handle authentication/authorization errors
    echo "Auth Error: " . $e->getMessage();
} catch (HotpaymentsException $e) {
    // Handle other API errors
    echo "API Error: " . $e->getMessage();
}

API Reference

Customer Methods

  • create(array $data) - Create a new customer
  • list(array $params = []) - List customers with pagination

Subscription Methods

  • create(array $data) - Create a new subscription
  • show(string $id) - Get subscription details
  • cancel(string $id, array $data = []) - Cancel a subscription
  • suspend(string $id, array $data = []) - Suspend a subscription
  • reactivate(string $id) - Reactivate a suspended subscription

Subscription Plans Methods

  • list(array $params = []) - List subscription plans
  • all(array $params = []) - Alias for list()

Transaction Methods

  • createPixQrCode(array $data) - Create a PIX QR code transaction
  • pixCashout(array $data) - Request a PIX cashout
  • check(string $id) - Check transaction status

Requirements

  • PHP 8.1 or higher
  • cURL extension
  • Fileinfo extension
  • Guzzle HTTP client

Support

For support, please contact contato@hotpayments.net or visit our documentation.

License

This package is open-sourced software licensed under the MIT license.

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-02