PHPackages                             ice-hau/pay2pay - 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. ice-hau/pay2pay

ActiveLibrary[Payment Processing](/categories/payments)

ice-hau/pay2pay
===============

专注 Alipay 和 WeChat 的支付扩展包

1.0.0(1y ago)012MITPHPPHP &gt;=5.6

Since Jun 21Pushed 1y agoCompare

[ Source](https://github.com/ace-hau/horseloft_pay2pay)[ Packagist](https://packagist.org/packages/ice-hau/pay2pay)[ RSS](/packages/ice-hau-pay2pay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Pay
===

[](#pay)

[![StyleCI](https://camo.githubusercontent.com/eec5f3d03d28f758229403f0c3324ba7df331a7f251ded82dc483a14fedc5073/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130303335353131322f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/100355112)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d961693ad843215404145f5498444337e7f2615761e34a29ec8d47260e833724/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f79616e736f6e6764612f7061792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yansongda/pay/?branch=master)[![Build Status](https://camo.githubusercontent.com/989773e46bb62a400b7ce38e3349d2e0be5572e6aea064d3813d35b110da3946/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f79616e736f6e6764612f7061792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yansongda/pay/build-status/master)[![Latest Stable Version](https://camo.githubusercontent.com/74107b02dd7e23ec93a9cb953c4587619443a466ea320e4d85f2e2f403969f20/68747470733a2f2f706f7365722e707567782e6f72672f79616e736f6e6764612f7061792f762f737461626c65)](https://packagist.org/packages/yansongda/pay)[![Total Downloads](https://camo.githubusercontent.com/59c752cf7390481a9f0e2f264980a3579d8e2c7fb92b0acd43cb2d8fc8ab0a56/68747470733a2f2f706f7365722e707567782e6f72672f79616e736f6e6764612f7061792f646f776e6c6f616473)](https://packagist.org/packages/yansongda/pay)[![Latest Unstable Version](https://camo.githubusercontent.com/6f2ac4108a9105811c4a80f14959b75e9055a66ed6ebfb194b8f82ab531affad/68747470733a2f2f706f7365722e707567782e6f72672f79616e736f6e6764612f7061792f762f756e737461626c65)](https://packagist.org/packages/yansongda/pay)[![License](https://camo.githubusercontent.com/3e43e32e81e72fda1fb9b451a79d12d72503c76b737b12068e947ede50f1f1f8/68747470733a2f2f706f7365722e707567782e6f72672f79616e736f6e6764612f7061792f6c6963656e7365)](https://packagist.org/packages/yansongda/pay)

**！注意：v1.x 版本将不做新功能开发，只进行 bug 维护！请大家尽快迁移到 v2 版本！**

开发了多次支付宝与微信支付后，很自然产生一种反感，惰性又来了，想在网上找相关的轮子，可是一直没有找到一款自己觉得逞心如意的，要么使用起来太难理解，要么文件结构太杂乱，只有自己撸起袖子干了。

**说明，请先熟悉支付宝说明文档！！**

欢迎 Star，欢迎 PR！

laravel 扩展包请

特点
--

[](#特点)

- 命名不那么乱七八糟
- 隐藏开发者不需要关注的细节
- 根据支付宝、微信最新 API 开发而成
- 高度抽象的类，免去各种拼json与xml的痛苦
- 符合 PSR 标准，你可以各种方便的与你的框架集成
- 文件结构清晰易理解，可以随心所欲添加本项目中没有的支付网关
- 方法使用更优雅，不必再去研究那些奇怪的的方法名或者类名是做啥用的

运行环境
----

[](#运行环境)

- PHP 5.6+
- composer

支持的支付网关
-------

[](#支持的支付网关)

由于各支付网关参差不齐，所以我们抽象了两个方法 `driver()`，`gateway()`。

两个方法的作用如下：

`driver()` ： 确定支付平台，如 `alipay`,`wechat`;

`gateway()`： 确定支付网关。通过此方法，确定支付平台下的支付网关。例如，支付宝下有 「电脑网站支付」，「手机网站支付」，「APP 支付」三种支付网关，通过传入 `web`,`wap`,`app` 确定。

详细思路可以查看源代码。

### 1、支付宝

[](#1支付宝)

- 电脑支付
- 手机网站支付
- APP 支付
- 刷卡支付
- 扫码支付

SDK 中对应的 driver 和 gateway 如下表所示：

drivergateway描述alipayweb电脑支付alipaywap手机网站支付alipayappAPP 支付alipaypos刷卡支付alipayscan扫码支付alipaytransfer 帐户转账（可用于平台用户提现）### 2、微信

[](#2微信)

- 公众号支付
- 小程序支付
- H5 支付
- 扫码支付
- 刷卡支付
- APP 支付

SDK 中对应的 driver 和 gateway 如下表所示：

drivergateway描述wechatmp公众号支付wechatminiapp小程序支付wechatwapH5 支付wechatscan扫码支付wechatpos刷卡支付wechatappAPP 支付wechattransfer企业付款支持的方法
-----

[](#支持的方法)

所有网关均支持以下方法

- pay(array $config\_biz)
    说明：支付接口
    参数：数组类型，订单业务配置项，包含 订单号，订单金额等
    返回：mixed 详情请看「支付网关配置说明与返回值」一节。
- refund(array|string $config\_biz, $refund\_amount = null)
    说明：退款接口
    参数：`$config_biz` 为字符串类型仅对`支付宝支付`有效，此时代表订单号，第二个参数为退款金额。
    返回：mixed 退款成功，返回 服务器返回的数组；否则返回 false；
- close(array|string $config\_biz)
    说明：关闭订单接口
    参数：`$config_biz` 为字符串类型时代表订单号，如果为数组，则为关闭订单业务配置项，配置项内容请参考各个支付网关官方文档。
    返回：mixed 关闭订单成功，返回 服务器返回的数组；否则返回 false；
- find(string $out\_trade\_no)
    说明：查找订单接口
    参数：`$out_trade_no` 为订单号。
    返回：mixed 查找订单成功，返回 服务器返回的数组；否则返回 false；
- verify($data, $sign = null)
    说明：验证服务器返回消息是否合法
    参数：`$data` 为服务器接收到的原始内容，`$sign` 为签名信息，当其为空时，系统将自动转化 `$data` 为数组，然后取 `$data['sign']`。
    返回：mixed 验证成功，返回 服务器返回的数组；否则返回 false；

安装
--

[](#安装)

```
composer require "yansongda/pay:^1.0"
```

使用说明
----

[](#使用说明)

### 0、一个完整的例子:

[](#0一个完整的例子)

```
