查看文件: index_wanpay.php
大小: 3.21 KB
类型: application/octet-stream
<?php //请求参数 $post_data["orgno"]="21009530";//商户 UEuIamCCD1lMuHvL $post_data["body"]="消费"; $post_data["total_fee"]="10000"; $post_data["returnurl"]="https://www.skybni.com/log/wanpayret.php"; $post_data["backurl"]='https://www.skybni.com/log/wanpayret.php'; $post_data["out_trade_no"]=date('YmdHis').sprintf('%04d',rand(1,9999)) ;//'2024032918005600008' ;//訂單號 #$post_data["type"]="AUTH_3DTRXTOKEN"; $post_data['nonce_str'] = rand(10000000, 99999999); $post_data['secondtimestamp'] = time(); $post_data['virtualatmvalidity'] = 3; #$post_data['payername'] = 'kevin'; #$post_data['payermobile'] = '0972295789'; #$post_data['payeremail'] = 'skybni678@gmail.com'; $post_datastr = ''; //使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串stringA foreach ($post_data AS $name => $value) { if (!is_array($value)) { if ($value != null && $value != '') { $post_datastr = $post_datastr . $name . '=' . $value . '&'; } } } $tmpArr = explode('&', trim($post_datastr, '&')); //参数名ASCII码从小到大排序(字典序) sort($tmpArr, SORT_STRING); $tmpStr = implode('&', $tmpArr); //拼接API密钥 $clientkey = "UEuIamCCD1lMuHvL";//秘钥 $tmpStr = $tmpStr . '&key=' . $clientkey; $sign = strtoupper(md5($tmpStr)); $post_data["sign"]=$sign;//签名 $ch = curl_init(); $url="https://api.wan-pay.com/wxzfservice/virtualatmpay"; //atm curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_URL,$url );//请求地址"https://apitest.xmfree.net:8118/wxzfservice/waporder" curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); $result = curl_exec($ch); curl_close($ch); /** * 返回结果 /** * 返回结果 https://epay.wan-pay.com/#/pages/Paywaporderys/waporderys3d?mac=B6EDAF245BD2A3657FB8BDDE6FD6302B846E5A46FC9CE4682C67BAE896C187F1EA84 "{"status":"900","info":"下單成功","data":{"html":"https://epay.wan-pay.com/#/pages/Paywaporderys/waporderys3d?mac=B6EDAF245BD2A3657FB8BDDE6FD6302BD044C2459AF0B41BE50B3664FE710463EF8D3D1732C6DDB3F9C2EA294297D6569FF55B3155555570CED36EB9552A237C0B0CE167967F0F582EE650E21F4A730CA12F05D5B8D1669C74382272E2E928A0443C3C2C4A62303566E4A7C1F943A57E04AA7963F023295DC6FE51C5A7C318DC","out_trade_no":"202411260918562539"}}" */ $test_dejson = json_decode($result, true); $logpath="/www2/skybni/log/wanpaylog.txt"; $fp = fopen($logpath, "a"); //$_SERVER['HTTP_REFERER']; fwrite($fp,"===== start log Wan-pay_visa SEND To wan-pay ".date('Y-m-d H:i:s',$post_data['secondtimestamp'])." ====\r\n"); fwrite($fp,$result."\r\n"); $test_dejson = json_decode($result, true); if(isset($test_dejson['info']) && $test_dejson['info']=="下單成功"){ $gotourl=$test_dejson['data']['html']; fwrite($fp,"=======下單成功=========="."\r\n"); echo "<script>location.href='".$gotourl."';</script>"; } else { echo "連線失敗"; fwrite($fp,"======== 連線失敗 Send End =================="."\r\n"); fclose($fp); }
保存
取消
返回文件列表