ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 支付 > 魔工海豚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/