PHPackages                             chenjianeng0201/paygent - 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. chenjianeng0201/paygent

ActiveLibrary[Payment Processing](/categories/payments)

chenjianeng0201/paygent
=======================

A paygent SDK.

3135PHP

Since Sep 7Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

Paygent
=======

[](#paygent)

包含信用卡支付和后支付
-----------

[](#包含信用卡支付和后支付)

[![StyleCI build status](https://camo.githubusercontent.com/939a8fc69bb728422d06421ed755273eb273be9e1687930a22173faeb1c78eb2/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3230363330373135362f736869656c64)](https://camo.githubusercontent.com/939a8fc69bb728422d06421ed755273eb273be9e1687930a22173faeb1c78eb2/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3230363330373135362f736869656c64)

安装
--

[](#安装)

composer require chenjianeng0201/paygent:dev-master -vvv

配置
--

[](#配置)

需要拥有 Paygent 相关证书、私钥、及配置参数

使用
--

[](#使用)

```
use Chenjianeng0201\Paygent\Paygent;

$env = 'local';  // 环境 [local、production]
$merchant_id = 'xxxxx'; // merchant_id
$connect_id = 'xxxxxx'; // 连接 id
$connect_password = 'xxxxxx'; // 连接密码
$pem = 'xxxxxxxxxxx'; // 证书路径
$crt = 'xxxxxxx'; //私钥路径
$telegram_version = '1.0'; // 版本，默认 1.0

$p = new Paygent($env, $merchant_id, $connect_id, $connect_password, $pem, $crt, $telegram_version);

```

### 前台 Token 获取参考代码

[](#前台-token-获取参考代码)

```

        请求

        示例: test12345678

        示例: 4023123456780000

        示例: 19

        示例: 09

        示例: 123

        示例: user

        示例: 1

    提交

    form {
        padding-left: 15px;
    }

    p {
        color: red;
    }

    .t {
        margin: 0;
    }

    .form-group {
        margin-bottom: 0;
    }

    .form-control {
        width: 40%;
    }

    function checkSubmit() {
        var card_number = $('input[name=card_number]').val()
        var expire_year = $('input[name=expire_year]').val()
        var expire_month = $('input[name=expire_month]').val()
        var cvc = $('input[name=cvc]').val()
        var name = $('input[name=number]').val()

        var paygentToken = new PaygentToken()
        paygentToken.createToken(
            'xxxxx', // merchant_id
            'xxxxxxxxxxxxxxx', // token
            {
                card_number: card_number, // 卡号
                expire_year: expire_year, // 有效年 19
                expire_month: expire_month, // 有效月 09
                cvc: cvc, // 安全码
                name: name, // 用户名
            }, execPurchase
        )
        return false
    }

    function execPurchase(response) {
        var msg = '';
        switch (response.result) {
            case '0000':
                $('input[name=card_token]').val(response.tokenizedCardObject.token);
                $('#form').submit();
                break;
            case '1100':
                msg = 'マーチャントID - 必須エラー';
                break;
            case '1200':
                msg = 'トークン生成公開鍵 - 必須エラー';
                break;
            case '1201':
                msg = 'トークン生成公開鍵 - 不正エラー';
                break;
            case '1300':
                msg = 'カード番号 - 必須チェックエラー';
                break;
            case '1301':
                msg = 'カード番号 - 書式チェックエラー';
                break;
            case '1400':
                msg = '有効期限(年) - 必須チェックエラー';
                break;
            case '1401':
                msg = '有効期限(年) - 書式チェックエラー';
                break;
            case '1500':
                msg = '有効期限(月) - 必須チェックエラー';
                break;
            case '1501':
                msg = '有効期限(月) - 書式チェックエラー';
                break;
            case '1502':
                msg = '有効期限(年月)が不正です。';
                break;
            case '1600':
                msg = 'セキュリティコード - 書式チェックエラー';
                break;
            case '1601':
                msg = 'セキュリティコード - 必須エラー（セキュリティコードトークンの場合）';
                break;
            case '1700':
                msg = 'カード名義 - 書式チェックエラー';
                break;
            case '7000':
                msg = '非対応のブラウザです。';
                break;
            case '7001':
                msg = 'ペイジェントとの通信に失敗しました。';
                break;
            case '8000':
                msg = 'システムメンテナンス中です。';
                break;
            case '9000':
                msg = 'ペイジェント決済システム内部エラー';
                break;
        }
        if (response.result != '0000') {
            alert(msg);
        }
    }

```

### 发送信用卡支付请求

[](#发送信用卡支付请求)

```
$split_count = 'xxx'; // 分期数
$card_token = 'xxxxxxxxx'; // token
$trading_id = 'xxxxxxxx'; // 订单号
$payment_amount = 100; // 金额
$result = $p->paySend($split_count, $card_token, $trading_id, $payment_amount);

```

### 发送后支付请求

[](#发送后支付请求)

```
$trading_id = 'xxxxxx'; // 订单号
$payment_amount = 700; // 订单金额
$shop_order_date = date('Ymd', time()); // 日期
$customer_name_kanji = 'xxxxxx'; // 用户名 鈴木 太郎
$customer_name_kana = 'xxxxxxx'; // 用户假名 すずき たろう
$customer_email = 'xxxxxx'; // 邮箱
$customer_zip_code = 'xxxxxx'; // 邮编 2740065
$customer_address = 'xxxxxx'; // 地址 千葉県船橋市高根台7-14-1
$customer_tel = 'xxxxxxx'; // 电话 090-8510-9250

$goods_list = [
            [
                'goods' => '商品1',
                'goods_price' => 300,
                'goods_amount' => 1
            ],
            [
                'goods' => '商品2',
                'goods_price' => 200,
                'goods_amount' => 2
            ],

        ];

$result = $p->afterPaySend($trading_id, $payment_amount, $shop_order_date, $customer_name_kanji, $customer_name_kana,
            $customer_email, $customer_zip_code, $customer_address, $customer_tel, $goods_list);

```

**备注： 需要额外注意返回的 pay\_code 为 15007 的情况，此时表示请求审核中**

### 发送后支付取消请求

[](#发送后支付取消请求)

```
$trading_id = 'xxxxxxx'; // 订单号，与交易 id 可只传一个
$payment_id = 'xxxxxxx'; // 交易 id
$result = $p->afterPayCancel($trading_id, $payment_id);

```

### 发送后支付确认请求

[](#发送后支付确认请求)

```
$delivery_company_code = 'xxxxxxxxx'; // 快递公司代号， 黑猫为 12，其他公司自行查询
$delivery_slip_no = 'xxxxxxxxxx'; // 快递单号
$trading_id = 'xxxxxxx'; // 订单号，与交易 id 可只传一个
$payment_id = 'xxxxxxx'; // 交易 id
$result = $p->afterPayConfirm($delivery_company_code, $delivery_slip_no, $trading_id, $payment_id);

```

在 Laravel 中使用
-------------

[](#在-laravel-中使用)

在 Laravel 中使用也是同样的安装方式，配置写在 `config/services.php` 中

```
·
·
·
'paygent' => [
    'env' => env('PAYGENT_ENV', 'local'),
    'merchant_id' => env('PAYGENT_MERCHANT_ID', ''),
    'connect_id' => env('PAYGENT_CONNECT_ID', ''),
    'connect_password' => env('PAYGENT_CONNECT_PASSWORD', ''),
    'token' => env('PAYGENT_TOKEN', ''), // 备注：此 token 为前台页面获取信用卡 token 时使用
    'pem' => app_path() . env('PAYGENT_PEM', ''),
    'crt' => app_path() . env('PAYGENT_CRT', ''),
    'telegram_version' => env('PAYGENT_TELEGRAM_VERSION', '1.0'),
]

```

然后在 `.env` 中配置以上参数

```
PAYGENT_ENV=local
PAYGENT_MERCHANT_ID=
PAYGENT_CONNECT_ID=
PAYGENT_CONNECT_PASSWORD=
PAYGENT_TOKEN=
PAYGENT_PEM=/Config/Paygent/Sandbox/xxxx.pem
PAYGENT_CRT=/Config/Paygent/Sandbox/xxxxx.crt
PAYGENT_TELEGRAM_VERSION=1.0

```

**备注**`PAYGENT_PEM` 和 `PAYGENT_CRT` 为证书密钥文件的位置

方法参数注入

```
public function test(Paygent $paygent)
{
    $split_count = 'xxx'; // 分期数
    $card_token = 'xxxxxxxxx'; // token
    $trading_id = 'xxxxxxxx'; // 订单号
    $payment_amount = 100; // 金额
    $result = $paygent->paySend($split_count, $card_token, $trading_id, $payment_amount);
}

```

服务器访问

```
public function test()
{
    $split_count = 'xxx'; // 分期数
    $card_token = 'xxxxxxxxx'; // token
    $trading_id = 'xxxxxxxx'; // 订单号
    $payment_amount = 100; // 金额
    $result = app('paygent')->paySend($split_count, $card_token, $trading_id, $payment_amount);
}

```

**以下为腾讯云文档 [跳转](https://dev.tencent.com/s/d6174133-c098-4426-83a6-307d0ee6608a)**

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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/d9982f69ff72987c2e316b74a0e6806832f073478f2888481e683788097f7fe8?d=identicon)[chenjianeng0201](/maintainers/chenjianeng0201)

---

Top Contributors

[![chenjianeng0201](https://avatars.githubusercontent.com/u/42136057?v=4)](https://github.com/chenjianeng0201 "chenjianeng0201 (17 commits)")

### Embed Badge

![Health badge](/badges/chenjianeng0201-paygent/health.svg)

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

###  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)
