PHPackages                             gangangan/baic - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gangangan/baic

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gangangan/baic
==============

BAIC简化版 PHP SDK。

2101PHP

Since Sep 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/GanGanGan/baic)[ Packagist](https://packagist.org/packages/gangangan/baic)[ RSS](/packages/gangangan-baic/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Baic
====

[](#baic)

基于Baic网关的 PHP 简单组件。

安装
--

[](#安装)

```
$ composer require gangangan/baic -vvv
```

配置
--

[](#配置)

在使用本扩展之前，你需要去 \[BAIC商户后台\] 注册账号，然后创建应用，获取应用的 APP Id与Key。

使用
--

[](#使用)

```
use Gangangan\Baic\Baic;

$sdkId = 'Your sdkId';
$appKey = 'Your appKey';

$baic = new Baic($sdkId, $appKey);
```

> ### 1.获取Token
>
> [](#1获取token)
>
> ```
> $response = $baic->getToken();
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "success": "true",
>    "message": "获取成功！",
>    "token": "1252002bd3ff4a418b24b331cd28b0c4"
> }
> ```
>
>
>
> 参数参数类型参数说明successString是否校验成功:true成功;false不成功messageString相应信息tokenStringToken

> ### 2.获取Porder
>
> [](#2获取porder)
>
> ```
> $data = [
>    'token' => '1252002bd3ff4a418b24b331cd28b0c4',  //获取的token
>    'sdkId' => $sdkId,                              //自己的sdkId
>    'orderAmount' => 10,                            //单位
>    'currencyType' => 'BAIC',                       //币种
>    'orderNo' => '12121212',                        //自己系统中的订单号
> ];
> $response = $baic->getPorder($data);
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "success": "true",
>    "message": "請求成功！",
>    "porder": "yh4ea65gh41ae65t4pxm-123123-999-1534925308319-BAIC"
> }
> ```

拿到porder后生成二维码，然后钱包APP扫码进行后续操作

> ### 3.查询订单根据时间
>
> [](#3查询订单根据时间)
>
> ```
> $data = [
>    'token' => '1252002bd3ff4a418b24b331cd28b0c4',      //token
>    'sdkId' => $sdkId,                                  //自己的sdkId
>    'beginTime' => '1534038254774',                     //开始时间
>    'endTime' => '1534239254774',                       //结束时间
>    'merchantId' => 'asdasdasdasdasd',                  //商户ID
> ];
> $response = $baic->selectOrderByTime($data);
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "data": [
>        {
>            "currencyType": "USDT",
>            "orderAmount": 1,
>            "walletAccount": "216778721177910-0003",
>            "transactionNo": "1808143532200921700720",
>            "refundList": [
>                {
>                    "currencyType": "USDT",
>                    "transactionType": 1,
>                    "refundNo": "1808143551139775261736",
>                    "refundTime": 1535009861000,
>                    "operator": "李四",
>                    "refundAmount": 0.5,
>                    "isSuccess": 1
>                }
>            ],
>            "transactionTime": 1534235335000,
>            "verifyFailureReasons": null,
>            "isSuccess": 1
>        }
>    ],
>    "success": "true",
>    "message": "查詢成功!"
> }
> ```
>
>
>
> 参数参数类型参数说明currencyTypeString币种orderAmountString交易金额walletAccountString钱包账号transactionNoString交易号transactionTimeDate交易时间verifyFailureReasonsString参数校验失败原因isSuccessInt是否成功refundList的数据结构：------refundAmountBigDecimal退款金额currencyTypeString币种isSuccessInt是否操作成功refundNoString退款流水号refundTimeDate退款时间operatorString操作人transactionTypeByte交易类型:0:购买,1:退货

> ### 4.查询订单根据页数
>
> [](#4查询订单根据页数)
>
> ```
> $data = [
>    'token' => '1252002bd3ff4a418b24b331cd28b0c4',      //token
>    'sdkId' => $sdkId,                                  //自己的sdkId
>    'limit' => 10,                                      //开始时间
>    'page' => 1,                                        //结束时间
> ];
> $response = $baic->selectOrderByPage($data);
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "data": [
>        {
>            "currencyType": "BAIC",
>            "orderAmount": 30.432444,
>            "walletAccount": null,
>            "transactionNo": "1808223643283327367154",
>            "transactionTime": 1535008977000,
>            "verifyFailureReasons": null,
>            "isSuccess": null
>        }
>    ],
>    "success": "true",
>    "message": "查詢成功!"
> }
> ```

> ### 5.查询订单根据交易号
>
> [](#5查询订单根据交易号)
>
> ```
> $data = [
>    'token' => '1252002bd3ff4a418b24b331cd28b0c4',      //token
>    'sdkId' => $sdkId,                                  //自己的sdkId
>    'transactionNo' => '1808223643283327367154',        //交易号
> ];
> $response = $baic->selectByTransactionNo($data);
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "data": {
>        "currencyType": "BAIC",
>        "orderNo": "123e123r4312r1233",
>        "orderAmount": 30.432444,
>        "isRefund": false,
>        "walletAccount": null,
>        "transactionNo": "1808223643283327367154",
>        "transactionTime": 1535008977000,
>        "operator": "999",
>        "verifyFailureReasons": null,
>        "merchantName": "海灵顿",
>        "isSuccess": null,
>        "refundAmount": null
>    },
>    "success": "true",
>    "message": "查詢成功!"
> }
> ```
>
>
>
> 参数参数类型参数说明orderNoString订单号transactionNoString交易号transactionTimeDate订单时间walletAccountString钱包账号orderAmountBigDecimal订单金额merchantNameString商户名字currencyTypeString币种operatorString操作人isSuccessByte是否操作成功varifyFailureReasonsString参数校验失败原因isRefundboolean是否退款refundAmountBigDecimal退款金额

> ### 6.查询退款根据交易号
>
> [](#6查询退款根据交易号)
>
> ```
> $data = [
>    'token' => '1252002bd3ff4a418b24b331cd28b0c4',      //token
>    'sdkId' => $sdkId,                                  //自己的sdkId
>    'transactionNo' => '1808223225350327327962',        //交易号
> ];
> $response = $baic->selectRefundByTransactionNo($data);
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "data": {
>        "currencyType": "BAIC",
>        "orderNo": "312312323",
>        "orderAmount": 1,
>        "isRefund": false,
>        "walletAccount": "218606395509603-0003",
>        "transactionNo": "1808223225350327327962",
>        "transactionTime": 1535008975000,
>        "operator": "0258b2a6-cfd6-4c46-8577-a3d922c83e00",
>        "verifyFailureReasons": null,
>        "merchantName": "全家",
>        "isSuccess": 1,
>        "refundAmount": null
>    },
>    "success": "true",
>    "message": "查詢成功!"
> }
> ```

> ### 7.查询退款根据页数
>
> [](#7查询退款根据页数)
>
> ```
> $data = [
>    'token' => '1252002bd3ff4a418b24b331cd28b0c4',      //token
>    'sdkId' => $sdkId,                                  //自己的sdkId
>    'limit' => 1,                                       //一页几个
>    'page' => 1,                                        //第几页
> ];
> $response = $baic->selectRefundRecordByPage($data);
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "data": [
>        {
>            "currencyType": "USDT",
>            "orderNo": "20180807095633656",
>            "refundNo": "1808141677440091440840",
>            "refundTime": 1535009861000,
>            "walletAccount": "216778721177910-0003",
>            "transactionNo": "1808073579226312821320",
>            "verifyFailureReasons": null,
>            "isSuccess": 1,
>            "refundAmount": 1
>        }
>    ],
>    "success": "true",
>    "message": "查詢成功!"
> }
> ```

> ### 8.退款操作
>
> [](#8退款操作)
>
> ```
> $data = [
>    'token' => '1252002bd3ff4a418b24b331cd28b0c4',      //token
>    'sdkId' => $sdkId,                                  //自己的sdkId
>    'merchantId' => 'asdasdasdasdasd',                  //商户ID
>    'transactionNo' => '1808223225350327327962',        //交易号
>    'refundAmount' => 0.001,                            //退款金额
> ];
> $response = $baic->sdkRefundRequest($data);
> ```
>
>
>
> 响应示例：
>
> ```
> {
>    "data": {
>        "currencyType": "USDT",
>        "orderNo": "20180828091308354",
>        "refundNo": "1808285041352509149216",
>        "transactionNo": "1808284759253919660144",
>        "isSuccess": 1,
>        "refundAmount": 0.001
>    },
>    "success": "true",
>    "message": "请求成功!"
> }
> ```

参考
--

[](#参考)

- \[BAIC网关接口\]

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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

---

Top Contributors

[![GanGanGan](https://avatars.githubusercontent.com/u/14269654?v=4)](https://github.com/GanGanGan "GanGanGan (2 commits)")

### Embed Badge

![Health badge](/badges/gangangan-baic/health.svg)

```
[![Health](https://phpackages.com/badges/gangangan-baic/health.svg)](https://phpackages.com/packages/gangangan-baic)
```

PHPackages © 2026

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