Esempio n. 1
0
File: Buy.cs Progetto: kevin4044/ssc
        /// <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;
            }
        }
Esempio n. 2
0
File: Buy.cs Progetto: nuet/wwwroot
        /// <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);
            }
        }