五月天激情丁香,国产精品2019,国产成人精品亚洲2020,国产精品免费视频一区二区三区,开心久久婷婷综合中文字幕,天堂视频在线观看免费完整版

協(xié)程支付網(wǎng)關(guān)(微信支付)

組件安裝方法和說明

注意:請務(wù)必檢查你的 php 環(huán)境有沒有安裝 php-bcmath 擴(kuò)展,沒有安裝 php-bcmath 擴(kuò)展時(shí)安裝的 pay 組件的版本是 1.2.17 之前的版本(不是最新)。想要使用最新穩(wěn)定版 pay 組件的功能,請先安裝 php-bcmath 擴(kuò)展,php 安裝此擴(kuò)展的方法請自行查詢。

composer require easyswoole/pay

微信支付方法

微信支付目前支持 6 種支付方法,對應(yīng)的支付 method 如下:

method 說明 參數(shù) 返回值
wap 手機(jī)網(wǎng)站支付 Request Response
officialAccount 公眾號(hào)支付 Request Response
scan 掃碼支付 Request Response
miniProgram 小程序支付 Request Response
barCode 條碼當(dāng)面支付 Request Response
App App支付 Request Response

微信參數(shù)配置

$wechatConfig = new Config();
$wechatConfig->setAppId('xxxxxx');      // 除了小程序以外使用該APPID
$wechatConfig->setMiniAppId('xxxxxx');  // 小程序使用該APPID
$wechatConfig->setMchId('xxxxxx');
$wechatConfig->setKey('xxxxxx');
$wechatConfig->setNotifyUrl('xxxxx');
$wechatConfig->setApiClientCert('xxxxxxx');//客戶端證書
$wechatConfig->setApiClientKey('xxxxxxx'); //客戶端證書秘鑰

由于小程序擁有獨(dú)立的APPID,只需要在配置里同時(shí)配置上AppId和MiniAppId兩個(gè)配置項(xiàng),在支付的時(shí)候會(huì)自動(dòng)選擇對應(yīng)的APPID來發(fā)起支付

公眾號(hào)支付

$officialAccount = new OfficialAccount();
$officialAccount->setOpenid('xxxxxxx');
$officialAccount->setOutTradeNo('CN' . date('YmdHis') . rand(1000, 9999));
$officialAccount->setBody('xxxxx-測試' . $outTradeNo);
$officialAccount->setTotalFee(1);
$officialAccount->setSpbillCreateIp('xxxxx');
$pay = new \EasySwoole\Pay\Pay();
$params = $pay->weChat($wechatConfig)->officialAccount($officialAccount);

可以參考demo/wechat/index.php

在使用微信支付時(shí),商品名稱中如果出現(xiàn)特殊字符,如 & 請自行使用urlencode在生成簽名傳參時(shí)進(jìn)行編碼

H5支付

$wap = new \EasySwoole\Pay\WeChat\RequestBean\Wap();
$wap->setOutTradeNo('CN' . date('YmdHis') . rand(1000, 9999));
$wap->setBody('xxxxx-WAP測試' . $outTradeNo);
$wap->setTotalFee(1);
$wap->setSpbillCreateIp('xxxxx');
$pay = new \EasySwoole\Pay\Pay();
$params = $pay->weChat($wechatConfig)->wap($wap);

小程序支付

$bean = new \EasySwoole\Pay\WeChat\RequestBean\MiniProgram();
$bean->setOpenid('xxxxxxxxx');
$bean->setOutTradeNo('CN' . date('YmdHis') . rand(1000, 9999));
$bean->setBody('xxxx-測試' . $outTradeNo);
$bean->setTotalFee(1);
$bean->setSpbillCreateIp($this->request()->getHeader('x-real-ip')[0]);
$pay = new \EasySwoole\Pay\Pay();
$params = $pay->weChat($this->wechatConfig)->miniProgram($bean);

App支付

$app = new App();
$app->setNonceStr('xxxxx');
$app->setSign('xxxxx');
$app->setBody('app支付測試');
$app->setOutTradeNo(date(YmdHis).rand(1000,999));
$app->setTotalFee(1);
$app->setSpbillCreateIp('xxxx');

$pay = new \EasySwoole\Pay\Pay();
$result = $pay->weChat($wechatConfig)->app($app);

掃碼支付

模式一

生成掃碼鏈接 然后生成二維碼 具體請查看demo/wechat/index.php

$biz = new Biz();
$biz->setProductId('123456789');
$biz->setTimeStamp(time());
$biz->setAppId($wechatConfig->getAppId());
$biz->setMchId($wechatConfig->getMchid());
$data = $biz->toArray();
$u = new Utility($wechatConfig);
$sign = $u->generateSign($data);
$biz->setSign($sign);
$url1 = "weixin://wxpay/bizpayurl?" . $this->ToUrlParams($biz->toArray());

掃碼回調(diào)地址(ps:公眾號(hào)平臺(tái)設(shè)置)

 $xml = $this->request()->getBody()->__toString();
$pay = new Pay();
$data = $pay->weChat($this->wechatConfig)->verify($xml);
$bean = new \EasySwoole\Pay\WeChat\RequestBean\Scan();
$bean->setOutTradeNo('CN' . date('YmdHis') . rand(1000, 9999));
$bean->setOpenid('xxxxxx');
$bean->setProductId($data['product_id']);
$bean->setBody('xxxxxx-SCAN測試' . $outTradeNo);
$bean->setTotalFee(1);
$bean->setSpbillCreateIp($this->request()->getHeader('x-real-ip')[0]);
$response = $pay->weChat($this->wechatConfig)->scan($bean);
$nativeResponse = new NativeResponse([
    'appid' => $this->wechatConfig->getAppId(),
    'mch_id' => $this->wechatConfig->getMchId(),
    'prepay_id' => $response->getPrepayId(),
    'nonce_str' => $response->getNonceStr()]);
$u = new Utility($this->wechatConfig);
$nativeResponse->setSign($u->generateSign($nativeResponse->toArray()));
$xml = (new SplArray($nativeResponse->toArray()))->toXML();
$this->response()->write($xml);

模式二

$bean = new \EasySwoole\Pay\WeChat\RequestBean\Scan();
$bean->setOutTradeNo($outTradeNo);
$bean->setProductId('123456789');
$bean->setBody('xxxx-SCAN2測試' . $outTradeNo);
$bean->setTotalFee(1);
$bean->setSpbillCreateIp($this->request()->getHeader('x-real-ip')[0]);
$pay = new Pay();
$data = $pay->weChat($this->wechatConfig)->scan($bean);
$url2 = $data->getCodeUrl();

訂單查詢

go(function () use ($wechatConfig) {
    $orderFind = new \EasySwoole\Pay\WeChat\RequestBean\OrderFind();
    $orderFind->setOutTradeNo('CN201903181044383609');
    $pay = new \EasySwoole\Pay\Pay();
    $info = $pay->weChat($wechatConfig)->orderFind($orderFind);
    print_r((array)$info);
});

申請退款

go(function () use ($wechatConfig) {
    $refund = new \EasySwoole\Pay\WeChat\RequestBean\Refund();
    $refund->setOutTradeNo('CN201903181111275823');
    $refund->setOutRefundNo('TK' . date('YmdHis') . rand(1000, 9999));
    $refund->setTotalFee(1);
    $refund->setRefundFee(1);
    $refund->setNotifyUrl('xxxxx');
    $pay = new \EasySwoole\Pay\Pay();
    $info = $pay->weChat($wechatConfig)->refund($refund);
    print_r($info);
});

退款查詢

go(function () use ($wechatConfig) {
    $refundFind = new \EasySwoole\Pay\WeChat\RequestBean\RefundFind();
    $refundFind->setOutTradeNo('CN201903181044383609');
    $pay = new \EasySwoole\Pay\Pay();
    $info = $pay->weChat($wechatConfig)->refundFind($refundFind);
    print_r((array)$info);
});

關(guān)閉訂單

go(function () use ($wechatConfig) {
    $close = new \EasySwoole\Pay\WeChat\RequestBean\Close();
    $close->setOutTradeNo('CN201903151343107239');
    $pay = new \EasySwoole\Pay\Pay();
    $info = $pay->weChat($wechatConfig)->close($close);
    print_r((array)$info);
});

下載對賬單

go(function () use ($wechatConfig) {
    $download = new \EasySwoole\Pay\WeChat\RequestBean\Download();
    $download->setBillDate('20190312');
    $download->setBillType('ALL');//這個(gè)參數(shù)必傳
    $pay = new \EasySwoole\Pay\Pay();
    $info = $pay->weChat($wechatConfig)->download($download);
    echo htmlspecialchars($info, ENT_QUOTES);
});

下載資金對賬單

go(function () use ($wechatConfig) {
    $download = new \EasySwoole\Pay\WeChat\RequestBean\DownloadFundFlow();
    $download->setBillDate('20190312');
    $download->setAccountType('Basic');
    $pay = new \EasySwoole\Pay\Pay();
    $info = $pay->weChat($wechatConfig)->downloadFundFlow($download);
    echo htmlspecialchars($info, ENT_QUOTES);
});

驗(yàn)證簽名

$pay = new \EasySwoole\Pay\Pay();
$content = '';//content為xml原始數(shù)據(jù),在easyswoole中可通過$this->request()->getBody()->__toString()取出
$data = $pay->weChat($wechatConfig)->verify($content);

服務(wù)器確認(rèn)收到異步通知字符串獲取

\EasySwoole\Pay\WeChat\WeChat::success();//成功響應(yīng)
\EasySwoole\Pay\WeChat\WeChat::fail();//失敗響應(yīng)
主站蜘蛛池模板: a一级一色一情 | 国产精品毛片无码 | 婷婷色网站 | 久久国产这里只有精品 | 久久亚洲国产欧洲精品一 | 能在线观看的一区二区三区 | 99在线观看精品免费99 | www.chenren| 精品无人乱码一区二区三区 | 国产农村精品一级毛片视频 | 免费一区二区三区四区 | 天天草综合网 | 黄色小视频观看 | 国产精品久久久久久久久岛 | 聊斋艳谭8陆判性水仙 | 国产一区二区三区视频 | 精品一区二区三区在线播放 | 国产高清成人mv在线观看 | 开心色五香五月婷婷 | 久久国产这里只有精品 | 久久精品在这里 | 四虎免费在线观看 | 五月天激情小说网 | 全国男人的天堂网站 | 红色一级毛片 | 国产亚洲精品中文带字幕21页 | 国产欧美精品午夜在线播放 | 青草导航 | 日日草草 | 久久成人免费 | 国产精品久久久久… | 亚洲成a人片777777久久 | www.米奇777.com | 久久久久久久久久免免费精品 | 国产69精品久久久久777 | 日本高清色惰www在线视频 | 九九热在线观看 | 久久中文精品 | 免费高清欧美一区二区视频 | 久久最新免费视频 | 五月开心六月伊人色婷婷 |