private string testRefund(HttpContext context) { try { string payNo = context.Request["orderno"]; Random rand = new Random(); int num = rand.Next(1000, 9999); Parameteres param = new Parameteres(); string orderno = DateTime.Now.ToString("yyyyMMddHHmmss") + num; Refund refund = new Refund(); refund.appid = "wxd6cf371dbe9f5906"; refund.key = "F56S456F4SD5F4S65F4AS65D4FS6D54F"; refund.mch_id = "1519238551"; refund.nonce_str = "5K8264ILTKCH16CQ2502SI8ZNMTM67VS"; //随机字符串 refund.out_refund_no = orderno; //退款单号随机生成 refund.out_trade_no = payNo; //支付单号 DataTable dt = ms.getDeposit(); int refundfee = 0; if (dt != null) { refundfee = Convert.ToInt32(dt.Rows[0]["deposit"]); } int totalfee = ms.selectPayFee(payNo); refund.refund_fee = totalfee.ToString(); refund.total_fee = totalfee.ToString(); refund.notify_url = "https://feibiao.ty-gz.com:8137/dist/Handler/refundNotify.ashx"; string strParam = getRefundParam(refund); string payResXML = Helper.PostWebRequest("https://api.mch.weixin.qq.com/secapi/pay/refund", strParam); //string certificatePath = ConfigurationManager.AppSettings["certificatePath"]; //return strParam; var payRes = XDocument.Parse(payResXML); var root = payRes.Element("xml"); //序列化相应参数返回给小程序 var res = GetPayRequestParam(root, refund.appid, refund.key); string strJson = JsonConvert.SerializeObject(res); return(strJson); } catch (Exception ex) { return(ex.ToString()); } }