Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderinfo"></param>
        /// <param name="apiKey"></param>
        /// <returns></returns>
        public static string CreateMultiNotifyUrl(OrderCardTotal orderinfo, string apiKey)
        {
            if (orderinfo == null)
            {
                return(string.Empty);
            }

            string notifyUrl = orderinfo.notifyUrl;

            if (string.IsNullOrEmpty(notifyUrl))
            {
                return(string.Empty);
            }

            decimal facevalue = orderinfo.successAmt;

            bool verifyAmt = orderinfo.filed1 == "true" ? true : false;

            string r0_Cmd = "ChargeCardDirect";

            string r1Code = "0";

            if (orderinfo.status == 2)
            {
                r1Code = "1";
            }

            string p1MerId      = orderinfo.userId.ToString(CultureInfo.InvariantCulture);
            string p2Order      = orderinfo.userorderid;
            string p3Amt        = facevalue.ToString(CultureInfo.InvariantCulture);
            string p4FrpId      = orderinfo.filed1;
            string p5CardNo     = orderinfo.cardNos;//多张卡以半角逗号分隔
            string p7RealAmount = orderinfo.filed3;

            DataSet details = BLL.Order.Card.Factory.Instance.GetlistBybatno(orderinfo.orderid);

            string p6ConfirmAmount = "";
            string p8CardStatus    = "";

            if (details != null)
            {
                foreach (DataRow row in details.Tables[0].Rows)
                {
                    #region
                    int     status     = Convert.ToInt32(row["status"]);
                    decimal realvalue  = Convert.ToDecimal(row["realvalue"]);
                    decimal refervalue = Convert.ToDecimal(row["refervalue"]);

                    if (status == 2)
                    {
                        p6ConfirmAmount += string.Format("{0:f2}", realvalue);
                        if (verifyAmt)
                        {
                            if (realvalue >= refervalue)
                            {
                                p8CardStatus += "0,";
                            }
                            else
                            {
                                p8CardStatus += "1,";
                            }
                        }
                        else
                        {
                            p8CardStatus += "0,";
                        }
                    }
                    else
                    {
                        p6ConfirmAmount += "0,";
                        p8CardStatus    += "1004,";
                    }
                    #endregion
                }
            }

            string p9_MP         = orderinfo.attach;
            string pb_BalanceAmt = "0M";
            string pc_BalanceAct = "";

            string sbOld = "";
            sbOld += r0_Cmd;
            sbOld += r1Code;
            sbOld += p1MerId;
            sbOld += p2Order;
            sbOld += p3Amt;
            sbOld += p4FrpId;
            sbOld += p5CardNo;
            sbOld += p6ConfirmAmount;
            sbOld += p7RealAmount;
            sbOld += p8CardStatus;
            sbOld += p9_MP;
            sbOld += pb_BalanceAmt;
            sbOld += pc_BalanceAct;

            string nhmac = Digest.HmacSign(sbOld, apiKey);

            var parms = new StringBuilder();

            parms.AppendFormat("r0_Cmd={0}", Common.UrlEncode(r0_Cmd));
            parms.AppendFormat("&r1_Code={0}", Common.UrlEncode(r1Code));
            parms.AppendFormat("&p1_MerId={0}", Common.UrlEncode(p1MerId));
            parms.AppendFormat("&p2_Order={0}", Common.UrlEncode(p2Order));
            parms.AppendFormat("&p3_Amt={0}", Common.UrlEncode(p3Amt));
            parms.AppendFormat("&p4_FrpId={0}", Common.UrlEncode(p4FrpId));
            parms.AppendFormat("&p5_CardNo={0}", Common.UrlEncode(p5CardNo));
            parms.AppendFormat("&p6_confirmAmount={0}", Common.UrlEncode(p6ConfirmAmount));
            parms.AppendFormat("&p7_realAmount={0}", Common.UrlEncode(p7RealAmount));
            parms.AppendFormat("&p8_cardStatus={0}", Common.UrlEncode(p8CardStatus));
            parms.AppendFormat("&p9_MP={0}", Common.UrlEncode(p9_MP));
            parms.AppendFormat("&pb_BalanceAmt={0}", Common.UrlEncode(pb_BalanceAmt));
            parms.AppendFormat("&pc_BalanceAct={0}", Common.UrlEncode(pc_BalanceAct));
            parms.AppendFormat("&hmac={0}", Common.UrlEncode(nhmac));

            if (notifyUrl.IndexOf("?", System.StringComparison.Ordinal) > 0)
            {
                notifyUrl = notifyUrl + "&" + parms.ToString();
            }
            else
            {
                notifyUrl = notifyUrl + "?" + parms.ToString();
            }

            return(notifyUrl);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderinfo"></param>
        /// <param name="apiKey"></param>
        /// <returns></returns>
        public static string CreateNotifyUrl(OrderCardInfo orderinfo, string apiKey)
        {
            if (orderinfo == null)
            {
                return(string.Empty);
            }

            string notifyUrl = orderinfo.notifyurl;

            if (string.IsNullOrEmpty(notifyUrl))
            {
                return(string.Empty);
            }

            decimal facevalue = 0M;

            if (orderinfo.realvalue.HasValue)
            {
                facevalue = decimal.Round(orderinfo.realvalue.Value, 0);
            }


            bool   verifyAmt = orderinfo.cus_field4 == "true" ? true : false;
            string r0_Cmd    = "ChargeCardDirect";

            string r1Code = "0";

            if (orderinfo.status == 2)
            {
                r1Code = "1";
            }

            string p1MerId = orderinfo.userid.ToString(CultureInfo.InvariantCulture);
            string p2Order = orderinfo.userorder;
            string p3Amt   = facevalue.ToString(CultureInfo.InvariantCulture);

            string p4FrpId  = orderinfo.cus_field2;
            string p5CardNo = orderinfo.cardNo;                                        //多张卡以半角逗号分隔

            string p6ConfirmAmount = facevalue.ToString(CultureInfo.InvariantCulture); //卡支付的金额组
            string p7RealAmount    = orderinfo.cus_field3;                             //卡原有的金额组

            string p8CardStatus = "1006";                                              //p8_cardStatus//状态组

            if (orderinfo.status == 2)
            {
                p8CardStatus = "0";
            }

            if (verifyAmt && p8CardStatus == "0")
            {
                if (orderinfo.refervalue > facevalue)
                {
                    p8CardStatus = "1";
                    r1Code       = "2";
                    p3Amt        = "0";
                }
                else if (orderinfo.refervalue <= facevalue)
                {
                    p3Amt = orderinfo.refervalue.ToString("f2");
                }
            }


            string p9_MP         = orderinfo.attach;
            string pb_BalanceAmt = "0M";
            string pc_BalanceAct = "";

            string sbOld = "";

            sbOld += r0_Cmd;
            sbOld += r1Code;
            sbOld += p1MerId;
            sbOld += p2Order;
            sbOld += p3Amt;
            sbOld += p4FrpId;
            sbOld += p5CardNo;
            sbOld += p6ConfirmAmount;
            sbOld += p7RealAmount;
            sbOld += p8CardStatus;
            sbOld += p9_MP;
            sbOld += pb_BalanceAmt;
            sbOld += pc_BalanceAct;

            string nhmac = Digest.HmacSign(sbOld, apiKey);

            var parms = new StringBuilder();

            parms.AppendFormat("r0_Cmd={0}", Common.UrlEncode(r0_Cmd));
            parms.AppendFormat("&r1_Code={0}", Common.UrlEncode(r1Code));
            parms.AppendFormat("&p1_MerId={0}", Common.UrlEncode(p1MerId));
            parms.AppendFormat("&p2_Order={0}", Common.UrlEncode(p2Order));
            parms.AppendFormat("&p3_Amt={0}", Common.UrlEncode(p3Amt));
            parms.AppendFormat("&p4_FrpId={0}", Common.UrlEncode(p4FrpId));
            parms.AppendFormat("&p5_CardNo={0}", Common.UrlEncode(p5CardNo));
            parms.AppendFormat("&p6_confirmAmount={0}", Common.UrlEncode(p6ConfirmAmount));
            parms.AppendFormat("&p7_realAmount={0}", Common.UrlEncode(p7RealAmount));
            parms.AppendFormat("&p8_cardStatus={0}", Common.UrlEncode(p8CardStatus));
            parms.AppendFormat("&p9_MP={0}", Common.UrlEncode(p9_MP));
            parms.AppendFormat("&pb_BalanceAmt={0}", Common.UrlEncode(pb_BalanceAmt));
            parms.AppendFormat("&pc_BalanceAct={0}", Common.UrlEncode(pc_BalanceAct));
            parms.AppendFormat("&hmac={0}", Common.UrlEncode(nhmac));

            if (notifyUrl.IndexOf("?", System.StringComparison.Ordinal) > 0)
            {
                notifyUrl = notifyUrl + "&" + parms.ToString();
            }
            else
            {
                notifyUrl = notifyUrl + "?" + parms.ToString();
            }

            return(notifyUrl);
        }