定制 payzcore/payzcore-php 二次开发

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

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

payzcore/payzcore-php

Composer 安装命令:

composer require payzcore/payzcore-php

包简介

Official PHP SDK for PayzCore - Blockchain Transaction Monitoring API

README 文档

README

Official PHP SDK for the PayzCore blockchain transaction monitoring API.

Important

PayzCore is a blockchain monitoring service, not a payment processor. All payments are sent directly to your own wallet addresses. PayzCore never holds, transfers, or has access to your funds.

  • Your wallets, your funds — You provide your own wallet (HD xPub or static addresses). Customers pay directly to your addresses.
  • Read-only monitoring — PayzCore watches the blockchain for incoming transactions and sends webhook notifications. That's it.
  • Protection Key security — Sensitive operations like wallet management, address changes, and API key regeneration require a Protection Key that only you set. PayzCore cannot perform these actions without your authorization.
  • Your responsibility — You are responsible for securing your own wallets and private keys. PayzCore provides monitoring and notification only.

Requirements

  • PHP 8.1+
  • ext-curl
  • ext-json
  • ext-hash

Installation

Composer (recommended)

composer require payzcore/payzcore-php

Manual

Download the src/ directory and use PSR-4 autoloading, or require files manually.

Quick Start

<?php

require_once 'vendor/autoload.php';

use PayzCore\PayzCore;

$payzcore = new PayzCore('pk_live_your_api_key');

// Create a payment monitoring request (network specified)
$result = $payzcore->payments->create([
    'amount' => 50,
    'externalRef' => 'user-123',
    'network' => PayzCore::NETWORK_TRC20,  // optional
    'metadata' => ['type' => 'topup'],
]);

echo $result['payment']['address']; // Deposit address
echo $result['payment']['amount'];  // Amount with random cents
echo $result['payment']['token'];   // 'USDT'

// Or let the customer choose the network on the payment page
$result = $payzcore->payments->create([
    'amount' => 50,
    'externalRef' => 'user-123',
]);

echo $result['payment']['awaitingNetwork'];   // true
echo $result['payment']['paymentUrl'];        // 'https://app.payzcore.com/pay/xxx'
print_r($result['payment']['availableNetworks']); // [{network, name, tokens}, ...]

Supported Networks & Tokens

Networks

Constant Value Blockchain
PayzCore::NETWORK_TRC20 TRC20 Tron
PayzCore::NETWORK_BEP20 BEP20 BNB Smart Chain
PayzCore::NETWORK_ERC20 ERC20 Ethereum
PayzCore::NETWORK_POLYGON POLYGON Polygon
PayzCore::NETWORK_ARBITRUM ARBITRUM Arbitrum

All networks: PayzCore::NETWORKS

Tokens

Constant Value
PayzCore::TOKEN_USDT USDT
PayzCore::TOKEN_USDC USDC

All tokens: PayzCore::TOKENS

Note: Token defaults to USDT when omitted, preserving backward compatibility.

Usage

Payments

// Create payment (USDT on TRC20)
$result = $payzcore->payments->create([
    'amount' => 100,
    'externalRef' => 'order-456',
    'network' => PayzCore::NETWORK_TRC20,  // optional
]);

// Create payment with explicit token
$result = $payzcore->payments->create([
    'amount' => 100,
    'externalRef' => 'order-456',
    'network' => PayzCore::NETWORK_BEP20,
    'token' => PayzCore::TOKEN_USDC,     // optional, defaults to 'USDT'
    'externalOrderId' => 'INV-001',       // optional
    'expiresIn' => 3600,                  // optional, seconds (300-86400)
    'metadata' => ['plan' => 'pro'],      // optional
    'address' => 'Txxxx...',             // optional, static wallet dedicated mode only
]);

echo $result['payment']['network'];  // 'BEP20'
echo $result['payment']['token'];  // 'USDC'
// Static wallet projects may also return: $result['payment']['notice'],
// $result['payment']['original_amount'], $result['payment']['requires_txid']

// List payments
$result = $payzcore->payments->list([
    'status' => 'paid',  // optional: pending, confirming, partial, paid, overpaid, expired, cancelled
    'limit' => 20,       // optional
    'offset' => 0,       // optional
]);

foreach ($result['payments'] as $payment) {
    echo $payment['id'] . ': ' . $payment['status'] . ' (' . $payment['token'] . ")\n";
}

// Get payment details (latest cached status from database)
$result = $payzcore->payments->get('payment-uuid');
$payment = $result['payment'];

echo $payment['status'];
echo $payment['paidAmount'];
echo $payment['token'];  // 'USDT' or 'USDC'

foreach ($payment['transactions'] as $tx) {
    echo $tx['txHash'] . ': ' . $tx['amount'] . "\n";
}

// Cancel a pending payment
$result = $payzcore->payments->cancel('payment-uuid');
// $result['payment']['status'] === 'cancelled'

// Submit tx hash for verification (pool + txid mode)
$result = $payzcore->payments->confirm('payment-uuid', 'abc123def456...');
// $result['verified'], $result['status'], $result['amount_received']

Projects (Master Key)

use PayzCore\PayzCore;

$admin = new PayzCore('mk_your_master_key', ['masterKey' => true]);

// Create project
$result = $admin->projects->create([
    'name' => 'My Store',
    'slug' => 'my-store',
    'webhookUrl' => 'https://example.com/webhook',
]);

echo $result['project']['apiKey'];       // pk_live_xxx
echo $result['project']['webhookSecret']; // whsec_xxx

// List projects
$result = $admin->projects->list();

Webhook Verification

use PayzCore\Webhook;
use PayzCore\Exceptions\WebhookSignatureException;

$body = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_PAYZCORE_SIGNATURE'] ?? '';
$secret = 'whsec_your_webhook_secret';

try {
    $event = Webhook::constructEvent($body, $signature, $secret);

    switch ($event['event']) {
        case 'payment.completed':
            // Handle completed payment
            $paymentId = $event['paymentId'];
            $amount = $event['paidAmount'];
            $ref = $event['externalRef'];
            $network = $event['network'];   // e.g. 'TRC20'
            $token = $event['token'];   // e.g. 'USDT' or 'USDC'
            break;

        case 'payment.overpaid':
            // Handle overpayment
            break;

        case 'payment.expired':
            // Handle expiry
            break;

        case 'payment.partial':
            // Handle partial payment
            break;

        case 'payment.cancelled':
            // Handle cancellation
            break;
    }

    http_response_code(200);
    echo json_encode(['ok' => true]);

} catch (WebhookSignatureException $e) {
    http_response_code(401);
    echo json_encode(['error' => 'Invalid signature']);
}

You can also verify the signature without parsing:

$isValid = Webhook::verifySignature($body, $signature, $secret);

Before Going Live

Always test your setup before accepting real payments:

  1. Verify your xPub — In the PayzCore dashboard, click "Verify Key" when adding your wallet. Compare address #0 with your wallet app's first receiving address. They must match.
  2. Send a test payment — Create a monitoring request for $1–5 and send the funds to the assigned address. Verify they arrive in your wallet.
  3. Test sweeping — Send the test funds back out to confirm you control the derived addresses with your private keys.

Warning: A wrong xPub key generates addresses you don't control. Funds sent to those addresses are permanently lost. PayzCore is watch-only and cannot recover funds. Please take 2 minutes to verify.

Configuration

$payzcore = new PayzCore('pk_live_xxx', [
    'baseUrl' => 'https://api.payzcore.com', // API base URL
    'timeout' => 30,                          // Request timeout in seconds
    'maxRetries' => 2,                        // Max retries on 5xx errors
    'masterKey' => false,                     // Use x-master-key header
]);

Error Handling

use PayzCore\Exceptions\PayzCoreException;
use PayzCore\Exceptions\AuthenticationException;
use PayzCore\Exceptions\ForbiddenException;
use PayzCore\Exceptions\NotFoundException;
use PayzCore\Exceptions\ValidationException;
use PayzCore\Exceptions\RateLimitException;
use PayzCore\Exceptions\IdempotencyException;

try {
    $result = $payzcore->payments->create([...]);
} catch (ValidationException $e) {
    // 400 - Invalid parameters
    echo $e->getMessage();
    print_r($e->getDetails()); // Validation error details
} catch (AuthenticationException $e) {
    // 401 - Invalid API key
} catch (ForbiddenException $e) {
    // 403 - Access denied
} catch (NotFoundException $e) {
    // 404 - Resource not found
} catch (RateLimitException $e) {
    // 429 - Rate limited
    echo $e->getRetryAfter(); // Seconds until reset (or null)
    echo $e->isDaily();       // Whether this is a daily limit
} catch (IdempotencyException $e) {
    // 409 - external_order_id reused with different external_ref
} catch (PayzCoreException $e) {
    // Other API errors (5xx, etc.)
    echo $e->getStatusCode();
    echo $e->getErrorCode();
}

Static Wallet Mode

When the PayzCore project is configured with a static wallet, the API works the same way but may return additional fields in the response:

Field Type Description
notice string Instructions for the payer (e.g. "Send exact amount")
original_amount string The original requested amount before any adjustments
requires_txid bool Whether the payer must submit their transaction ID

In dedicated address mode, you can specify which static address to assign to a customer using the address parameter on payment creation. In shared address mode, the project's single static address is used automatically.

Note: The address parameter is only used with static wallet projects in dedicated mode. For HD wallet projects, this parameter is ignored.

Token Parameter

The token parameter is optional. If omitted in create(), the API defaults to USDT. Response and webhook payloads always include a token field.

See Also

License

MIT

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-26