public override void SendRequest() { string str3 = SignUtil.HmacSign(SignUtil.HmacSign(this.characterSet + this.callbackUrl + this.notifyUrl + this.ipAddress + this.MerchantAcctId + this.requestId + this.signType + this.type + this.version + this.amount + this.bankAbbr + this.currency + this.orderDate + this.orderId + this.merAcDate + this.period + this.periodUnit + this.merchantAbbr + this.productDesc + this.productId + this.productName + this.productNum + this.reserved1 + this.reserved2 + this.userToken + this.showUrl + this.couponsFlag), this.Key); string data = "characterSet=" + this.characterSet + "&callbackUrl=" + this.callbackUrl + "¬ifyUrl=" + this.notifyUrl + "&ipAddress=" + this.ipAddress + "&merchantId=" + this.MerchantAcctId + "&requestId=" + this.requestId + "&signType=" + this.signType + "&type=" + this.type + "&version=" + this.version + "&amount=" + this.amount + "&bankAbbr=" + this.bankAbbr + "¤cy=" + this.currency + "&orderDate=" + this.orderDate + "&orderId=" + this.orderId + "&merAcDate=" + this.merAcDate + "&period=" + this.period + "&periodUnit=" + this.periodUnit + "&merchantAbbr=" + this.merchantAbbr + "&productDesc=" + this.productDesc + "&productId=" + this.productId + "&productName=" + this.productName + "&productNum=" + this.productNum + "&reserved1=" + this.reserved1 + "&reserved2=" + this.reserved2 + "&userToken=" + this.userToken + "&showUrl=" + this.showUrl + "&couponsFlag=" + this.couponsFlag + "&hmac=" + str3; Hashtable hashtable = IPosMUtil.parseStringToMap(IPosMUtil.httpRequest("https://ipos.10086.cn/ips/cmpayService", data)); string hmac = (string)hashtable["hmac"]; string str7 = (string)hashtable["returnCode"]; string str8 = (string)hashtable["message"]; if ("000000".Equals(str7) && SignUtil.verifySign(((string)hashtable["merchantId"]) + ((string)hashtable["requestId"]) + ((string)hashtable["signType"]) + ((string)hashtable["type"]) + ((string)hashtable["version"]) + str7 + str8 + ((string)hashtable["payUrl"]), this.Key, hmac)) { string payUrl = (string)hashtable["payUrl"]; HttpContext.Current.Response.Redirect(IPosMUtil.getRedirectUrl(payUrl)); } }
protected void Page_Load(object sender, EventArgs e) { try { PerrMsg.Text = ""; //获取页面输入 String orderId = Request.Form["orderId"]; ///获取参数输入 String callbackUrl = GlobalParam.getInstance().callbackUrl; String notifyUrl = GlobalParam.getInstance().notifyUrl; String merchantId = GlobalParam.getInstance().merchantId; String requestId = IPosMUtil.getTicks(); String signType = GlobalParam.getInstance().signType; String type = "OrderQuery"; String version = GlobalParam.getInstance().version; String signKey = GlobalParam.getInstance().signKey; String reqUrl = GlobalParam.getInstance().reqUrl; ///组织发送报文的签名原文 String signData = merchantId + requestId + signType + type + version + orderId; ///生成发送报文的签名 String reqHmac1 = SignUtil.HmacSign(signData); String reqHmac = SignUtil.HmacSign(reqHmac1, signKey); ///组织支付请求原始报文 String reqData = "merchantId=" + merchantId + "&requestId=" + requestId + "&signType=" + signType + "&type=" + type + "&version=" + version + "&orderId=" + orderId + "&hmac=" + reqHmac; ///发送支付请求,并接收手机支付平台返回的支付地址 String recData = IPosMUtil.httpRequest(reqUrl, reqData); Hashtable ht = IPosMUtil.parseStringToMap(recData); String recHmac = (String)ht["hmac"]; String recReturnCode = (String)ht["returnCode"]; if ("000000".Equals(recReturnCode)) { ///组织接收报文的签名原文 String verData = (String)ht["merchantId"] + (String)ht["payNo"] + (String)ht["returnCode"] + (String)ht["message"] + (String)ht["signType"] + (String)ht["type"] + (String)ht["version"] + (String)ht["amount"] + (String)ht["amtItem"] + (String)ht["bankAbbr"] + (String)ht["mobile"] + (String)ht["orderId"] + (String)ht["payDate"] + (String)ht["reserved1"] + (String)ht["reserved2"] + (String)ht["status"] + (String)ht["orderDate"] + (String)ht["fee"]; ///验签 Boolean flag = SignUtil.verifySign(verData, signKey, recHmac); if (flag) { Pamount.Text = (String)ht["amount"]; PamtItem.Text = (String)ht["amtItem"]; PbankAbbr.Text = (String)ht["bankAbbr"]; Pmobile.Text = (String)ht["mobile"]; PorderId.Text = (String)ht["orderId"]; PpayDate.Text = (String)ht["payDate"]; Preserved1.Text = HttpUtility.UrlDecode((String)ht["reserved1"], Encoding.UTF8); Preserved2.Text = HttpUtility.UrlDecode((String)ht["reserved2"], Encoding.UTF8); Pstatus.Text = (String)ht["status"]; PorderDate.Text = (String)ht["orderDate"]; Pfee.Text = (String)ht["fee"]; } else { PerrMsg.Text = "验签失败"; PreturnCode.Text = recReturnCode; Pmessage.Text = HttpUtility.UrlDecode((String)ht["message"], Encoding.UTF8); } } else { PerrMsg.Text = "查询订单失败"; PreturnCode.Text = recReturnCode; Pmessage.Text = HttpUtility.UrlDecode((String)ht["message"], Encoding.UTF8); } } catch (Exception el) { PerrMsg.Text = el.Message; } }
protected void Page_Load(object sender, EventArgs e) { try{ //页面初始化 PerrMsg.Text = ""; //页面传输参数 String orderId = (String)Request.Form["orderId"]; String amount = (String)Request.Form["amount"]; ///获取参数输入 String merchantId = GlobalParam.getInstance().merchantId; String requestId = IPosMUtil.getTicks(); String signType = GlobalParam.getInstance().signType; String type = "OrderRefund"; String version = GlobalParam.getInstance().version; String signKey = GlobalParam.getInstance().signKey; String reqUrl = GlobalParam.getInstance().reqUrl; ///组织发送报文的签名原文 String signData = merchantId + requestId + signType + type + version + orderId + amount; ///生成发送报文的签名 String reqHmac1 = SignUtil.HmacSign(signData); String reqHmac = SignUtil.HmacSign(reqHmac1, signKey); ///组织支付请求原始报文 String reqData = "merchantId=" + merchantId + "&requestId=" + requestId + "&signType=" + signType + "&type=" + type + "&version=" + version + "&orderId=" + orderId + "&amount=" + amount + "&hmac=" + reqHmac; ///发送支付请求,并接收手机支付平台返回的支付地址 String recData = IPosMUtil.httpRequest(reqUrl, reqData); Hashtable ht = IPosMUtil.parseStringToMap(recData); String recHmac = (String)ht["hmac"]; String recReturnCode = (String)ht["returnCode"]; if ("000000".Equals(recReturnCode)) { ///组织接收报文的签名原文 String verData = (String)ht["merchantId"] + (String)ht["payNo"] + (String)ht["returnCode"] + (String)ht["message"] + (String)ht["signType"] + (String)ht["type"] + (String)ht["version"] + (String)ht["amount"] + (String)ht["orderId"] + (String)ht["status"]; ///验签 Boolean flag = SignUtil.verifySign(verData, signKey, recHmac); if (flag) { Pamount.Text = (String)ht["amount"]; PorderId.Text = (String)ht["orderId"]; Pstatus.Text = (String)ht["status"]; } else { PerrMsg.Text = "验签失败"; PreturnCode.Text = recReturnCode; Pmessage.Text = HttpUtility.UrlDecode((String)ht["message"], Encoding.GetEncoding("UTF-8")); } } else { PerrMsg.Text = "退款失败"; PreturnCode.Text = recReturnCode; Pmessage.Text = HttpUtility.UrlDecode((String)ht["message"], Encoding.GetEncoding("UTF-8")); } } catch (Exception el) { PerrMsg.Text = el.Message; } }
public void Button1_Click(object sender, EventArgs e) { ///获取客户端IP String ipAddress = IPosMUtil.getIpAddress(); ///获取参数输入 String characterSet = GlobalParam.getInstance().characterSet; String callbackUrl = GlobalParam.getInstance().callbackUrl; String notifyUrl = GlobalParam.getInstance().notifyUrl; String merchantId = GlobalParam.getInstance().merchantId; String requestId = IPosMUtil.getTicks(); String signType = GlobalParam.getInstance().signType; String type = "DirectPayConfirm"; String version = GlobalParam.getInstance().version; String signKey = GlobalParam.getInstance().signKey; String reqUrl = GlobalParam.getInstance().reqUrl; ///获取页面输入 String amount = (String)Request.Form["amount"]; String bankAbbr = (String)Request.Form["bankAbbr"]; String currency = (String)Request.Form["currency"]; String orderDate = (String)Request.Form["orderDate"]; String merAcDate = (String)Request.Form["merAcDate"]; String orderId = (String)Request.Form["orderId"]; String period = (String)Request.Form["period"]; String periodUnit = (String)Request.Form["periodUnit"]; String merchantAbbr = (String)Request.Form["merchantAbbr"]; String productDesc = (String)Request.Form["productDesc"]; String productId = (String)Request.Form["productId"]; String productName = (String)Request.Form["productName"]; String productNum = (String)Request.Form["productNum"]; String reserved1 = (String)Request.Form["reserved1"]; String reserved2 = (String)Request.Form["reserved2"]; String userToken = (String)Request.Form["userToken"]; String showUrl = (String)Request.Form["showUrl"]; String couponsFlag = (String)Request.Form["couponsFlag"]; ///组织发送报文的签名原文 String signData = characterSet + callbackUrl + notifyUrl + ipAddress + merchantId + requestId + signType + type + version + amount + bankAbbr + currency + orderDate + orderId + merAcDate + period + periodUnit + merchantAbbr + productDesc + productId + productName + productNum + reserved1 + reserved2 + userToken + showUrl + couponsFlag; ///生成发送报文的签名 String reqHmac1 = SignUtil.HmacSign(signData); String reqHmac = SignUtil.HmacSign(reqHmac1, signKey); ///组织支付请求原始报文 String reqData = "characterSet=" + characterSet + "&callbackUrl=" + callbackUrl + "¬ifyUrl=" + notifyUrl + "&ipAddress=" + ipAddress + "&merchantId=" + merchantId + "&requestId=" + requestId + "&signType=" + signType + "&type=" + type + "&version=" + version + "&amount=" + amount + "&bankAbbr=" + bankAbbr + "¤cy=" + currency + "&orderDate=" + orderDate + "&orderId=" + orderId + "&merAcDate=" + merAcDate + "&period=" + period + "&periodUnit=" + periodUnit + "&merchantAbbr=" + merchantAbbr + "&productDesc=" + productDesc + "&productId=" + productId + "&productName=" + productName + "&productNum=" + productNum + "&reserved1=" + reserved1 + "&reserved2=" + reserved2 + "&userToken=" + userToken + "&showUrl=" + showUrl + "&couponsFlag=" + couponsFlag + "&hmac=" + reqHmac; ///发送支付请求,并接收手机支付平台返回的支付地址 String recData = IPosMUtil.httpRequest(reqUrl, reqData); Hashtable ht = IPosMUtil.parseStringToMap(recData); String recHmac = (String)ht["hmac"]; String recReturnCode = (String)ht["returnCode"]; String message = (String)ht["message"]; if ("000000".Equals(recReturnCode)) { ///组织接收报文的签名原文 String verData = (String)ht["merchantId"] + (String)ht["requestId"] + (String)ht["signType"] + (String)ht["type"] + (String)ht["version"] + recReturnCode + message + (String)ht["payUrl"]; ///验签 Boolean flag = SignUtil.verifySign(verData, signKey, recHmac); if (flag) { String recPayUrl = (String)ht["payUrl"]; Response.Redirect(IPosMUtil.getRedirectUrl(recPayUrl)); } else { Response.Write("验签失败:"); Response.Write("returnCode = " + recReturnCode); Response.Write("&message = " + HttpUtility.UrlDecode(message, Encoding.UTF8)); } } else { Response.Write("下单失败:"); Response.Write("returnCode = " + recReturnCode + "&"); Response.Write("message = " + HttpUtility.UrlDecode(message, Encoding.UTF8)); } }