PHPackages                             code-lives/byte-pay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. code-lives/byte-pay

ActiveLibrary[Payment Processing](/categories/payments)

code-lives/byte-pay
===================

头条小程序支付、支付、异步通知、查询、退款、分账、获取token

0339PHP

Since Oct 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/code-lives/byte-pay)[ Packagist](https://packagist.org/packages/code-lives/byte-pay)[ RSS](/packages/code-lives-byte-pay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

头条小程序担保支付（点个收藏是我前进的动力）
======================

[](#头条小程序担保支付点个收藏是我前进的动力)

[官方接口文档](https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/server/ecpay/introduction/)

Config 参数
=========

[](#config-参数)

参数名字类型必须说明tokenstring是担保交易的Token(令牌)saltstring是担保交易的SALTmerchant\_idstring是担保交易的商户号app\_idint是小程序的APP\_IDsecretstring是小程序的APP\_SECRETConfig
------

[](#config)

```
	 $config = [
        'token' => '',
        'salt' => '',
        'merchant_id' => '',
        'app_id' => '',
        'secret' => ''
    ];
```

获取token
-------

[](#获取token)

```
     $result = (new \Demo\test\Order($config))->getToken();
        if($result['status'] !== true) {
           print_R($result['message']);exit
        }

    echo $result['response']['data'];//token
```

支付
--

[](#支付)

```
    $result = (new \Demo\test\Order($config))->getOrder([

        'out_order_no' => time() . "", // 开发者订单号
        'total_amount' => 0.01, // 支付金额 单位: 分
        'subject' => '测试-tt-支付', // 商品描述
        'body' => '测试支付系统', // 商品详情
        'notify_url' => '' // 自定义回调地址

    ]);
    //下单成功
    if ($result['status'] === true) {
        //返回的订单号
        $order = [
            'order_id' => $result['response']['data']['order_id'],
            'order_token' => $result['response']['data']['order_token']
        ];
    }
```

订单查询
----

[](#订单查询)

```
    $result = (new \Demo\test\Order($config))->query([
            'out_order_no' => request()->param('order', '') // 商户订单号
        ]);

    if($result['status'] === false) {
        //查询失败
        print_R($result['message']);exit
    }

    if ($result['status'] === true) {
        //返回的订单号
        $order = [
            'out_order_no' => $result['response']['out_order_no'], // 商户订单号
            'order_id' => $result['response']['order_id'],
            'detail' => $result['response']['payment_info']；
    }
```

退款
--

[](#退款)

```
    $result = (new \Demo\test\Refund($config))->refund([
        'out_order_no' => $order,
        'out_refund_no' => $order . 'refund',
        'reason' => '就想退款，咋滴',
        'refund_amount' => 10,//退款金额，单位[分]
        'notify_url' => ''
    ]);

    if($result['status'] === false) {
        //查询失败
        print_R($result['message']);exit
    }
    echo $result['response']['refund_no'];//担保交易服务端退款单号
```

异步回调
----

[](#异步回调)

```
     if((new \Demo\test\TTPay($config))->callbackAuth($_POST) !== true) {

        return json_encode(['err_no' => -1, 'err_tips' => '签名验证失败']);

     }
    $data = json_decode($_POST['msg']), true);

    switch ($_POST['type']) {
            case 'payment':
                //支付成功操作 开发者 订单号$data['cp_orderno']
                break;
            case 'refund':
                //退款回调操作
                break;
            case 'settle':
                //
                break;
            default:
                return json_encode(['err_no' => -1, 'err_tips' => '事件异常']);
    }
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/66c8ab94602f8fde6cbb339ec8b9b0dbd178b1aeab8973d957e3903d14e2b7be?d=identicon)[code-lives](/maintainers/code-lives)

---

Top Contributors

[![code-lives](https://avatars.githubusercontent.com/u/79346591?v=4)](https://github.com/code-lives "code-lives (4 commits)")

### Embed Badge

![Health badge](/badges/code-lives-byte-pay/health.svg)

```
[![Health](https://phpackages.com/badges/code-lives-byte-pay/health.svg)](https://phpackages.com/packages/code-lives-byte-pay)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
