WeChat signature verification had no problem
Payment times the following error
Public string GetPayUrl (string productId)
{
WxPayData data=https://bbs.csdn.net/topics/new WxPayData ();
Data. The SetValue (" body ", "test");//commodity description
Data. The SetValue (" attach ", "test");//additional data
Data. SetValue (" out_trade_no ", a DateTime. Now. ToString (" yyyyMMddHHmmss "));//order number
Data. The SetValue (" total_fee ", "1");//total amount
Data. SetValue (" time_start, "DateTime. Now. ToString (" yyyyMMddHHmmss"));//deal starting time
Data. SetValue (" time_expire, "DateTime. Now. AddMinutes (10). ToString (" yyyyMMddHHmmss"));//deal ends time
Data. The SetValue (" goods_tag ", "test");//goods tag
Data. The SetValue (" trade_type ", "NATIVE");//transaction type
Data. The SetValue (" product_id ", productId);//commodity ID
WxPayData result=WxPayAPI. UnifiedOrder (data);//call the unified order interface
The string url=result. GetValue (" code_url "). The ToString ();//the order with a uniform interface to return the qr code link
Return the url;
}
Public static WxPayData UnifiedOrder (WxPayData inputObj, int timeOut=6)
{
The string url="https://api.mch.weixin.qq.com/pay/unifiedorder";
//inspection required parameter
if (! InputObj. IsSet (" out_trade_no "))
{
Throw new Exception (" lack of unified payment interface required parameters out_trade_no!" );
}
else if (! InputObj. IsSet (" body "))
{
Throw new Exception (" lack of unified payment interface required parameters body!" );
}
else if (! InputObj. IsSet (" total_fee "))
{
Throw new Exception (" lack of unified payment interface required parameters total_fee!" );
}
else if (! Trade_type inputObj. IsSet (" "))
{
Throw new Exception (" lack of unified payment interface required parameters trade_type!" );
}
//associated parameters
If (inputObj GetValue (" trade_type "). The ToString ()=="JSAPI" & amp; & ! InputObj. IsSet (" openid "))
{
Throw new Exception (" unified payment interface, lack of required parameters openid! Trade_type for JSAPI, openid for mandatory parameters!" );
}
If (inputObj GetValue (" trade_type "). The ToString ()=="NATIVE" & amp; & ! InputObj. IsSet (" product_id "))
{
Throw new Exception (" product_id unified payment interface, lack of required parameters. Trade_type for NATIVE, product_id for mandatory parameters!" );
}
//asynchronous notification url is not set, use the url in the configuration file is
if (! InputObj. IsSet (" notify_url "))
{
InputObj. SetValue (" notify_url, "WxSmConfig. NOTIFY_RESULT_URL);//asynchronous notification url
}
InputObj. SetValue (" appid ", WxSmConfig. Appid);//public account ID
InputObj. SetValue (" McH_id, "WxSmConfig. McH_id); No.//merchants
InputObj. SetValue (" spbill_create_ip, "HttpContext. Current. Request. UserHostAddress);//terminal IP
InputObj. SetValue (" nonce_str, "GenerateNonceStr ());//random string
//signature
InputObj. SetValue (" sign ", inputObj MakeSign ());
XML string=inputObj. ToXml ();
//var start=DateTime. Now;
WeiXin. WriteLog (" UnifiedOrder request: "+ XML);
String response=MyHttp. MyHttpPost (url, XML);
WeiXin. WriteLog (" UnifiedOrder response: "+ response).
//var end=DateTime. Now;
//int timeCost=(int) ((end - start). TotalMilliseconds);
WxPayData result=new WxPayData ();
Result. FromXml (response);
//ReportCostTime (url, timeCost, result);//speed report
return result;
}
/* *
* generates a random string, random strings contain letters or Numbers
* @ return random string
*/
Public static string GenerateNonceStr ()
{
Return the Guid. NewGuid (). The ToString (). The Replace (" - ", "");
}
CodePudding user response:
The elder brothers, to solve this problem, I also met this problem, and some mobile phones can pay, some mobile news this mistakeCodePudding user response:
Not yet for a few daysCodePudding user response:
The elder brothers, I have already solved, my question is api_key set problem, to change a, setting, complex point as far as possible, good!CodePudding user response:
The building Lord, solved? @ xiangronghua1984CodePudding user response:
The original poster is solved, please? Would you please send a source package to 863706132 @qq.com, learning how to learn! Thank you very much!CodePudding user response:
http://jingyan.baidu.com/article/59703552c3c9808fc1074072.html? St=2 & amp; OS x=0 & amp; Bd_page_type=1 & amp; Net_type=2