Ejemplo n.º 1
0
        public string ValidateCustomerAndEPIN(string acctNoOrMeterNo, string amt, string dealerName, string password, string mtid, string businessUnit = "")
        {
            ClsDealer dl   = new ClsDealer();
            Guid      guid = Guid.NewGuid();

            string tDate        = DateTime.Today.ToString("yyMMdd").Replace("/", "");
            string paymentType  = new PaymentType().GetPaymentType(acctNoOrMeterNo);
            string channelRefNo = (paymentType == "PREPAID" ? "MT" : "MB") + tDate + dl.GetDealerCode(dealerName).ToString() + "_" + guid.ToString();

            if (RequestIsValid(dealerName, password))
            {
                string reqParams = "acctNoOrMeterNo:" + acctNoOrMeterNo + "|" +
                                   "amt:" + amt + "|" +
                                   "dealerName:" + dealerName + "|" +
                                   "businessUnit:" + businessUnit
                ;


                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid + "|REQ", "ValidateCustomerAndEPIN", reqParams, channelRefNo);

                mtid += "|RESP";

                string customerName = "", address = "", fixedCharge = "";

                string dcode = new ClsDealer().GetDealerCode(dealerName).ToString();

                //log progress -- channelRefNo
                ClsCards cls = new ClsCards();
                //cls.RunNonQuery("insert into LogPaymentAction(channelRefNo) values('" + channelRefNo + "')");

                string getVars = acctNoOrMeterNo.Length == 11
                ? "vendAmount=" + amt + "&meterNo=" + acctNoOrMeterNo + "&paymentChannel=" + dcode
                : "meterNumber=" + (acctNoOrMeterNo.Length == 12 ? "PP" : "") + acctNoOrMeterNo + "&paymentChannel=" + dcode;

                WSCall wsc = new WSCall();

                //RealImplementation
                string returnString = "";

                if (acctNoOrMeterNo != "0000000000")
                {
                    returnString = wsc.GetJSON(String.Format(acctNoOrMeterNo.Length == 11 ? "/TrialCreditVend{0}" : "/confirmcustomer{0}", "?" + Misc.GetClientId + "&" + getVars + "&channelRefNo=" + channelRefNo));
                }
                else
                {
                    //returnString = "1|||||||";

                    string returnString33 = "1|customerName_address_fixedCharge_conlogTID_warningNsg_flag" + (mtid.IndexOf("|") != -1 ? "_channelRefNo" : "") + "||||||0|" + (mtid.IndexOf("|") != -1 ? "|" + channelRefNo : "");
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString33 + "|" + amt, channelRefNo);

                    return(returnString33);
                }
                //string returnString = wsc.GetJSON(String.Format("/confirmcustomer{0}", getVars)/*, new ClsDealer().GetDealerCode(dealerName).ToString()*/);

                //startTest
                //string returnString = "1|TransactionId_CustomerName_CustomerAddress_CustomerphoneNumber_CustomerAccountNumer_MinimunVendingAmount_Units|20170511115559~1000011|PAWAKAD1, TS|||04040406714|70.00|25.5";
                //endTest

                string warning = "", flag = "0";
                if (acctNoOrMeterNo != "")
                {
                    string[] lastPayment = dl.GetLastPayment(acctNoOrMeterNo, new ClsDealer().GetDealerCode(dealerName).ToString()).Split('_');

                    if (!lastPayment[0].ToString().Equals("") && !lastPayment[1].ToString().Equals("")) // lastPayment returnString ""
                    {
                        warning = "You have made a payment of N" + lastPayment[1] + " for this customer today at " + lastPayment[0].Substring(0, 8) + ".######Are you sure you want to proceed?###### Request for reversal may not be honoured.###";
                        flag    = "1";
                    }
                }

                //this IF is necessary for new meter nums that fails on first vend by returning 'Amount is insufficient' error
                //when a value lesser than the required amount is paid, or null when the required amount or more is paid
                if (returnString == null || returnString == "")
                {
                    returnString = wsc.GetJSON(String.Format("/confirmcustomer{0}", "?" + Misc.GetClientId + "&" + "meterNumber=" + acctNoOrMeterNo + "&paymentChannel=" + dcode + "&channelRefNo=" + channelRefNo));
                }

                if (returnString == null || returnString == "")
                {
                    returnString = "0|Unable to get customer details";
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString + "|" + amt, channelRefNo);

                    return(returnString);
                }

                string[] tokens = returnString.Split('|');

                if (tokens[0] == "1")
                {
                    customerName = tokens[3];
                    address      = tokens[4];
                    fixedCharge  = tokens[7];
                }
                else
                {
                    string returnString2 = "0|" + tokens[1];
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString2 + "|" + amt, channelRefNo);

                    return(returnString2);
                }

                string returnString3 = "1|customerName_address_fixedCharge_conlogTID_warningNsg_flag" + (mtid.IndexOf("|") != -1 ? "_channelRefNo" : "") + "|" + customerName + "|" + address + "|" + fixedCharge + "|" + tokens[2] + "|" + warning + "|" + flag + (mtid.IndexOf("|") != -1 ? "|" + channelRefNo : "");
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString3 + "|" + amt, channelRefNo);

                return(returnString3);
            }
            else
            {
                string returnString = "0|Invalid Request";
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString + "|" + amt, channelRefNo);

                return(returnString);
            }
        }