Article From:https://www.cnblogs.com/yangsongyan/p/9215334.html

1.On the premise that the XML and the generated sign are not identified, https://pay.weixin.qq.com/wiki/tools/signverify/ (verify the address)

–The above steps took 1 days, and a lot of it didn’t work.

2.To the public platform business center business payment API security added new IP address, and then to the IP below run just fine.

–It is also possible to execute on the local computer.

Attach the fields required by XML

//The APPID/ IDkey, which is the public number of the XML document, is changed by the key key set up for the business platform. The style is not moved, and the fields needed do not move.
public string GetXml()//XML to send
{
//Get a random number
Random ran = new Random();
int RandKey = ran.Next(10000, 99999);
//Define XML
StringBuilder strBuilder = new StringBuilder();
strBuilder.Append(“<xml>”);
strBuilder.Append(“<appid>wxbd6f4c5443fdf435</appid>”);//The APPID of the WeChat public
strBuilder.Append(“<attach>Recharge 10 yuan < /attach> “/ / supplementary description, unit name”
strBuilder.Append(“<body>The first line of success prompted by Yun Kai Chi Lian < /body> / / recharge
strBuilder.Append(“<device_info>WEB</device_info>”);//Equipment number
strBuilder.Append(“<mch_id>1909975435</mch_id>”);//Business ID
strBuilder.Append(“<nonce_str>1234567890</nonce_str>”);//Random string, the length is within 32 bits. Recommended random number generation algorithm
strBuilder.Append(“<notify_url>http://56996858.cn</notify_url>”);//Accept the callback address of the asynchronous receiving WeChat payment result notification.
strBuilder.Append(“<openid>o_Rq30XKSsaaF8tK1qmkBFec2Xng</openid>”);//openid
strBuilder.Append(“<out_trade_no>A0000000002</out_trade_no>”);//Order number, flow number, no repetition
strBuilder.Append(“<product_id>1</product_id>”);//Commodity number
strBuilder.Append(“<spbill_create_ip>115.159.208.52</spbill_create_ip>”);//Cloud server IP115.159.208.52
strBuilder.Append(“<total_fee>1</total_fee>”);//The amount, the unit is the Division
strBuilder.Append(“<trade_type>JSAPI</trade_type>”);//The recharge type jsapi is the public number payment
//Get signature value signature verification address https://pay.weixin.qq.com/wiki/tools/signverify/
string stringA = “appid=wxbd6fc53fdf35&attach=Recharge 10 yuan & body= cloud card Zhi Lian & device_info=WEB& mch_id=1494099752& nonce_str=1234567890& notify_urL=http://56996858.cn& openid=o_Rq30XKSsaaF8tK1qmkBFec2Xng& out_trade_no=A0000000002& producT_id=1& spbill_create_ip=115.159.208.52& total_fee=1& trade_type=JSAPI “;
string stringSignTemp = stringA + “&key=22233333333333333333333”; //Note: the key key set by key for the merchant platform
string sign = EncryptWithMD5(stringSignTemp).ToUpper(); //Note: MD5 signature method
WriteTextLog(stringSignTemp);
strBuilder.Append(“<sign>” + sign+ “</sign>”);//The signature value calculated by the signature algorithm is described in detail.
strBuilder.Append(“</xml>”);
WriteTextLog(strBuilder.ToString());
return strBuilder.ToString();
}

Leave a Reply

Your email address will not be published. Required fields are marked *