• <menu id="smwsk"><strong id="smwsk"></strong></menu>
    <menu id="smwsk"><strong id="smwsk"></strong></menu>
  • <menu id="smwsk"><tt id="smwsk"></tt></menu>
  • 歡迎來到安信科技官方網站!【www.timetechnb.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
    '協議級錯誤
    get_prepay_id=xml_dom.getelementsbytagname("return_msg").item(0).text
    response.Write("協議級接口調用錯誤:"&get_prepay_id)
    response.End()
    else
    result_code=xml_dom.getelementsbytagname("result_code").item(0).text
    if result_code="FAIL" then
    '業務級錯誤
    get_prepay_id=xml_dom.getelementsbytagname("err_code_des").item(0).text
    response.Write("業務級支付錯誤:"&get_prepay_id)
    response.End()
    else
    if return_code="SUCCESS" and result_code="SUCCESS" then
    '數據正常
    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 安信科技(十五周年紀念版) All Rights Reserved  備案號:蘇ICP備15047094號-3 
    網站首頁 |  新聞資訊 |  服務項目 |  軟件產品 |  試用下載 |  需求提交 |  模版建站 |  關于安信 |  產品授權 |  聯系我們 |  定制開發 | 
    服務熱線:181-1200-5550  客服QQ: 120094883  | 郵箱:120094883#qq.com(#改@)  
    欧美黑白配性xxxxx