ledc/wechatpay-profit-sharing

微信支付普通直连分账

Maintainers

👁 ledccn

Package info

github.com/ledccn/wechatpay-profit-sharing

pkg:composer/ledc/wechatpay-profit-sharing

Statistics

Installs: 28

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v7.1.2 2025-12-08 03:19 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 7e08a4334b0f791dafb2675ef25f765cd36d8063

  • david <367013672.woop@qq.com>

This package is auto-updated.

Last update: 2026-06-08 04:31:22 UTC


README

安装

composer require ledc/wechatpay-profit-sharing

使用说明

  1. 安装完之后,请执行以下命令,安装插件的数据库迁移文件 php think install:migrate:wechatpay-profit-sharing

  2. 执行数据库迁移 php think migrate:run

开箱即用,只需要传入一个配置,初始化一个实例即可:

use Ledc\WechatPayProfitSharing\Config;
use Ledc\WechatPayProfitSharing\ProfitService;

$config = [
 'mch_id' => 1360649000,
 'appid' => 1360649000,

 // 商户证书
 'private_key' => __DIR__ . '/certs/apiclient_key.pem',
 'certificate' => __DIR__ . '/certs/apiclient_cert.pem',

 // v3 API 秘钥
 'secret_key' => '43A03299A3C3FED3D8CE7B820Fxxxxx',

 // v2 API 秘钥
 'v2_secret_key' => '26db3e15cfedb44abfbb5fe94fxxxxx',

 // 平台证书:微信支付 APIv3 平台证书,需要使用工具下载
 // 下载工具:https://github.com/wechatpay-apiv3/CertificateDownloader
 'platform_certs' => [
 // 请使用绝对路径
 // '/path/to/wechatpay/cert.pem',
 ],
];

$profitService = new ProfitService(new Config($config));

在创建实例后,所有的方法都可以有IDE自动补全;例如:

// 添加分账接收方
$profitService->addReceiver();
// 删除分账接收方
$profitService->removeReceiver();
// 请求单次分账(请求需要双向证书)
$profitService->single();
// 请求多次分账(请求需要双向证书)
$profitService->multi();
// 查询分账结果
$profitService->query();
// 完结分账(请求需要双向证书)
$profitService->finish();
// 查询订单待分账金额
$profitService->orderAmountQuery();
// 分账回退(请求需要双向证书)
$profitService->return();
// 回退结果查询
$profitService->returnQuery();

官方文档

捐赠

👁 reward