Download the PHP package join/php-payment without Composer
On this page you can find all versions of the php package join/php-payment. 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 php-payment
PHP-JOIN-PAYMENT php 支付工程
github (最新代码) https://github.com/SantiagoFan/php-payment
gitee (定期同步) https://gitee.com/san_fan/php-paymentgit
整体框架
composer 安装
需要 composer 版本2+
包地址 https://packagist.org/packages/join/php-payment
require 依赖
php:>=7.2.0
代码结构
如何参与开发成为代码贡献人员
- 将项目fork到自己帐号
- 修改代码完成测试
- 提交commit push 到自己的仓库
- New pull request(简称pr) 合并请求到主库等待合并
使用教程
1.安装包 composer 包
2.创建数据表
复制源码文件夹的sql 脚本创建 交易流水表(此表作为所有支付进出的流水信息记录),具体业务订单信息请自己单独创建,参照下面的myorder
字段 | 数据类型 | 可空 | 含义 |
---|---|---|---|
id | varchar(64) | not null | 支付记录表 |
title | varchar(128) | null | 支付项目名称 如:商品-橘子5斤 |
is_refund | tinyint(1) | null | 是否为退款 |
state int | default 0 | null | 支付完成状态 -1撤销 0 默认 1 交易中 2支付完成 |
business_name | varchar(50) | null | 业务类别:1.商品支付 |
business_no | varchar(128) | null | 内部业务 关联订单号码 |
pay_channel | varchar(50) | null | 支付渠道:alipay,wxpay |
pay_channel_no | varchar(128) | null | 支付渠道 返回的外部订单号 |
amount | decimal(10,2) | null | 操作金额 支付为正 退款为负 |
real_amount | decimal(10,2) | null | |
apply_time | datetime | null | 下单时间 |
complete_time | datetime | null | 交易完成时间 |
original_amount | decimal(10,2) | null | 原订单交易金额 |
original_id | varchar(64) | null | 原始交易订单 |
3.编写配置类(实现 IPaymentConfig 接口)
- getPayConfig 是获取微信支付宝支付通道所需参数的方法
- getBusinessMap 是通过业务名称获取 业务类(具体指业务系统里需要有支付需求的订单如,商户购买订单、充值订单等)
- getPayChannel 是前端业务场景对应支付通道的配置
配置示例 config/payment.php
支付前注入配置
4.集成异步通知 Controller
此通知入口对应地址需要和配置类的通知地址一致
如果需要全局处理 支付成功后或者退款后的业务,notify 类覆盖父类方法PaySuccess
或者 RefundSuccess。
如果需要处理业务订单成功后的业务,请在相关业务model 里的PaySuccess方法处理
5.编写业务类 Model
- .编写自己的业务类MyOrder(可以实现多个不同业务类,如商城订单、充值订单,MyOrder只是示例名字,具体的写自己的名字!!!!) 。
- .每个业务需要实现 IPayableOrder 或者直接继承 BasePayableOrder 基类省时省力
- .BasePayableOrder 集成了 Thinkphp 的Model 类,可直接集成Model的数据库操作函数
6.编写业务调用支付
支付传入参数 $params
微信js 支付需要传入openid
支付宝js 支付需要传入buyer_id
All versions of php-payment with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.2.0
alipaysdk/easysdk Version ^2.2
overtrue/wechat Version ~4.0
topthink/framework Version 5.1.*
alipaysdk/easysdk Version ^2.2
overtrue/wechat Version ~4.0
topthink/framework Version 5.1.*
The package join/php-payment contains the following files
Loading the files please wait ....