/// <summary> /// 查询订单明细 /// </summary> /// <param name="p1_MerId">商户编号</param> /// <param name="keyValue">商户密钥</param> /// <param name="p2_Order">商户订单号</param> /// <returns>BuyQueryOrdDetailResult</returns> public static BuyQueryOrdDetailResult QueryOrdDetail(string p2_Order) { string sbOld = ""; sbOld += "QueryOrdDetail"; sbOld += merchantId; sbOld += p2_Order; string hmac = Digest.HmacSign(sbOld, keyValue); logstr(p2_Order, sbOld, hmac); string para = ""; para += "?p0_Cmd=QueryOrdDetail"; para += "&p1_MerId=" + merchantId; //加入商家ID para += "&p2_Order=" + p2_Order; //加入购买订单号码 para += "&hmac=" + hmac; //加入校验码 logstr(p2_Order, queryRefundReqURL + para, ""); string reqResult = HttpUtils.SendRequest(queryRefundReqURL, para); //记录查询通讯返回 logstr(p2_Order, reqResult, ""); string r0_Cmd = FormatQueryString.GetQueryString("r0_Cmd", reqResult, '\n'); string r1_Code = FormatQueryString.GetQueryString("r1_Code", reqResult, '\n'); string p1_MerId = FormatQueryString.GetQueryString("p1_MerId", reqResult, '\n'); string r2_TrxId = FormatQueryString.GetQueryString("r2_TrxId", reqResult, '\n'); string r3_Amt = FormatQueryString.GetQueryString("r3_Amt", reqResult, '\n'); string r4_Cur = FormatQueryString.GetQueryString("r4_Cur", reqResult, '\n'); string r5_Pid = FormatQueryString.GetQueryString("r5_Pid", reqResult, '\n'); string r6_Order = FormatQueryString.GetQueryString("r6_Order", reqResult, '\n'); string r8_MP = FormatQueryString.GetQueryString("r8_MP", reqResult, '\n'); string rb_PayStatus = FormatQueryString.GetQueryString("rb_PayStatus", reqResult, '\n'); string rc_RefundCount = FormatQueryString.GetQueryString("rc_RefundCount", reqResult, '\n'); string rd_RefundAmt = FormatQueryString.GetQueryString("rd_RefundAmt", reqResult, '\n'); hmac = FormatQueryString.GetQueryString("hmac", reqResult, '\n'); //查单返回校验hmac sbOld = ""; sbOld += r0_Cmd; sbOld += r1_Code; sbOld += p1_MerId; sbOld += r2_TrxId; sbOld += r3_Amt; sbOld += r4_Cur; sbOld += r5_Pid; sbOld += r6_Order; sbOld += r8_MP; sbOld += rb_PayStatus; sbOld += rc_RefundCount; sbOld += rd_RefundAmt; string nhmac = Digest.HmacSign(sbOld, keyValue); logstr(p2_Order, sbOld, nhmac); if (hmac == nhmac) { BuyQueryOrdDetailResult result = new BuyQueryOrdDetailResult(r0_Cmd, r1_Code, r2_TrxId, r3_Amt, r4_Cur, r5_Pid, r6_Order, r8_MP, rb_PayStatus, rc_RefundCount, rd_RefundAmt, hmac, ""); return(result); } else { BuyQueryOrdDetailResult result = new BuyQueryOrdDetailResult(r0_Cmd, r1_Code, r2_TrxId, r3_Amt, r4_Cur, r5_Pid, r6_Order, r8_MP, rb_PayStatus, rc_RefundCount, rd_RefundAmt, hmac, "交易签名无效"); return(result); } }
/// <summary> /// 退款 /// </summary> /// <param name="p1_MerId">商户编号</param> /// <param name="keyValue">商户密钥</param> /// <param name="pb_TrxId">yeepay流水号</param> /// <param name="p3_Amt">退款金额</param> /// <param name="p4_Cur">币种</param> /// <param name="p5_Desc">退款说明</param> /// <returns></returns> public static BuyRefundOrdResult RefundOrd(string pb_TrxId, string p3_Amt, string p4_Cur, string p5_Desc) { string sbOld = ""; sbOld += "RefundOrd"; sbOld += merchantId; sbOld += pb_TrxId; sbOld += p3_Amt; sbOld += p4_Cur; sbOld += p5_Desc; string hmac = Digest.HmacSign(sbOld, keyValue); logstr(pb_TrxId, sbOld, hmac); string para = ""; para += "?p0_Cmd=RefundOrd"; para += "&p1_MerId=" + merchantId; //加入商家ID para += "&pb_TrxId=" + pb_TrxId; para += "&p3_Amt=" + p3_Amt; //加入购买订单号码 para += "&p4_Cur=" + p4_Cur; para += "&p5_Desc=" + HttpUtility.UrlEncode(p5_Desc, System.Text.Encoding.GetEncoding("gb2312")); para += "&hmac=" + hmac; //加入校验码 logstr(pb_TrxId, queryRefundReqURL + para, ""); string reqResult = HttpUtils.SendRequest(queryRefundReqURL, para); //记录退款通讯返回 logstr(pb_TrxId, reqResult, ""); string r0_Cmd = FormatQueryString.GetQueryString("r0_Cmd", reqResult, '\n'); string r1_Code = FormatQueryString.GetQueryString("r1_Code", reqResult, '\n'); string r2_TrxId = FormatQueryString.GetQueryString("r2_TrxId", reqResult, '\n'); string r3_Amt = FormatQueryString.GetQueryString("r3_Amt", reqResult, '\n'); string r4_Cur = FormatQueryString.GetQueryString("r4_Cur", reqResult, '\n'); hmac = FormatQueryString.GetQueryString("hmac", reqResult, '\n'); //校验返回的hmac sbOld = ""; sbOld += r0_Cmd; sbOld += r1_Code; sbOld += r2_TrxId; sbOld += r3_Amt; sbOld += r4_Cur; string nhmac = Digest.HmacSign(sbOld, keyValue); logstr("退款返回流水号:" + r2_TrxId, sbOld, nhmac); if (hmac == nhmac) { BuyRefundOrdResult result = new BuyRefundOrdResult(r0_Cmd, r1_Code, r2_TrxId, r3_Amt, r4_Cur, hmac, ""); return(result); } else { BuyRefundOrdResult result = new BuyRefundOrdResult(r0_Cmd, r1_Code, r2_TrxId, r3_Amt, r4_Cur, hmac, "交易签名无效"); return(result); } }
public void Return(HttpContext context) { //SZX.logURL(context.Request.RawUrl); // 校验返回数据包 SZXCallbackResult result = SZX.VerifyCallback(SuppKey , FormatQueryString.GetQueryString("r0_Cmd") , FormatQueryString.GetQueryString("r1_Code") , FormatQueryString.GetQueryString("p1_MerId") , FormatQueryString.GetQueryString("p2_Order") , FormatQueryString.GetQueryString("p3_Amt") , FormatQueryString.GetQueryString("p4_FrpId") , FormatQueryString.GetQueryString("p5_CardNo") , FormatQueryString.GetQueryString("p6_confirmAmount") , FormatQueryString.GetQueryString("p7_realAmount") , FormatQueryString.GetQueryString("p8_cardStatus") , FormatQueryString.GetQueryString("p9_MP") , FormatQueryString.GetQueryString("pb_BalanceAmt") , FormatQueryString.GetQueryString("pc_BalanceAct") , FormatQueryString.GetQueryString("hmac")); if (string.IsNullOrEmpty(result.ErrMsg)) { //使用应答机制时 必须回写success string viewMsg = ""; string msg = GetMsgInfo(result.P8_cardStatus); string opstate = "-1"; /*成功还是失败*/ int status = (result.R1_Code == "1") ? 2 : 4; if (status == 2) { opstate = "0"; viewMsg = "支付成功"; } else { viewMsg = msg; } var response = new CardOrderSupplierResponse() { SupplierId = SuppId, SuppTransNo = "", SysOrderNo = result.P2_Order, OrderAmt = decimal.Parse(result.P3_Amt), SuppAmt = 0M, OrderStatus = status, SuppErrorCode = result.P8_cardStatus, Opstate = opstate, SuppErrorMsg = result.ErrMsg, ViewMsg = viewMsg, Method = 1 }; OrderCardUtils.SuppNotify(response, Succflag); } else { context.Response.Write("交易签名无效!"); context.Response.Write("<BR>YeePay-HMAC:" + result.Hmac); context.Response.Write("<BR>LocalHost:" + result.ErrMsg); } }