Download the PHP package yuepay/yuepay-laravel without Composer
On this page you can find all versions of the php package yuepay/yuepay-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package yuepay-laravel
粤收付(cnyepay)支付 SDK for Laravel
基于粤收付开放平台接口文档封装的 Laravel 支付 SDK,支持支付宝、微信等多种支付方式。
环境要求
- PHP >= 7.3
- Laravel >= 6.0
- ext-openssl 扩展
安装
方式一:Composer(推荐)
方式二:手动引入
将本目录放置到 Laravel 项目的 packages/yuepay 下,然后在 composer.json 中添加:
执行:
配置
1. 发布配置文件
这会将配置文件发布到 config/yuepay.php。
2. 生成 RSA 密钥对
- 商户私钥:用于生成签名,必须妥善保管,不可泄露
- 商户公钥:提供给粤收付平台配置
- 粤收付平台公钥:从粤收付商户后台获取,用于回调验签
3. 配置 .env
4. 注册 ServiceProvider(手动安装时需要)
在 config/app.php 中添加:
5. 注册路由
在 routes/api.php 中添加:
使用方法
基本调用
依赖注入方式
处理回调通知
SDK 已内置回调处理控制器,路由为 POST /api/yuepay/notify。
回调处理逻辑在 YuePay\Http\Controllers\YuePayController::notify() 方法中,请根据业务需求修改。
关键步骤:
- 验签(SDK自动完成)
- 校验金额一致性
- 更新本地订单状态
- 返回
success
支付方式 wayCode 一览
| wayCode | 说明 | 必填参数 |
|---|---|---|
| ALI_JSAPI | 支付宝JSAPI(小程序) | openid |
| ALI_QR | 支付宝二维码 | - |
| ALI_BAR | 支付宝条码(付款码) | authCode |
| ALI_WAP | 支付宝H5 | - |
| ALI_APP | 支付宝APP | - |
| WX_JSAPI | 微信JSAPI(小程序) | openid |
| WX_NATIVE | 微信扫码 | - |
| WX_BAR | 微信条码(付款码) | authCode |
| WX_H5 | 微信H5 | - |
| WX_APP | 微信APP | - |
目录结构
签名说明
SDK 使用 RSA2(SHA256withRSA)签名算法,流程如下:
- 将所有非空参数按参数名 ASCII 码字典序排序
- 拼接为
key1=value1&key2=value2...格式(sign 不参与签名) - 使用商户 RSA 私钥进行 SHA256withRSA 签名
- 签名结果转换为 Base64 编码
注意:与微信支付不同,粤收付 RSA2 签名时拼接字符串末尾不需要添加 API 密钥。
常见问题
Q: 签名失败?
- 检查私钥格式是否为 PKCS#8
- 确认私钥是否包含完整头尾标识(
-----BEGIN PRIVATE KEY-----) - 支持纯 Base64 字符串(SDK会自动格式化)
Q: 验签失败?
- 确认使用的是粤收付平台公钥(不是商户公钥)
- 检查平台公钥是否正确获取
Q: 回调收不到通知?
- 确认
notifyUrl为公网可访问的 HTTPS 地址 - 检查服务器防火墙是否放行
- 回调路由需排除 CSRF 中间件(SDK已处理)
License
MIT
All versions of yuepay-laravel with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.3
ext-openssl Version *
illuminate/support Version ^6.0|^7.0|^8.0
illuminate/http Version ^6.0|^7.0|^8.0
ext-openssl Version *
illuminate/support Version ^6.0|^7.0|^8.0
illuminate/http Version ^6.0|^7.0|^8.0
The package yuepay/yuepay-laravel contains the following files
Loading the files please wait ...