Public Account Payment and development issues
1. An error occurred while calling the unified order interface.
Https://pay.weixin.qq.com/wiki/doc/api/app.php? Chapter = 9_1
The parameter is entered in string Format at the beginning. An error is returned. Later, I read other blogs and demos and learned that I should write them like this:
// Add data to the dictionary SortedDictionary <string, string> m_values = new SortedDictionary <string, string> (); m_values.Add ("appid", appID ); m_values.Add ("body", bodymsg); m_values.Add ("mch_id", mch_id); m_values.Add ("nonce_str", nonce_str); m_values.Add ("notify_url", notify_url ); m_values.Add ("openid", openID); m_values.Add ("out_trade_no", orderId); m_values.Add ("spbill_create_ip", region); m_values.Add ("total_region", Region ()); m_values.Add ("trade_type", "JSAPI"); string signkey = WXDes. totUrl (m_values); // concatenate data
// Splice string key = value public static string TotUrl (SortedDictionary <string, string> m_values) {int I = 0; StringBuilder sb = new StringBuilder (); foreach (KeyValuePair <string, string> temp in m_values) {if (temp. value = "" | temp. value = null | temp. key. toLower () = "sign") {continue;} I ++; sb. append (temp. key. trim () + "=" + temp. value. trim () + "&");} sb. append ("key =" + ConfigHelp. APISign); string signkey = sb. toString (); return signkey ;}
2.Question about calling uniform single body Encoding
At the beginning of the writing is the direct body = "hello" direct value, but the return code says there is no UTF-8 encoding, and then HttpUtility. urlEncode ("member recharge", Encoding. getEncoding ("UTF-8"), the result of the payment page shows the encoded text, and then see the post said direct assignment is OK, and has been, really !!!!
Body = "direct assignment"
3. the API Password box page cannot be displayed.
Get the returned prepay_id and access the API interface. The generated json is returned to the front end. If alert (json string) has no problem, a parameter is missing when it is passed in. After several twists and turns
In this way, the returned json is converted.JSON. parse (json)