<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ### 運行環境 * PHP 7.0+ (v2.8.0 開始 >= 7.1.3) * composer > php5 請使用 v1.x 版本[https://github.com/yansongda/pay/tree/v1.x](https://github.com/yansongda/pay/tree/v1.x) 詳情 請查看 https://github.com/yansongda/pay/tree/v2 ### 1、支付寶 * 電腦支付 * 手機網站支付 * APP 支付 * 刷卡支付 * 掃碼支付 * 賬戶轉賬 * 小程序支付 | method | 描述 | | :-: | :-: | | web | 電腦支付 | | wap | 手機網站支付 | | app | APP 支付 | | pos | 刷卡支付 | | scan | 掃碼支付 | | transfer | 帳戶轉賬 | | mini | 小程序支付 | ### 2、微信 * 公眾號支付 * 小程序支付 * H5 支付 * 掃碼支付 * 刷卡支付 * APP 支付 * 企業付款 * 普通紅包 * 分裂紅包 | method | 描述 | | :-: | :-: | | mp | 公眾號支付 | | miniapp | 小程序支付 | | wap | H5 支付 | | scan | 掃碼支付 | | pos | 刷卡支付 | | app | APP 支付 | | transfer | 企業付款 | | redpack | 普通紅包 | | groupRedpack | ## 安裝 **安裝 方式1** ~~~shell composer require yansongda/pay -vvv ~~~ **安裝 方式2** 執行上面命令或者執行下面 ![](https://img.kancloud.cn/9d/1a/9d1a6ffc2cbd79f2874658af62c71fe9_627x317.png) ~~~ "yansongda/pay": "^2.10" ~~~ `composer install` composer install 報錯版本不匹配 或者如下圖 執行 `composer install --ignore-platform-reqs` 忽略版本號 ![](https://img.kancloud.cn/8b/27/8b27d9a79e5c7361c475e410f3cd1203_962x448.png) ***** **使用** 下面例子是 laravel8.0 且僅僅用了 h5 和web app 支付測試 總是報錯 最后使用支付寶 官方提供 ~~~ //支付入口 public function alipayIndex(Request $request) { $money = $request->money ?? 39.9; //支付金額 $user_id = $request->id ?? null; //用戶ID $pay_type = $request->pay_type ?? 'h5'; // 支付方式 $out_trade_no = date("YmdHis").rand(10,99).rand(100,999);//訂單號 $alipay_order = [ 'out_trade_no' => $out_trade_no, 'total_amount' => $money, 'subject' => 'fenqixin', ]; $config = Config::get("alipay.h5_pay"); $alipay = Pay::alipay($config); $result = Order::insertOrder($user_id,$money,$out_trade_no,2); if(!$result) return false; if($pay_type == 'h5'){ return $alipay->wap($alipay_order); } return $alipay->web($alipay_order); } ~~~ ~~~ //支付寶驗簽 h5 public function alipayNoticeApp() { $config = Config::get("alipay.h5_pay"); $data = Pay::alipay($config)->verify(); $order_id = $data->out_trade_no; $money = $data->total_amount; $where = [ ['order_id','=',$order_id], ['money','=',$money] ]; if($data->trade_status == "TRADE_SUCCESS" || $data->trade_status == "TRADE_FINISHED"){ $order_data = Order::query()->where($where)->first(); if($order_data->status == 's') return true;//該訂單 已經處理過 無需更新 訂單 用戶 狀態 Order::query()->where($where)->update(['status' => 's']);//處理訂單成功修改 User::updateUserVipStatus($order_data->user_id);//修改用戶VIP狀態 和 VIP時間 }else{ Order::query()->where($where)->update(['status' => 'f']); } return true; } ~~~ 支付寶官方支付 1 下載官方包 放在laravel框架 vendor目錄下 ![](https://img.kancloud.cn/21/ad/21adf3193f31519748b94803ab1e89d7_222x134.png) ~~~ public function _aliPay($alipay_order,$config) { $dir = __DIR__.'/../../../vendor/';//根據自己控制器路徑調整對應位置 require_once $dir.'aop/AopClient.php'; require_once $dir.'aop/request/AlipayTradeAppPayRequest.php'; $aop = new \AopClient; $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do"; $aop->appId = $config['app_id']; $aop->rsaPrivateKey = $config['private_key']; $aop->format = "json"; $aop->charset = "UTF-8"; $aop->signType = "RSA2"; $aop->alipayrsaPublicKey = $config['ali_public_key']; //實例化具體API對應的request類,類名稱和接口名稱對應,當前調用接口名稱:alipay.trade.app.pay $req = new \AlipayTradeAppPayRequest(); $notify_url = "https://api-fqx.fenqiqian.com.cn/app/alipay-notice-app-app"; $subject = $alipay_order['subject']; $body = '訂單詳情'; $out_trade_no = $alipay_order['out_trade_no']; $money = $alipay_order['total_amount']; $bizcontent = "{\"body\":\"".$body."\"," . "\"subject\": \"".$subject."\"," . "\"out_trade_no\": \"".$out_trade_no."\"," . "\"timeout_express\": \"30m\"," . "\"total_amount\": \"".$money."\"," . "\"product_code\":\"QUICK_MSECURITY_PAY\"" . "}"; $req->setNotifyUrl($notify_url); $req->setBizContent($bizcontent); return $aop->sdkExecute($req); } ~~~ ~~~ //支付寶驗簽 app public function alipayNoticeAppAPP() { $config = Config::get("alipay.app_pay"); $data = Pay::alipay($config)->verify(); $order_id = $data->out_trade_no; $money = $data->total_amount; $where = [ ['order_id','=',$order_id], ['money','=',$money] ]; DB::table("alipay")->insert(['status' => $order_id]); DB::table("alipay")->insert(['status' => $money]); if($data->trade_status == "TRADE_SUCCESS" || $data->trade_status == "TRADE_FINISHED"){ return true; } } ~~~ ***** config 配置 ~~~ 'app_pay' => [ // APPID 'app_id' => '2021002156678492', // 支付寶 支付成功后 主動通知商戶服務器地址 注意 是post請求 'notify_url' => 'https://api-xxxx.cn/app/alipay-notice-app-app', // 支付寶 支付成功后 回調頁面 get // 'return_url' => 'https://xxx/pages/gather/initialSuccess', // 公鑰(注意是支付寶的公鑰,不是商家應用公鑰) 'ali_public_key' => '', // 加密方式: **RSA2** 私鑰 商家應用私鑰 'private_key' => "", // 'http' => [ // 'timeout' => 5.0, // 'connect_timeout' => 5.0, // // 更多配置項請參考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html) // ], ] ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看