## 支付
> 魔工海豚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+