## 支付
> 魔工海豚php已经内置
## 微信支付
### 文档
+ easyWeChat 用于微信登陆/支付等
> https://www.easywechat.com/docs/3.x/zh-CN/index
### 微信支付回调字段
https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_7&index=3
## 支付宝支付
### 实现代码
1.首先创建网关
```
$gateway = Omnipay::create('Alipay_AopApp');
$gateway->setSignType('RSA2'); //RSA/RSA2
$gateway->setAppId('the_app_id');
$gateway->setPrivateKey('the_app_private_key');
$gateway->setAlipayPublicKey('the_alipay_public_key');
$gateway->setNotifyUrl('https://www.example.com/notify');
```
2.使用网关方法 生成订单
```
$request = $gateway->purchase();
$request->setBizContent([
'subject' => 'test',
'out_trade_no' => date('YmdHis') . mt_rand(1000, 9999),
'total_amount' => '0.01',
'product_code' => 'QUICK_MSECURITY_PAY',
]);
/**
* @var AopTradeAppPayResponse $response
*/
$response = $request->send();
$orderString = $response->getOrderString();
```
3. 异步回调
```
$request = $gateway->completePurchase();
$request->setParams($_POST);//Optional
/**
* @var AopCompletePurchaseResponse $response
*/
try {
$response = $request->send();
if($response->isPaid()){
/**
* Payment is successful
*/
die('success'); //The response should be 'success' only
}else{
/**
* Payment is not successful
*/
die('fail');
}
} catch (Exception $e) {
/**
* Payment is not successful
*/
die('fail');
}
```
### 文档
+ Omnipay-alipay 支付宝支付库
> https://github.com/lokielse/omnipay-alipay
### 支付宝回调字段文档
```
array(25) {
["gmt_create"] => string(19) "2018-04-18 17:20:10"
["charset"] => string(5) "UTF-8"
["seller_email"] => string(19) "15873400584@163.com"
["subject"] => string(7) "3个月"
["sign"] => string(344) "cW1C3NcMTYItoE441KHx6p/EfblVApc1ojoMLo5/PEdLWg7uIV/ma9QFSzwr1p6MdlNsEAY6MUe/8IDBoLW8EljRRZH2WszfzvKkZsVmxAPUu2oeXitxqdVGPndfZrl3pdQ9HvCKgjA1bN9ZJr8i7PMLm8seNttqZFUKrqamGu3hjveQPP6E7RvocOvkKg/ieGsn7g3ef8lM7VdbiSCM+BfBFnDDFrf2/d8haSM4BjVJ1tUOQ6PR0rnhnS4QPCsbSKMBh/aCv4LBZaUdwtfCkncXpX7R/Fw1zUmIgqBtn0P3OfO76PW6PoPb+mgX6DY1Ulby4vpP7vGz4KzpD/227Q=="
["buyer_id"] => string(16) "2088502639082232"
["invoice_amount"] => string(4) "0.01"
["notify_id"] => string(34) "12f8b02c536d156afcf9cbbd7f53166hs1"
["fund_bill_list"] => string(49) "[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]"
["notify_type"] => string(17) "trade_status_sync"
["trade_status"] => string(13) "TRADE_SUCCESS"
["receipt_amount"] => string(4) "0.01"
["app_id"] => string(16) "2018032702454503"
["buyer_pay_amount"] => string(4) "0.01"
["sign_type"] => string(4) "RSA2"
["seller_id"] => string(16) "2088031700409974"
["gmt_payment"] => string(19) "2018-04-18 17:20:11"
["notify_time"] => string(19) "2018-04-18 17:20:11"
["version"] => string(3) "1.0"
["out_trade_no"] => string(20) "jiabang5ad70dc75bcba"
["total_amount"] => string(4) "0.01"
["trade_no"] => string(28) "2018041821001004230577344672"
["auth_app_id"] => string(16) "2018032702454503"
["buyer_logon_id"] => string(13) "626***@qq.com"
["point_amount"] => string(4) "0.00"
}
```
字段表示请查看下面文档
https://docs.open.alipay.com/204/105301/
- 首页
- APP
- 调试
- 部分问题解答
- IM
- 魔工坊APP框架
- 前端
- npm
- MogoAjax
- ES6
- javascript规范
- weui
- 微信小程序
- Mock数据伪造
- Mogo-Css
- O2-Upload
- 七牛图片处理
- 前端调试
- 后端
- 魔工坊海豚PHP
- 文件上传
- O2-Comments
- 前端API
- 消息
- Excel导入/导出
- 阿里短信
- dolphinPHP
- Thinkphp
- 海豚PHP
- 创建项目
- 人人商城与海豚同步问题
- mysql
- 发送HTTP请求
- 支付
- 个推
- 接口开发须知
- 生成海报
- 音频转换
- openssl
- App上架的故事
- 安卓签名问题
- 苹果账号申请
- 各个平台上架内容
- 文案小姐姐的文档
- 微信支付申请流程
- 备案的故事
- 企业支付宝认证
- 微信公众问题
- 微信开放平台与上架应用
- 小程序特殊行业所需材料
- 模型文档模板
- 必读规范
- 跨域
- 前后端数据通讯接口规范
- Restful风格API规范
- 服务器
- SSL中间证书
- Git篇章
- MogoSDK
- 文档模板
- PHP
- 使用
- 概念
- User
- 模型
- 文档书写
- JS
- 安装
- 初始化
- 用户
- 状态管理
- 查询
- 执行函数
- 请求
- 上传
- MogoH5+