歡迎來到安信科技官方網(wǎng)站!【www.512ons.com】
18112005550
工作時間: 8:30-21:30
新聞中心
News Center

微信公眾號支付源碼asp分享(2.微信公眾號支付程序類文件)

資訊分類: 移動微信  瀏覽: 2019年11月3日

微信公眾號支付源碼asp分享

微信公眾號支付程序類文件:class.asp

--------------------------------------------

dim apiurl,create_ip,nonce_str,timeStamp,xmlhttp,preCookies,json_str
preCookies      = "aqefd"
create_ip       = GetIP()
nonce_str       = GetRnd(10)
timeStamp       = ToUnixTime(now())
xmlhttp         = "Msxml2.ServerXMLHTTP.6.0" '候選:Msxml2.ServerXMLHTTP.3.0
json_str        = "2" '1 or 2

'微信支付V3獲取Prepay_Id
Function get_prepay_id()
dim postData,signValue,post_url,sign,returnXml,xml_dom,return_code,result_code
post_url= "https://api.mch.weixin.qq.com/pay/unifiedorder"
sign="appid="&getAppId&"&attach="&attach_my&"&body="&body&"&mch_id="&getMCHID&"&nonce_str="&nonce_str&"&notify_url="&notify_url&"&openid="&openid&"&out_trade_no="&out_trade_no&"&spbill_create_ip="&create_ip&"&total_fee="&total_fee&"&trade_type=JSAPI&key="&getPartnerKey
signValue=UCase(MD5(sign,"UTF-8"))
postData="<xml>"&_
"<appid><![CDATA["&getAppId&"]]></appid>"&_
"<attach><![CDATA["&attach_my&"]]></attach>"&_
"<body><![CDATA["&body&"]]></body>"&_
"<mch_id><![CDATA["&getMCHID&"]]></mch_id>"&_
"<nonce_str><![CDATA["&nonce_str&"]]></nonce_str>"&_
"<notify_url><![CDATA["&notify_url&"]]></notify_url>"&_
"<openid><![CDATA["&openid&"]]></openid>"&_
"<out_trade_no><![CDATA["&out_trade_no&"]]></out_trade_no>"&_
"<spbill_create_ip><![CDATA["&create_ip&"]]></spbill_create_ip>"&_
"<total_fee><![CDATA["&total_fee&"]]></total_fee>"&_
"<trade_type><![CDATA[JSAPI]]></trade_type>"&_
"<sign><![CDATA["&signValue&"]]></sign>"&_
"</xml>"
returnXml=Get_code_url(post_url,postData)
set xml_dom=Server.CreateObject("MSXML2.DOMDocument")
xml_dom.loadXml(returnXml)
return_code=xml_dom.getelementsbytagname("return_code").item(0).text
if return_code="FAIL" then
'協(xié)議級錯誤
get_prepay_id=xml_dom.getelementsbytagname("return_msg").item(0).text
response.Write("協(xié)議級接口調(diào)用錯誤:"&get_prepay_id)
response.End()
else
result_code=xml_dom.getelementsbytagname("result_code").item(0).text
if result_code="FAIL" then
'業(yè)務(wù)級錯誤
get_prepay_id=xml_dom.getelementsbytagname("err_code_des").item(0).text
response.Write("業(yè)務(wù)級支付錯誤:"&get_prepay_id)
response.End()
else
if return_code="SUCCESS" and result_code="SUCCESS" then
'數(shù)據(jù)正常
get_prepay_id=xml_dom.getelementsbytagname("prepay_id").item(0).text
end if
end if
end if
End Function

'微信支付V3,返回最后提交的paySign
Function get_paySign()
dim sign
sign="appId="&getAppId&"&nonceStr="&nonce_str&"&package=prepay_id="&prepay_id&"&signType=MD5&timeStamp="&timeStamp&"&key="&getPartnerKey
get_paySign=UCase(MD5(sign,"UTF-8"))
End Function

'獲取用戶OpenID
Function GetOpenId()
if request.Cookies(preCookies&"openid")="" then
dim code,s_url,url,strJson,access_token,openids
code=request("code")
if code="" then
s_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="&getAppId&"&redirect_uri="&Server.URLEncode(redirect_url)&"&response_type=code&scope=snsapi_base&state=Sky#wechat_redirect"
response.Redirect(s_url)
response.End()
else
url="https://api.weixin.qq.com/sns/oauth2/access_token?appid="&getAppId&"&secret="&getSecret&"&code="&code&"&grant_type=authorization_code"
strJson=GetURL(url)
dim objTest
if json_str="1" then
Call InitScriptControl:Set objTest = getJSONObject(strJson)
elseif json_str="2" then
Set objTest = getjson(strJson)
end if
if InStr(strJson,"errcode")>0 then
response.Write "獲取Openid出錯:"&strJson
response.End()
else
openids=objTest.openid '獲取openid
Response.Cookies(preCookies&"openid")=openids
Response.Cookies(preCookies&"openid").Expires=DateAdd("m",60,now())
GetOpenId=openids
end if
end if
else
GetOpenId=request.Cookies(preCookies&"openid")
end if
End Function

Copyright © 2007-2024 安信科技(十五周年紀(jì)念版) All Rights Reserved  備案號:蘇ICP備15047094號-3 
網(wǎng)站首頁 |  新聞資訊 |  服務(wù)項目 |  軟件產(chǎn)品 |  試用下載 |  需求提交 |  模版建站 |  關(guān)于安信 |  產(chǎn)品授權(quán) |  聯(lián)系我們 |  定制開發(fā) | 
服務(wù)熱線:181-1200-5550  客服QQ: 120094883  | 郵箱:120094883#qq.com(#改@)  
国产麻豆天美果冻无码视频 | 日韩欧美视频在线| 人禽无码视频在线观看| 18禁美女黄网站色大片免费观看| 国产精品天天在线午夜更新| n男同时一女的h文4p| 工囗番漫画全彩无遮拦老师| 久久受www免费人成_看片中文| 日韩精品极品视频在线观看免费| 亚洲AV日韩精品久久久久久| 日韩乱码人妻无码中文字幕视频| 久久精品国产亚洲AV天海翼| 挺进邻居丰满少妇的身体| 亚洲AV无码专区国产乱码电影| 日本阿v视频在线观看| 亚洲av永久综合在线观看尤物| 欧美性猛交xxxx乱大交丰满| 伊人婷婷色香五月综合缴激情| 欧美激情在线播放一区二区三区| 免费观看一级特黄欧美大片| 精品一区二区三区在线视频| 国产h在线播放| 老司机免费福利午夜入口ae58 | 91色视频网站| 国精产品一品二品国精品69xx| 三男三女换着曰| 强行扒开双腿猛烈进入| 久99久无码精品视频免费播放| 无码人妻精品一区二区三区蜜桃| 久久精品国产9久久综合| 日韩a在线观看免费观看| 久久伊人精品一区二区三区| 无码人妻久久一区二区三区免费 | 国语自产偷拍精品视频偷拍| 69久久夜色精品国产69| 国产女人视频免费观看| 韩国亚洲伊人久久综合影院| 国产模特众筹精品视频| 麻豆国产原创剧情精品| 国产欧美日韩精品a在线观看| 色九月亚洲综合网|