public static string ValidatePaymentCC(ref CreditCardModels.CreditCardPaymentRequest PayRequest, string feature)
        {
            Boolean ceknoref = CreditCardHelper.CheckReferenceCreditCard(PayRequest.reference, PayRequest.instiutionCode);
            decimal number;
            string  rc     = "";
            Helper  helper = new Helper();

            if (!helper.FeatureCheck(PayRequest.instiutionCode, feature))
            {
                rc = "0011";
            }
            else if (!ceknoref)
            {
                if (String.IsNullOrEmpty(helper.GetSourceAccount(PayRequest.instiutionCode, ConstantModels.FeatureCode_CC)))
                {
                    rc = "0111";
                }
                else if (String.IsNullOrEmpty(PayRequest.cardNumber))
                {
                    rc = "0110"; //Card number tidak boleh kosong
                }
                else if (!decimal.TryParse(PayRequest.cardNumber, out number))
                {
                    rc = "0104";
                }
                else if (String.IsNullOrEmpty(PayRequest.amount))
                {
                    rc = "0105"; //Total amount tidak boleh kosong
                }
                else if (String.IsNullOrEmpty(PayRequest.cardName))
                {
                    rc = "0106"; //Name tidak boleh kosong
                }
                else if (String.IsNullOrEmpty(PayRequest.reference))
                {
                    rc = "0014"; //Reference tidak boleh kosong
                }
                else if (!decimal.TryParse(PayRequest.amount.Replace(",", ""), out number))
                {
                    rc = "0108"; //Total amount mengandung karakter bukan angka
                }
                else if (System.Convert.ToDouble(PayRequest.amount.Replace(",", "")) < 1)
                {
                    rc = "0109"; //Total amount tidak boleh 0 atau bernilai negatif
                }
                else
                {
                    rc = "0005"; //Success
                }
            }
            else
            {
                rc = "0013"; //Reference sudah pernah digunakan
            }

            return(rc);
        }
예제 #2
0
        public static void InsertTransactionCC(CreditCardModels.CreditCardPaymentRequest PayRequest, CreditCardModels.CreditCardPaymentRespone PayResponse, CreditCardModels.PSWRequest pswReq, CreditCardModels.PSWServicePayResponse pswRes, string wsStartTime, string wsEndTime, string ip, string bankName)
        {
            Util util = new Util();

            string errMsg = "";


            string sql = "INSERT INTO CCTRANSACTION ([CREATEDTIME],[WS_STARTTIME],[WS_ENDTIME],[INSTITUTION_CODE],[CC_TYPE],[SEQUENCE_TRX],[TOTAL_AMOUNT]," +
                         "[CARD_NUMBER],[NAMA],[BANK],[TRANSACTION_DATE],[TRANSACTION_TIME],[RC],[RC_DESC],[ERRMSG],[JURNALSEQ],[IP_ADDRESS],[NOMOR_REFF])" +
                         "VALUES (@createdTime, @wsStartTime, @wsEndTime, @institutionCode, @ccType, @sequenceTrx, @totalAmount," +
                         "@cardNumber, @nama, @bank, @transactionDate, @transactionTime, @rc, @rcDesc, @errmsg, @jurnalSeq, @ip, @nomorReff)";

            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("@institutionCode", SqlDbType.VarChar).Value = PayRequest.instiutionCode;
            sqlCommand.Parameters.Add("@ccType", SqlDbType.VarChar).Value          = pswReq.ProductID;
            sqlCommand.Parameters.Add("@sequenceTrx", SqlDbType.VarChar).Value     = pswReq.SequenceTrx;
            sqlCommand.Parameters.Add("@totalAmount", SqlDbType.Decimal).Value     = Convert.ToDecimal(PayRequest.amount);
            sqlCommand.Parameters.Add("@cardNumber", SqlDbType.VarChar).Value      = PayRequest.cardNumber;
            sqlCommand.Parameters.Add("@nama", SqlDbType.VarChar).Value            = PayRequest.cardName;
            sqlCommand.Parameters.Add("@bank", SqlDbType.VarChar).Value            = bankName;
            sqlCommand.Parameters.Add("@transactionDate", SqlDbType.VarChar).Value = DateTime.Now.ToShortDateString();
            sqlCommand.Parameters.Add("@transactionTime", SqlDbType.VarChar).Value = DateTime.Now.ToShortTimeString();
            sqlCommand.Parameters.Add("@rc", SqlDbType.VarChar).Value        = PayResponse.responseCode;
            sqlCommand.Parameters.Add("@rcDesc", SqlDbType.VarChar).Value    = PayResponse.responseDescription;
            sqlCommand.Parameters.Add("@errmsg", SqlDbType.VarChar).Value    = errMsg;
            sqlCommand.Parameters.Add("@jurnalSeq", SqlDbType.VarChar).Value = pswRes.JurnalSeq;
            sqlCommand.Parameters.Add("@ip", SqlDbType.VarChar).Value        = ip;
            sqlCommand.Parameters.Add("@nomorReff", SqlDbType.VarChar).Value = PayRequest.reference;
            util.ExecuteSqlCommand(sqlCommand);
        }
예제 #3
0
        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);
        }