| @@ -42,28 +42,13 @@ | |||||
| <input type="text" id="iptWechatAppID" class="form-control"> | <input type="text" id="iptWechatAppID" class="form-control"> | ||||
| </div> | </div> | ||||
| <div class="form-group"> | <div class="form-group"> | ||||
| <label for="iptWechatAppSecret">AppSecret</label> | |||||
| <input type="text" id="iptWechatAppSecret" class="form-control"> | |||||
| <label for="iptWechatAPIv2Secret">APIv2Secret</label> | |||||
| <input type="text" id="iptWechatAPIv2Secret" class="form-control"> | |||||
| </div> | </div> | ||||
| <div class="form-group"> | <div class="form-group"> | ||||
| <label for="iptWechatMchID">商户号</label> | <label for="iptWechatMchID">商户号</label> | ||||
| <input type="text" id="iptWechatMchID" class="form-control"> | <input type="text" id="iptWechatMchID" class="form-control"> | ||||
| </div> | </div> | ||||
| <div class="form-group"> | |||||
| <label for="iptWechatAPIV3Key">APIv3秘钥</label> | |||||
| <input type="text" id="iptWechatAPIV3Key" class="form-control"> | |||||
| </div> | |||||
| <div class="form-group"> | |||||
| <label for="iptWechatSerialNo">商户证书序列号</label> | |||||
| <input type="text" id="iptWechatSerialNo" class="form-control"> | |||||
| </div> | |||||
| <div class="form-group"> | |||||
| <label>商户证书文件</label> | |||||
| <div class="custom-file"> | |||||
| <input type="file" id="iptWechatPrivateKey" class="custom-file-input"> | |||||
| <label class="custom-file-label" for="iptWechatPrivateKey" data-browse="选择">选择商户证书文件</label> | |||||
| </div> | |||||
| </div> | |||||
| <div class="form-group"> | <div class="form-group"> | ||||
| <label for="iptWechatSortrank">排序(越小越靠前)</label> | <label for="iptWechatSortrank">排序(越小越靠前)</label> | ||||
| <input type="text" id="iptWechatSortrank" class="form-control" value="0"> | <input type="text" id="iptWechatSortrank" class="form-control" value="0"> | ||||
| @@ -88,25 +73,8 @@ | |||||
| <input type="text" id="iptAlipayPrivateKey" class="form-control"> | <input type="text" id="iptAlipayPrivateKey" class="form-control"> | ||||
| </div> | </div> | ||||
| <div class="form-group"> | <div class="form-group"> | ||||
| <label>应用公钥证书</label> | |||||
| <div class="custom-file"> | |||||
| <input type="file" id="iptAlipayAppCertPublicKey" class="custom-file-input"> | |||||
| <label class="custom-file-label" for="iptAlipayAppCertPublicKey" data-browse="选择">选择应用公钥证书文件</label> | |||||
| </div> | |||||
| </div> | |||||
| <div class="form-group"> | |||||
| <label>支付宝公钥证书</label> | |||||
| <div class="custom-file"> | |||||
| <input type="file" id="iptAlipayCertPublicKey" class="custom-file-input"> | |||||
| <label class="custom-file-label" for="iptAlipayCertPublicKey" data-browse="选择">选择支付宝公钥证书文件</label> | |||||
| </div> | |||||
| </div> | |||||
| <div class="form-group"> | |||||
| <label>支付宝根证书</label> | |||||
| <div class="custom-file"> | |||||
| <input type="file" class="custom-file-input" id="iptAlipayRootCert"> | |||||
| <label class="custom-file-label" for="iptAlipayRootCert" data-browse="选择">选择支付宝根证书文件</label> | |||||
| </div> | |||||
| <label for="iptAlipayCertPublicKey">支付宝公钥证书</label> | |||||
| <input type="text" id="iptAlipayCertPublicKey" class="form-control"> | |||||
| </div> | </div> | ||||
| <div class="form-group"> | <div class="form-group"> | ||||
| <label for="iptAlipaySignType">签名类型</label> | <label for="iptAlipaySignType">签名类型</label> | ||||
| @@ -192,20 +160,15 @@ | |||||
| let config = { | let config = { | ||||
| Wechat: { | Wechat: { | ||||
| AppID: '', | AppID: '', | ||||
| AppSecret: '', | |||||
| APIv2Secret: '', | |||||
| MchID: '', | MchID: '', | ||||
| APIV3Key: '', | |||||
| SerialNo: '', | |||||
| PrivateKey: '', | |||||
| Sortrank: 0, | Sortrank: 0, | ||||
| Enabled: true, | Enabled: true, | ||||
| }, | }, | ||||
| Alipay: { | Alipay: { | ||||
| APPID: '', | APPID: '', | ||||
| PrivateKey: '', | PrivateKey: '', | ||||
| AppCertPublicKey: '', | |||||
| CertPublicKey: '', | CertPublicKey: '', | ||||
| RootCert: '', | |||||
| SignType: 'RSA2', | SignType: 'RSA2', | ||||
| Sortrank: 0, | Sortrank: 0, | ||||
| Enabled: false, | Enabled: false, | ||||
| @@ -122,39 +122,72 @@ if ($paytype === 0) { | |||||
| if($paytype === 1) { | if($paytype === 1) { | ||||
| //微信支付 | //微信支付 | ||||
| include_once(DEDEINC.'/sdks/include.php'); | include_once(DEDEINC.'/sdks/include.php'); | ||||
| include_once(DEDEINC.'/libraries/oxwindow.class.php'); | |||||
| $pInfo = $dsql->GetOne("SELECT * FROM `#@__sys_payment` WHERE id = $paytype"); | $pInfo = $dsql->GetOne("SELECT * FROM `#@__sys_payment` WHERE id = $paytype"); | ||||
| $pData = (array)json_decode($pInfo['config']); | $pData = (array)json_decode($pInfo['config']); | ||||
| $config = array( | $config = array( | ||||
| "appid" => $pData['AppID'], | "appid" => $pData['AppID'], | ||||
| "mch_id" => $pData['MchID'], | "mch_id" => $pData['MchID'], | ||||
| "mch_key" => $pData['AppSecret'], | |||||
| "mch_key" => $pData['APIv2Secret'], | |||||
| ); | ); | ||||
| $wechat = new \WeChat\Pay($config); | $wechat = new \WeChat\Pay($config); | ||||
| $options = array( | $options = array( | ||||
| 'product_id' => $buyid, | |||||
| 'product_id' => $buyid, | |||||
| 'body' => '测试商品', | 'body' => '测试商品', | ||||
| 'out_trade_no' => time(), | |||||
| 'total_fee' => '1', | |||||
| 'out_trade_no' => $buyid, | |||||
| 'total_fee' => $row['money']*100, | |||||
| 'trade_type' => 'NATIVE', | 'trade_type' => 'NATIVE', | ||||
| 'notify_url' => 'http://a.com/text.html', | |||||
| 'spbill_create_ip' => '127.0.0.1', | |||||
| 'notify_url' => 'https://www.dedebiz.com/notify?platform=wxpay', | |||||
| ); | ); | ||||
| try { | try { | ||||
| // 生成预支付码 | // 生成预支付码 | ||||
| $result = $wechat->createOrder($options); | $result = $wechat->createOrder($options); | ||||
| var_dump($result); | |||||
| // 创建JSAPI参数签名 | |||||
| $options = $wechat->createParamsForRuleQrc($buyid); | |||||
| var_dump($options);exit; | |||||
| $payurl = $result['code_url']; | |||||
| $msg = "请使用微信扫一扫,扫描二维码支付:<div id='qrcode' style='width:200px; height:200px; margin-top:15px;'></div><br/><a href='buy_action.php?dopost=wechat_ok&buyid={$buyid}' class='btn btn-success btn-sm'>已完成支付</a> <a href='operation.php' class='btn btn-outline-success btn-sm'>返回订单管理</a>"; | |||||
| $script = '<script type="text/javascript">var qrcode = new QRCode(document.getElementById("qrcode"), { | |||||
| width : 300, | |||||
| height : 300, | |||||
| correctLevel : 3 | |||||
| });qrcode.makeCode("'.$payurl.'");</script>'; | |||||
| $wintitle = "微信支付"; | |||||
| $wecome_info = " ";//这个空格不要去 | |||||
| $win = new OxWindow(); | |||||
| $win->AddMsgItem($msg); | |||||
| $winform = $win->GetWindow("hand", " ", false); | |||||
| $win->Display(DEDEMEMBER."/templets/win_templet.htm"); | |||||
| } catch (Exception $e) { | } catch (Exception $e) { | ||||
| ShowMsg("生成微信支付信息失败,请联系网站管理员", "javascript:;"); | |||||
| exit; | |||||
| } | |||||
| } elseif ($paytype === 2) { | |||||
| include_once(DEDEINC.'/libraries/oxwindow.class.php'); | |||||
| $pInfo = $dsql->GetOne("SELECT * FROM `#@__sys_payment` WHERE id = $paytype"); | |||||
| $pData = (array)json_decode($pInfo['config']); | |||||
| $config = array( | |||||
| "sign_type" => $pData['SignType'], | |||||
| "appid" => $pData['APPID'], | |||||
| "private_key" => $pData['PrivateKey'], | |||||
| "public_key" => $pData['CertPublicKey'], | |||||
| "notify_url" => 'https://www.dedebiz.com/alipay-notify.php', | |||||
| "return_url" => 'https://www.dedebiz.com/alipay-notify.php', | |||||
| ); | |||||
| //支付宝 | |||||
| try { | |||||
| // 实例支付对象 | |||||
| $pay = \AliPay\Web::instance($config); | |||||
| // 参考链接:https://docs.open.alipay.com/api_1/alipay.trade.page.pay | |||||
| $result = $pay->apply(array([ | |||||
| 'out_trade_no' => $buyid, // 商户订单号 | |||||
| 'total_amount' => sprintf("%d",$row['money']), // 支付金额 | |||||
| 'subject' => '支付订单描述', // 支付订单描述 | |||||
| ])); | |||||
| // 出错啦,处理下吧 | |||||
| echo $e->getMessage() . PHP_EOL; | |||||
| var_dump(htmlspecialchars( $result)); | |||||
| } catch (Exception $e) { | |||||
| echo $e->getMessage(); | |||||
| } | } | ||||
| } elseif ($paytype === 3) { | |||||
| } elseif ($paytype === 3) { | |||||
| include_once(DEDEINC.'/libraries/oxwindow.class.php'); | include_once(DEDEINC.'/libraries/oxwindow.class.php'); | ||||
| //银行转账 | //银行转账 | ||||
| $pInfo = $dsql->GetOne("SELECT * FROM `#@__sys_payment` WHERE id = $paytype"); | $pInfo = $dsql->GetOne("SELECT * FROM `#@__sys_payment` WHERE id = $paytype"); | ||||
| @@ -5,6 +5,7 @@ | |||||
| <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"> | ||||
| <title>{dede:wintitle/}</title> | <title>{dede:wintitle/}</title> | ||||
| <script src="{dede:global.cfg_cmsurl/}/static/web/js/jquery.min.js"></script> | <script src="{dede:global.cfg_cmsurl/}/static/web/js/jquery.min.js"></script> | ||||
| <script src="{dede:global.cfg_cmsurl/}/static/web/js/qrcode.min.js"></script> | |||||
| <link rel="stylesheet" href="{dede:global.cfg_cmsurl/}/static/web/css/bootstrap.min.css"> | <link rel="stylesheet" href="{dede:global.cfg_cmsurl/}/static/web/css/bootstrap.min.css"> | ||||
| <link rel="stylesheet" href="{dede:global.cfg_cmsurl/}/static/web/font/css/font-awesome.min.css"> | <link rel="stylesheet" href="{dede:global.cfg_cmsurl/}/static/web/font/css/font-awesome.min.css"> | ||||
| <link rel="stylesheet" href="{dede:global.cfg_cmsurl/}/static/web/css/style.css"> | <link rel="stylesheet" href="{dede:global.cfg_cmsurl/}/static/web/css/style.css"> | ||||
| @@ -26,5 +27,6 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| {dede:include filename='foot.htm'/} | {dede:include filename='foot.htm'/} | ||||
| {dede:script/} | |||||
| </body> | </body> | ||||
| </html> | </html> | ||||