Dim StringA,stringSignTemp,sign As String
'stringA ="appid=wxa7154bc4751eddec&body=test&device_info=1000&mch_id=1488726912&nonce_str=ibuaiVcKdpRxkhJA"
' stringSignTemp = stringA + "&key=hahaqwertyuioasdfghjklzxcvblanbo"
Dim attach_my,body,getMCHID,notify_url,openid,out_trade_no,create_ip,getPartnerKey As String
Dim st As New Date(1970,1,1,8,0,0)
Dim getAppId As String = "wxa7154bc4751eddec" '开发者ID
Dim timestamp As Integer = CInt((Date.Now - st).TotalSeconds()) '时间戳
Dim total_fee
attach_my ="支付测试"
body = "test"
getMCHID ="1488726912"
Dim nonce_str As String = Rand.NextString(16) '随机字符
notify_url ="http://www.664748.top/hello.htm"
openid = "ofRouwl_aRCGFTkhxeVECkQmzd8g"
out_trade_no ="1415659990"
create_ip="106.14.79.51"
total_fee =1
getPartnerKey = "hahaqwertyuioasdfghjklzxcvblanbo"
sign="appid=" & getAppId & "&attach=" & attach_my & "&body=" & body & "&mch_id=" & getMCHID & "&n¬ify_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
Output.Show(sign)
Dim md5 = System.Security.Cryptography.MD5.Create()
Dim bs = md5.ComputeHash(Encoding.UTF8.GetBytes(sign))
Dim sb As new StringBuilder()
For Each b As Byte In bs
sb.Append(b.ToString("x2"))
Next
sign = sb.ToString().ToUpper()
msgbox(sign)
'sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sign, "MD5")
Dim xml As String
Dim xo As New XObject
xo.AddCDATA("appid",getAppId)
xo.AddCDATA("attach",attach_my)
xo.AddCDATA("body",body)
xo.AddCDATA("mch_id",getMCHID )
xo.AddCDATA("nonce_str",nonce_str)
xo.AddCDATA("notify_url",notify_url)
xo.AddCDATA("openid",openid)
xo.AddCDATA("out_trade_no",out_trade_no)
xo.AddCDATA("spbill_create_ip",create_ip)
xo.AddCDATA("total_fee",total_fee)
xo.AddCDATA("trade_type","JSAPI")
xo.AddCDATA("sign",sign)
'Dim hc As New HttpClient("https://api.mch.weixin.qq.com/pay/unifiedorder")
'hc.FormData.Add("xml",xo.ToXML)
'hc.C
'hc.Content = xo.ToXML
'MessageBox.Show(hc.getdata)
'
Dim hc As New HttpClient("https://api.mch.weixin.qq.com/pay/unifiedorder")
hc.Content = xo.ToXML
MessageBox.Show(hc.getdata)