Beispiel #1
0
        public static void InsertLogInquiryCC(CreditCardModels.CreditCardInquiryRequest InqRequest, CreditCardModels.CreditCardInquiryRespone InqResponse, CreditCardModels.PSWRequest pswReq, CreditCardModels.PSWServiceInqResponse pswRes, string wsStartTime, string wsEndTime, string ip)
        {
            Util   util = new Util();
            string name;
            string minimum_pay;
            string billing;
            string maturity_date;

            if (pswRes.Data1 != null && pswRes.Data1 != "")
            {
                string   pswresData = pswRes.Data1.Replace("||", "~");
                string[] data       = pswresData.Split('~');
                name          = data[0];
                billing       = data[1].Substring(0, 1) + data[1].Substring(1).TrimStart('0');
                minimum_pay   = data[2].TrimStart('0');
                maturity_date = data[3];
            }
            else
            {
                name          = "-";
                billing       = "-";
                minimum_pay   = "-";
                maturity_date = "-";
            }
            string errMsg = "";

            string sql = "INSERT INTO CCINQUIRYLOG ([CREATEDTIME],[WS_STARTTIME],[WS_ENDTIME],[ACTION],[INSTITUTION_CODE],[CHANNEL_ID],[PRODUCT_ID]," +
                         "[SUB_PRODUCT],[SEQUENCE_TRX],[CC_NUM],[KEY],[NAME],[BANK],[BILLING],[MINIMUM_PAYMENT],[MATURITY_DATE],[RC],[RC_DESC],[ERRMSG],[IP_ADDRESS]) " +
                         "VALUES (@createdTime, @wsStartTime, @wsEndTime, @action, @institutionCode, @channelId, @productId, @subProduct, @sequenceTrx, @ccNumber, " +
                         "@key, @name, @bank, @billing, @minimumPayment, @maturityDate, @rc, @rcDesc, @errmsg, @ip)";


            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = sql;
            sqlCommand.Parameters.Add("@createdTime", SqlDbType.VarChar).Value     = DateTime.Now.ToString(ConstantModels.FORMATDATETIME);
            sqlCommand.Parameters.Add("@wsStartTime", SqlDbType.VarChar).Value     = wsStartTime;
            sqlCommand.Parameters.Add("@wsEndTime", SqlDbType.VarChar).Value       = wsEndTime;
            sqlCommand.Parameters.Add("@action", SqlDbType.VarChar).Value          = "INQUIRY_CC";
            sqlCommand.Parameters.Add("@institutionCode", SqlDbType.VarChar).Value = InqRequest.instiutionCode;
            sqlCommand.Parameters.Add("@channelId", SqlDbType.VarChar).Value       = pswReq.ChannelID;
            sqlCommand.Parameters.Add("@productId", SqlDbType.VarChar).Value       = pswReq.ProductID;
            sqlCommand.Parameters.Add("@subProduct", SqlDbType.VarChar).Value      = pswReq.SubProduct;
            sqlCommand.Parameters.Add("@sequenceTrx", SqlDbType.VarChar).Value     = pswReq.SequenceTrx;
            sqlCommand.Parameters.Add("@ccNumber", SqlDbType.VarChar).Value        = pswReq.InputData;
            sqlCommand.Parameters.Add("@key", SqlDbType.VarChar).Value             = pswReq.Key;
            sqlCommand.Parameters.Add("@name", SqlDbType.VarChar).Value            = name;
            sqlCommand.Parameters.Add("@bank", SqlDbType.VarChar).Value            = "BRI";
            sqlCommand.Parameters.Add("@billing", SqlDbType.VarChar).Value         = billing;
            sqlCommand.Parameters.Add("@minimumPayment", SqlDbType.VarChar).Value  = minimum_pay;
            sqlCommand.Parameters.Add("@maturityDate", SqlDbType.VarChar).Value    = maturity_date;
            sqlCommand.Parameters.Add("@rc", SqlDbType.VarChar).Value     = InqResponse.responseCode;
            sqlCommand.Parameters.Add("@rcDesc", SqlDbType.VarChar).Value = InqResponse.responseDescription;
            sqlCommand.Parameters.Add("@errmsg", SqlDbType.VarChar).Value = errMsg;
            sqlCommand.Parameters.Add("@ip", SqlDbType.VarChar).Value     = ip;
            util.ExecuteSqlCommand(sqlCommand);
        }
Beispiel #2
0
        public static CreditCardModels.CreditCardInquiryRespone InquiryCC(ref CreditCardModels.CreditCardInquiryRequest requestInq, string featureCode)
        {
            string url      = ConstantModels.URLINQPAY;
            string bankName = "";
            string bankCode = "";

            CreditCardModels.PSWRequest pswReq = new CreditCardModels.PSWRequest();
            CreditCardModels.CreditCardInquiryRespone     responseInq = new CreditCardModels.CreditCardInquiryRespone();
            CreditCardModels.PSWServiceInqResponse        pswRes      = new CreditCardModels.PSWServiceInqResponse();
            CreditCardModels.PSWServiceInqCCOtherResponse pswResOther = new CreditCardModels.PSWServiceInqCCOtherResponse();
            DataTable dt = new DataTable();

            dt = GetBinMap(requestInq.cardNumber.Substring(0, 6));
            if (dt != null)
            {
                bankCode = dt.Rows[0]["BANK_CODE"].ToString();
                bankName = dt.Rows[0]["BANK_NAME"].ToString();
            }
            switch (bankCode.PadLeft(3, '0'))
            {
            case "002":
                pswReq.Key        = ConstantModels.Key_CCBRI;
                pswReq.ProductID  = ConstantModels.ProductID_CCBRI;
                pswReq.SubProduct = ConstantModels.SubProductINQ;
                break;

            default:
                pswReq.Key        = ConstantModels.Key_CCBRI;
                pswReq.ProductID  = ConstantModels.ProductID_CCOTHER;
                pswReq.SubProduct = ConstantModels.SubProductINQOther;
                break;
            }


            pswReq.InputData = requestInq.cardNumber;
            Random rand = new Random();

            pswReq.SequenceTrx = DateTime.Now.ToString("HHmmssfff") + rand.Next(0, 9).ToString(); //harusnya get ke DB


            string _requestInq = "data=" + "[" + JsonConvert.SerializeObject(pswReq) + "]";


            ASCIIEncoding ascii = new ASCIIEncoding();

            byte[]         postBytes = ascii.GetBytes(_requestInq);
            HttpWebRequest request;

            try
            {
                request = (HttpWebRequest)HttpWebRequest.Create(url);
            }
            catch (UriFormatException)
            {
                return(null);
            }

            request.Method        = "POST";
            request.Accept        = "application/x-www-form-urlencoded";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = postBytes.Length;
            System.Net.ServicePointManager.Expect100Continue = false;

            //WebProxy proxy = new WebProxy("172.18.104.20", 1707);
            //request.Proxy = proxy;

            string wsStartTime = DateTime.Now.ToString();
            // add post data to request
            Stream postStream = request.GetRequestStream();

            postStream.Write(postBytes, 0, postBytes.Length);
            postStream.Flush();
            postStream.Close();
            if (bankCode == "002")
            {
                try
                {
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Stream       answerStream = response.GetResponseStream();
                        StreamReader answerReader = new StreamReader(answerStream);
                        String       jsonAnswer   = answerReader.ReadToEnd();
                        pswRes = JsonConvert.DeserializeObject <CreditCardModels.PSWServiceInqResponse>(jsonAnswer);
                        responseInq.responseCode        = pswRes.RC;
                        responseInq.responseDescription = pswRes.Description;
                        if (pswRes.RC == "00")
                        {
                            responseInq.responseCode        = "0100";
                            responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                            //responseInq.errorDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);

                            string   pswresData = pswRes.Data1.Replace("||", "~");
                            string[] data       = pswresData.Split('~');
                            responseInq.data.cardName       = data[0];
                            responseInq.data.bankName       = "BRI";
                            responseInq.data.billingAmount  = data[1].Substring(0, 1) + data[1].Substring(1).TrimStart('0');
                            responseInq.data.minimumPayment = data[2].TrimStart('0');
                            responseInq.data.maturityDate   = data[3];
                            responseInq.data.dataKey        = Base64Encode(pswRes.Data1);
                        }
                        else
                        {
                            responseInq.responseCode        = ResponseCodeModels.GetResponseCodePSW(pswRes.RC);
                            responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                        }
                    }
                    else
                    {
                        responseInq.responseCode        = "0102";
                        responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                    }
                }
                catch (Exception ex)
                {
                    responseInq.responseCode        = "81";
                    responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                }
                string wsEndTime = DateTime.Now.ToString();
                InsertLogInquiryCC(requestInq, responseInq, pswReq, pswRes, wsEndTime, wsStartTime, System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString());
                return(responseInq);
            }
            #region ccotherbank
            else //otherbank, fikri
            {
                try
                {
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Stream       answerStream = response.GetResponseStream();
                        StreamReader answerReader = new StreamReader(answerStream);
                        String       jsonAnswer   = answerReader.ReadToEnd();
                        pswResOther = JsonConvert.DeserializeObject <CreditCardModels.PSWServiceInqCCOtherResponse>(jsonAnswer);
                        responseInq.responseCode        = pswResOther.RC;
                        responseInq.responseDescription = pswResOther.Description;
                        if (pswResOther.RC == "00")
                        {
                            responseInq.responseCode        = "0100";
                            responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                            //responseInq.errorDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);

                            responseInq.data.cardName = pswResOther.NamaNasabah;
                            responseInq.data.bankName = pswResOther.NamaBank;
                            try
                            {
                                string   pswresData = pswResOther.OtherData.Replace("||", "~");
                                string[] data       = pswresData.Split('~');
                                responseInq.data.billingAmount  = (data[4] == "C"? "+" : "-") + data[5].TrimStart('0');
                                responseInq.data.minimumPayment = data[6].TrimStart('0');
                                responseInq.data.maturityDate   = data[7];
                                responseInq.data.dataKey        = Base64Encode(pswResOther.OtherData);
                            }
                            catch
                            {
                                responseInq.data.billingAmount = responseInq.data.minimumPayment = responseInq.data.maturityDate = "";
                                responseInq.data.dataKey       = Base64Encode(pswResOther.OtherData);
                            }
                        }
                        else
                        {
                            responseInq.responseCode        = ResponseCodeModels.GetResponseCodePSW(pswResOther.RC);
                            responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                        }
                    }
                    else
                    {
                        responseInq.responseCode        = "0102";
                        responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                    }
                }
                catch (Exception ex)
                {
                    responseInq.responseCode        = "81";
                    responseInq.responseDescription = ResponseCodeModels.GetResponseDescription(responseInq.responseCode);
                }
                string wsEndTime = DateTime.Now.ToString();
                InsertLogInquiryCCOther(requestInq, responseInq, pswReq, pswResOther, wsEndTime, wsStartTime, System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString());
                return(responseInq);
            }
            #endregion
        }