public TelkomModels.TelkomPaymentResponse PaymentTelkom(ref TelkomModels.TelkomPaymentRequest AutoPayRequest, string ip) { string wsStartTime = DateTime.Now.ToString(ConstantModels.FORMATDATETIME); string wsEndTime = ""; TelkomHelper telkomHelper = new TelkomHelper(); TelkomModels.PSWServiceRequest PswRequest = new TelkomModels.PSWServiceRequest(); TelkomModels.TelkomPaymentResponse AutoPayResponse = new TelkomModels.TelkomPaymentResponse(); TelkomModels.PSWServicePaymentResponse GetPayResponse = new TelkomModels.PSWServicePaymentResponse(); string decodeBillingCode = helper.Base64Decode(AutoPayRequest.billingCode); if (decodeBillingCode == "") { AutoPayResponse.responseCode = "0210"; AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(AutoPayResponse.responseCode); } else { string[] splitBillingCode = decodeBillingCode.Split('~'); string[] splitData1PSW = ((splitBillingCode[0]).Replace("||", "~")).Split('~'); Random random = new Random(); PswRequest.SubProduct = ConstantModels.SubProductPAY_Telkom; PswRequest.SequenceTrx = DateTime.Now.ToString("HHmmssfff") + random.Next(0, 9).ToString(); PswRequest.TotalAmount = AutoPayRequest.totalAmount; PswRequest.AddAmount1 = splitData1PSW[1]; PswRequest.AddAmount2 = splitData1PSW[2]; PswRequest.AddAmount3 = splitData1PSW[3]; PswRequest.InputData = AutoPayRequest.billingNumber; PswRequest.Data1 = helper.GetSourceAccount(AutoPayRequest.institutionCode, ConstantModels.FeatureCode_Telkom); PswRequest.Data2 = splitData1PSW[0]; PswRequest.Data3 = splitBillingCode[1]; GetPayResponse = PSWServicePaymentTelkom(ref PswRequest); wsEndTime = DateTime.Now.ToString(ConstantModels.FORMATDATETIME); if (GetPayResponse == null) { AutoPayResponse.responseCode = ConstantModels.TIMEOUTCODEPAY; AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.TIMEOUTCODEPAY); } else if (GetPayResponse.RC == "00") //success { AutoPayResponse.responseCode = ConstantModels.SUCCESSCODEPAY; AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.SUCCESSCODEPAY); AutoPayResponse.data.billingNumber = AutoPayRequest.billingNumber; AutoPayResponse.data.reference = AutoPayRequest.reference; AutoPayResponse.data.journalSeq = GetPayResponse.JurnalSeq.Trim(); } else if (GetPayResponse.RC == ConstantModels.TIMEOUTCODEPAY) //timeout { AutoPayResponse.responseCode = ConstantModels.TIMEOUTCODEPAY; AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetPayResponse.RC); } else if (GetPayResponse.RC == ConstantModels.EXCEPTIONCODEPAY) //exception { AutoPayResponse.responseCode = ConstantModels.EXCEPTIONCODEPAY; AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetPayResponse.RC); } else //fail { AutoPayResponse.responseCode = ResponseCodeModels.GetResponseCodePSW(GetPayResponse.RC); AutoPayResponse.responseDescription = ResponseCodeModels.GetResponseDescription(AutoPayResponse.responseCode); //kondisi suspend kredit dari psw if (GetPayResponse.RC == "Q4" || GetPayResponse.RC == "68" || GetPayResponse.RC == "82") { AutoPayResponse.data.billingNumber = AutoPayRequest.billingNumber; AutoPayResponse.data.reference = AutoPayRequest.reference; AutoPayResponse.data.journalSeq = GetPayResponse.JurnalSeq.Trim(); } } } //insert ke tabel TELKOMTRANSACTION telkomHelper.InsertTelkomTransaction(AutoPayRequest, PswRequest, AutoPayResponse, wsStartTime, wsEndTime, ip, (GetPayResponse == null ? "" : GetPayResponse.RC)); return(AutoPayResponse); }
public TelkomModels.TelkomInquiryResponse InquiryTelkom(ref TelkomModels.TelkomInquiryRequest AutoInqRequest, string ip) { string wsStartTime = DateTime.Now.ToString(ConstantModels.FORMATDATETIME); TelkomHelper telkomHelper = new TelkomHelper(); TelkomModels.PSWServiceRequest PswRequest = new TelkomModels.PSWServiceRequest(); TelkomModels.TelkomInquiryResponse AutoInqResponse = new TelkomModels.TelkomInquiryResponse(); TelkomModels.PSWServiceInquiryResponse GetInqResponse = new TelkomModels.PSWServiceInquiryResponse(); Random random = new Random(); PswRequest.SubProduct = ConstantModels.SubProductINQ_Telkom; PswRequest.SequenceTrx = DateTime.Now.ToString("HHmmssfff") + random.Next(0, 9).ToString(); PswRequest.InputData = AutoInqRequest.billingNumber; PswRequest.Data1 = helper.GetSourceAccount(AutoInqRequest.institutionCode, ConstantModels.FeatureCode_Telkom); GetInqResponse = PSWServiceInquiryTelkom(ref PswRequest); if (GetInqResponse == null) { AutoInqResponse.responseCode = ConstantModels.TIMEOUTCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.TIMEOUTCODEINQ); } else if (GetInqResponse.RC == "00") //success { double totalAmount = 0; List <TelkomModels.TelkomBillingDetailsData> billDetail = new List <TelkomModels.TelkomBillingDetailsData>(); string[] splitData1 = ((GetInqResponse.Data1).Replace("||", "~")).Split('~'); int countData1 = splitData1.Length - 1; AutoInqResponse.responseCode = ConstantModels.SUCCESSCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(ConstantModels.SUCCESSCODEINQ); AutoInqResponse.data.name = splitData1[0].ToString().Trim(); AutoInqResponse.data.billingCode = helper.Base64Encode(GetInqResponse.Data1 + "~" + GetInqResponse.Data2); for (int i = 1; i <= countData1; i++) { string[] splitBillDetail = splitData1[i].Split('#'); totalAmount += Convert.ToDouble(String.IsNullOrEmpty(splitBillDetail[1].ToString()) ? "0" : splitBillDetail[1].ToString()); TelkomModels.TelkomBillingDetailsData listBillDetail = new TelkomModels.TelkomBillingDetailsData(); if (!String.IsNullOrEmpty(splitBillDetail[0].ToString()) || !String.IsNullOrEmpty(splitBillDetail[1].ToString())) { listBillDetail.referenceNumber = splitBillDetail[0].ToString(); listBillDetail.amount = splitBillDetail[1].ToString(); billDetail.Add(listBillDetail); } } AutoInqResponse.data.totalAmount = (totalAmount.ToString() == "0" ? null : totalAmount.ToString()); AutoInqResponse.data.billingDetail = billDetail; } else if (GetInqResponse.RC == ConstantModels.TIMEOUTCODEINQ) { AutoInqResponse.responseCode = ConstantModels.TIMEOUTCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetInqResponse.RC); } else if (GetInqResponse.RC == ConstantModels.EXCEPTIONCODEINQ) { AutoInqResponse.responseCode = ConstantModels.EXCEPTIONCODEINQ; AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(GetInqResponse.RC); } else //fail { AutoInqResponse.responseCode = ResponseCodeModels.GetResponseCodePSW(GetInqResponse.RC); AutoInqResponse.responseDescription = ResponseCodeModels.GetResponseDescription(AutoInqResponse.responseCode); } string wsEndTime = DateTime.Now.ToString(ConstantModels.FORMATDATETIME); telkomHelper.InsertLogInquiryTelkom(AutoInqRequest, PswRequest, AutoInqResponse, wsStartTime, wsEndTime, ip, (GetInqResponse == null ? "" : GetInqResponse.RC)); return(AutoInqResponse); }
public static CreditCardModels.CreditCardPaymentRespone PaymentCC(ref CreditCardModels.CreditCardPaymentRequest requestPay, string featureCode) { string url = ConstantModels.URLINQPAY; string bankCode = ""; string bankName = ""; CreditCardModels.PSWRequest pswReq = new CreditCardModels.PSWRequest(); CreditCardModels.CreditCardPaymentRespone responsePay = new CreditCardModels.CreditCardPaymentRespone(); CreditCardModels.PSWServicePayResponse pswRes = new CreditCardModels.PSWServicePayResponse(); DataTable dt = new DataTable(); dt = GetBinMap(requestPay.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.SubProductPAY; pswReq.Data2 = requestPay.cardName; break; default: pswReq.Key = ConstantModels.Key_CCBRI; pswReq.ProductID = ConstantModels.ProductID_CCOTHER; pswReq.SubProduct = ConstantModels.SubProductPAYOther; pswReq.Data2 = requestPay.cardName; try { pswReq.Data2 = Base64Decode(requestPay.dataKey); } catch { responsePay.responseCode = "0112"; responsePay.responseDescription = ResponseCodeModels.GetResponseDescription(responsePay.responseCode); return(responsePay); } break; } pswReq.InputData = requestPay.cardNumber; Random rand = new Random(); pswReq.SequenceTrx = DateTime.Now.ToString("HHmmssfff") + rand.Next(0, 9).ToString(); //harusnya get ke DB pswReq.TotalAmount = requestPay.amount; pswReq.Data1 = GetSourceAccount(requestPay.instiutionCode, featureCode); //helper.getrekdb(); 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; // add post data to request Stream postStream = request.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Flush(); postStream.Close(); string wsStartTime = DateTime.Now.ToString(); 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.PSWServicePayResponse>(jsonAnswer); if (pswRes.RC == "00") { responsePay.data.cardNumber = requestPay.cardNumber; responsePay.data.reference = requestPay.reference; responsePay.data.journalSeq = pswRes.JurnalSeq; responsePay.responseCode = "0200"; responsePay.responseDescription = ResponseCodeModels.GetResponseDescription(responsePay.responseCode); } else { responsePay.responseCode = ResponseCodeModels.GetResponseCodePSW(pswRes.RC); responsePay.responseDescription = ResponseCodeModels.GetResponseDescription(responsePay.responseCode); } // responsePay.data.Data2 = respond.Data2; } else { responsePay.responseCode = "0202"; responsePay.responseDescription = ResponseCodeModels.GetResponseDescription(responsePay.responseCode); } } catch (Exception ex) { responsePay.responseCode = "81"; responsePay.responseDescription = ResponseCodeModels.GetResponseDescription(responsePay.responseCode); } string wsEndTime = DateTime.Now.ToString(); InsertTransactionCC(requestPay, responsePay, pswReq, pswRes, wsStartTime, wsEndTime, System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(), bankName); return(responsePay); }
public CredentialModels(string _responseCode) { responseCode = _responseCode; responseDescription = ResponseCodeModels.GetResponseDescription(_responseCode); }
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 }