コード例 #1
0
        public string PullKCCADetails(string PRN)
        {
            string result = "";

            try
            {
                string HashKey = MD5Hash(KCCASession_key + KCCAVendorCode + KCCAVendorPassword + KCCAHash);
                KCCAGateway.BankPaymentService x = new KCCAGateway.BankPaymentService();

                // ----------------------- Get Session Key --------------------------
                var Sessionkey = new object();
                try
                {
                    Sessionkey = x.authenticate(KCCASession_key, KCCAVendorCode, KCCAVendorPassword, HashKey, "");
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
                string skey = "";
                //DataRow rw = null;
                DataSet      ds     = new DataSet();
                DataTable    dt     = new DataTable();
                StringReader strRdr = new StringReader(Sessionkey.ToString());
                try
                {
                    ds.ReadXml(strRdr);
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
                dt   = ds.Tables[0];
                skey = dt.Rows[0][1].ToString();


                // ------------------- Validate against prn --------------------------
                string validateresponse = "";
                try
                {
                    validateresponse = x.verifyReference(skey, PRN, "", "");
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
                dt     = new DataTable();
                ds     = new DataSet();
                strRdr = new StringReader(validateresponse);
                try
                {
                    ds.ReadXml(strRdr);
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
                dt = ds.Tables[0];

                // ---------------------- Return Xml Response -------------------------
                string        PaymentDetails = "";
                MemoryStream  XmlMs          = new MemoryStream();
                XmlTextWriter XmlTxtWtr      = new XmlTextWriter(XmlMs, System.Text.Encoding.UTF8);
                XmlTxtWtr.Formatting  = Formatting.Indented;
                XmlTxtWtr.Indentation = 4;
                XmlTxtWtr.WriteStartDocument();
                XmlTxtWtr.WriteStartElement("KCCA PAYMENT DETAILS");
                XmlTxtWtr.WriteElementString("PRN", dt.Rows[0][4].ToString());
                XmlTxtWtr.WriteElementString("COIN", dt.Rows[0][1].ToString());
                XmlTxtWtr.WriteElementString("CUSTNAME", dt.Rows[0][2].ToString());
                XmlTxtWtr.WriteElementString("PHONENUMBER", dt.Rows[0][3].ToString());
                XmlTxtWtr.WriteElementString("AMOUNT", dt.Rows[0][7].ToString());
                XmlTxtWtr.WriteElementString("STATUS", dt.Rows[0][0].ToString());
                XmlTxtWtr.WriteEndElement();
                XmlTxtWtr.WriteEndDocument();
                XmlTxtWtr.Flush();
                StreamReader strmrdr = new StreamReader(XmlMs);
                XmlMs.Seek(0, SeekOrigin.Begin);
                PaymentDetails = strmrdr.ReadToEnd();
                return(PaymentDetails);
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
コード例 #2
0
        public string PullKCCADetails(string PRN)
        {
            string result = "";
            try
            {
                string HashKey = MD5Hash(KCCASession_key + KCCAVendorCode + KCCAVendorPassword + KCCAHash);
                KCCAGateway.BankPaymentService x = new KCCAGateway.BankPaymentService();
               
                // ----------------------- Get Session Key --------------------------
                var Sessionkey = new object();
                try
                {
                    Sessionkey = x.authenticate(KCCASession_key, KCCAVendorCode, KCCAVendorPassword, HashKey, "");                    
                }
                catch (Exception ex)
                {
                    result=ex.Message;
                }
                string skey = "";
                //DataRow rw = null;
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                StringReader strRdr = new StringReader(Sessionkey.ToString());
                try
                {
                    ds.ReadXml(strRdr);
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
                dt = ds.Tables[0];
                skey = dt.Rows[0][1].ToString();      
          

                // ------------------- Validate against prn --------------------------
                string validateresponse = "";
                try
                {
                    validateresponse = x.verifyReference  (skey, PRN, "", "");
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
                dt = new DataTable();
                ds = new DataSet();
                strRdr = new StringReader(validateresponse);
                try
                {
                    ds.ReadXml(strRdr);
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
                dt = ds.Tables[0];

                // ---------------------- Return Xml Response -------------------------
                string PaymentDetails = "";
                MemoryStream XmlMs = new MemoryStream();
                XmlTextWriter XmlTxtWtr = new XmlTextWriter(XmlMs, System.Text.Encoding.UTF8);
                XmlTxtWtr.Formatting = Formatting.Indented;
                XmlTxtWtr.Indentation = 4;
                XmlTxtWtr.WriteStartDocument();
                XmlTxtWtr.WriteStartElement("KCCA PAYMENT DETAILS");
                XmlTxtWtr.WriteElementString("PRN",dt.Rows[0][4].ToString());
                XmlTxtWtr.WriteElementString("COIN", dt.Rows[0][1].ToString());
                XmlTxtWtr.WriteElementString("CUSTNAME", dt.Rows[0][2].ToString());
                XmlTxtWtr.WriteElementString("PHONENUMBER", dt.Rows[0][3].ToString());
                XmlTxtWtr.WriteElementString("AMOUNT", dt.Rows[0][7].ToString());
                XmlTxtWtr.WriteElementString("STATUS", dt.Rows[0][0].ToString());
                XmlTxtWtr.WriteEndElement();
                XmlTxtWtr.WriteEndDocument();
                XmlTxtWtr.Flush();
                StreamReader strmrdr = new StreamReader(XmlMs);
                XmlMs.Seek(0, SeekOrigin.Begin);
                PaymentDetails = strmrdr.ReadToEnd();
                return PaymentDetails;              
            }
            catch (Exception ex)
            {
                result= ex.Message;
            }
            return result;
        }
コード例 #3
0
        public string PayKCCA(string PRN, string data, string UTILITYACCOUNT, string Amount, string debitmobilenumber, string TXNDATE, string TXNTIME, string alertcontact, string EXREF)
        {
            var FailureDetailsinfo = new KCCAADAPAYResponse();
            var KCCADetailsinfo    = new KCCAADAPAYResponse();

            string HashKey = MD5Hash(KCCASession_key + KCCAVendorCode + KCCAVendorPassword + KCCAHash);

            KCCAGateway.BankPaymentService x = new KCCAGateway.BankPaymentService();

            // ----------------------- Get Session Key --------------------------
            var Sessionkey = new object();

            try
            {
                Sessionkey = x.authenticate(KCCASession_key, KCCAVendorCode, KCCAVendorPassword, HashKey, "");
            }
            catch (Exception ex)
            {
                //result = ex.Message;
            }
            string skey = "";
            //DataRow rw = null;
            DataSet      ds     = new DataSet();
            DataTable    dt     = new DataTable();
            StringReader strRdr = new StringReader(Sessionkey.ToString());

            try
            {
                ds.ReadXml(strRdr);
            }
            catch (Exception ex)
            {
                //result = ex.Message;
            }
            dt   = ds.Tables[0];
            skey = dt.Rows[0][1].ToString();


            // ------------------- Validate against prn --------------------------
            string validateresponse = "";

            try
            {
                validateresponse = x.verifyReference(skey, PRN, "", "");
            }
            catch (Exception ex)
            {
                // result = ex.Message;
            }
            dt     = new DataTable();
            ds     = new DataSet();
            strRdr = new StringReader(validateresponse);
            try
            {
                ds.ReadXml(strRdr);
            }
            catch (Exception ex)
            {
                //result = ex.Message;
            }
            dt = ds.Tables[0];
            string COIN, CUSTOMERNAME, PHONENUMBER, PRNDATE, EXPIRYDATE, AMOUNTDUE, PAYMENTCURRENCY, STATUS, StatusDescriptionx, balance, CustomerTypex;

            COIN               = dt.Rows[0][1].ToString();
            CUSTOMERNAME       = dt.Rows[0][2].ToString();
            PHONENUMBER        = dt.Rows[0][3].ToString();
            PRNDATE            = dt.Rows[0][5].ToString();
            EXPIRYDATE         = dt.Rows[0][6].ToString();
            AMOUNTDUE          = dt.Rows[0][7].ToString();
            StatusDescriptionx = "UNSUCCCESSFUL";
            balance            = "";
            CustomerTypex      = "POST PAID";

            PAYMENTCURRENCY = "";
            STATUS          = dt.Rows[0][0].ToString();
            Datamanagement.PushKCCACustReferenceDetails(PRN, COIN, CUSTOMERNAME, PHONENUMBER, PRNDATE, EXPIRYDATE, AMOUNTDUE, PAYMENTCURRENCY, STATUS);
            Thread.Sleep(5000);

            switch (STATUS)
            {
            case "A":
                break;

            default:

                FailureDetailsinfo.EXRef          = EXREF;
                FailureDetailsinfo.CustReference  = PRN;
                FailureDetailsinfo.PaymentAmount  = Amount;
                FailureDetailsinfo.FailureDetails = new List <KCCAFailureDetials>();
                FailureDetailsinfo.FailureDetails.Add(new KCCAFailureDetials()
                {
                    Remark       = StatusDescriptionx,
                    Responcecode = "05"
                });
                if (STATUS == "T")
                {
                    return("Transaction Already Transacted");
                }
                else if (STATUS == "X")
                {
                    return("Transaction Has Expired ");
                }
                else
                {
                    return("UNSUCCESSFULL");
                }
                break;
            }

            string sp_reference = PRN + "-" + CUSTOMERNAME;
            bool   istransacted = Datamanagement.isalreadyTransactedKCCA(PRN);

            switch (istransacted)
            {
            case true:
                FailureDetailsinfo.EXRef          = EXREF;
                FailureDetailsinfo.CustReference  = PRN;
                FailureDetailsinfo.PaymentAmount  = Amount;
                FailureDetailsinfo.FailureDetails = new List <KCCAFailureDetials>();
                FailureDetailsinfo.FailureDetails.Add(new KCCAFailureDetials()
                {
                    Remark =
                        "Payment reference has already been transacted",
                    Responcecode = "05"
                });
                return("UNSUCCESSFULL");

                break;

            default:
                break;
            }

            string Trantypey = "FCDB";

            PRN = PRN + Trantypey;
            string MyRef = (PRN.ToString()).Trim().Replace(" ", "").ToUpper() +
                           System.DateTime.Today.ToString("yyMMdd") + System.DateTime.Now.ToString("hhmmss") + "UTIL";

            Thread.Sleep(5000);

            //DEBIT CUSTOMER MOBILE MONEY ACCOUNT

            bool   issuccess = true;
            string coin      = Datamanagement.coin_(PRN);

            EXREF = "exref";

            switch (issuccess)
            {
            case true:
                Datamanagement.IsertintoKCCAPayments(MyRef, "KCCA Payment",
                                                     UTILITYACCOUNT, CUSTOMERNAME, balance, Amount,
                                                     "mobile money payment",
                                                     debitmobilenumber, PRN,
                                                     CustomerTypex,
                                                     alertcontact, "", TXNDATE,
                                                     STATUS, StatusDescriptionx, "KCCA Payment", "0", "2",
                                                     "", coin);


                break;

            case false:
                FailureDetailsinfo.EXRef          = EXREF;
                FailureDetailsinfo.CustReference  = PRN;
                FailureDetailsinfo.PaymentAmount  = AMOUNTDUE;
                FailureDetailsinfo.FailureDetails = new List <KCCAFailureDetials>();
                FailureDetailsinfo.FailureDetails.Add(new KCCAFailureDetials()
                {
                    Remark       = "Failed To Post To Core Banking",
                    Responcecode = "05"
                });
                return("UNSUCCESSFULL");

                break;
            }

            //Notify KCCA

            Thread.Sleep(5000);
            notifyKCCA(PRN);


            //RESPOND HERE
            KCCADetailsinfo.EXRef         = EXREF;
            KCCADetailsinfo.CustReference = PRN;
            KCCADetailsinfo.PaymentAmount = AMOUNTDUE;
            KCCADetailsinfo.KCCADetails   = new List <KCCADetails>();
            KCCADetailsinfo.KCCADetails.Add(new KCCADetails()
            {
                AmountPaid        = AMOUNTDUE,
                Balance           = AMOUNTDUE,
                CustomerName      = CUSTOMERNAME,
                CustomerType      = "",
                Remark            = "",
                Responcecode      = "00",
                StatusCode        = STATUS,
                StatusDescription = StatusDescriptionx,
                FlexResponse      = EXREF
            });
            return(KCCADetailsinfo.EXRef.ToString());
        }
コード例 #4
0
        public string PayKCCA(string PRN, string data, string UTILITYACCOUNT, string Amount, string debitmobilenumber, string TXNDATE, string TXNTIME, string alertcontact, string EXREF)
        {
            var FailureDetailsinfo = new KCCAADAPAYResponse();
            var KCCADetailsinfo = new KCCAADAPAYResponse();

            string HashKey = MD5Hash(KCCASession_key + KCCAVendorCode + KCCAVendorPassword + KCCAHash);
            KCCAGateway.BankPaymentService x = new KCCAGateway.BankPaymentService();

            // ----------------------- Get Session Key --------------------------
            var Sessionkey = new object();
            try
            {
                Sessionkey = x.authenticate(KCCASession_key, KCCAVendorCode, KCCAVendorPassword, HashKey, "");
            }
            catch (Exception ex)
            {
                //result = ex.Message;
            }
            string skey = "";
            //DataRow rw = null;
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            StringReader strRdr = new StringReader(Sessionkey.ToString());
            try
            {
                ds.ReadXml(strRdr);
            }
            catch (Exception ex)
            {
                //result = ex.Message;
            }
            dt = ds.Tables[0];
            skey = dt.Rows[0][1].ToString();


            // ------------------- Validate against prn --------------------------
            string validateresponse = "";
            try
            {
                validateresponse = x.verifyReference(skey, PRN, "", "");
            }
            catch (Exception ex)
            {
               // result = ex.Message;
            }
            dt = new DataTable();
            ds = new DataSet();
            strRdr = new StringReader(validateresponse);
            try
            {
                ds.ReadXml(strRdr);
            }
            catch (Exception ex)
            {
                //result = ex.Message;
            }
            dt = ds.Tables[0];
            string COIN, CUSTOMERNAME, PHONENUMBER, PRNDATE, EXPIRYDATE, AMOUNTDUE, PAYMENTCURRENCY, STATUS, StatusDescriptionx, balance, CustomerTypex;
            COIN = dt.Rows[0][1].ToString();
            CUSTOMERNAME = dt.Rows[0][2].ToString();
            PHONENUMBER = dt.Rows[0][3].ToString();
            PRNDATE = dt.Rows[0][5].ToString();
            EXPIRYDATE = dt.Rows[0][6].ToString();
            AMOUNTDUE = dt.Rows[0][7].ToString();
            StatusDescriptionx = "UNSUCCCESSFUL";
            balance = "";
            CustomerTypex = "POST PAID";

            PAYMENTCURRENCY = "";
            STATUS = dt.Rows[0][0].ToString();
            Datamanagement.PushKCCACustReferenceDetails(PRN,COIN,CUSTOMERNAME,PHONENUMBER,PRNDATE,EXPIRYDATE,AMOUNTDUE,PAYMENTCURRENCY ,STATUS );
            Thread.Sleep(5000);

            switch (STATUS)
            {
                case "A":
                    break;
                default:

                    FailureDetailsinfo.EXRef = EXREF;
                    FailureDetailsinfo.CustReference = PRN;
                    FailureDetailsinfo.PaymentAmount = Amount;
                    FailureDetailsinfo.FailureDetails = new List<KCCAFailureDetials>();
                    FailureDetailsinfo.FailureDetails.Add(new KCCAFailureDetials()
                    {
                        Remark = StatusDescriptionx,
                        Responcecode = "05"
                    });
                    if (STATUS == "T")
                    {
                        return "Transaction Already Transacted";
                    }
                    else if (STATUS == "X")
                    {
                        return "Transaction Has Expired ";
                    }
                    else
                    {
                        return "UNSUCCESSFULL";
                    }
                    break;
            }

            string sp_reference = PRN + "-" + CUSTOMERNAME;
            bool istransacted = Datamanagement.isalreadyTransactedKCCA(PRN);
            switch (istransacted)
            {
                case true:
                    FailureDetailsinfo.EXRef = EXREF;
                    FailureDetailsinfo.CustReference = PRN;
                    FailureDetailsinfo.PaymentAmount = Amount;
                    FailureDetailsinfo.FailureDetails = new List<KCCAFailureDetials>();
                    FailureDetailsinfo.FailureDetails.Add(new KCCAFailureDetials()
                    {
                        Remark =
                            "Payment reference has already been transacted",
                        Responcecode = "05"
                    });
                    return "UNSUCCESSFULL";
                    break;
                default:
                    break;
            }

            string Trantypey = "FCDB";
            PRN = PRN + Trantypey;
            string MyRef = (PRN.ToString()).Trim().Replace(" ", "").ToUpper() +
                           System.DateTime.Today.ToString("yyMMdd") + System.DateTime.Now.ToString("hhmmss") + "UTIL";

            Thread.Sleep(5000);

            //DEBIT CUSTOMER MOBILE MONEY ACCOUNT

            bool issuccess = true;
            string coin = Datamanagement.coin_(PRN);
            EXREF = "exref";

            switch (issuccess)
                {

                    case true:
                        Datamanagement.IsertintoKCCAPayments(MyRef, "KCCA Payment",
                                                              UTILITYACCOUNT, CUSTOMERNAME, balance, Amount,
                                                              "mobile money payment",
                                                               debitmobilenumber,  PRN,
                                                              CustomerTypex,
                                                              alertcontact, "",  TXNDATE,
                                                              STATUS, StatusDescriptionx, "KCCA Payment", "0", "2",
                                                              "", coin);


                        break;
                    case false:
                        FailureDetailsinfo.EXRef = EXREF;
                        FailureDetailsinfo.CustReference = PRN ;
                        FailureDetailsinfo.PaymentAmount = AMOUNTDUE;
                        FailureDetailsinfo.FailureDetails = new List<KCCAFailureDetials>();
                        FailureDetailsinfo.FailureDetails.Add(new KCCAFailureDetials()
                        {
                            Remark = "Failed To Post To Core Banking",
                            Responcecode = "05"
                        });
                        return "UNSUCCESSFULL";
                        break;
                }

                //Notify KCCA

                Thread.Sleep(5000);
                notifyKCCA(PRN);


                //RESPOND HERE
                KCCADetailsinfo.EXRef = EXREF;
                KCCADetailsinfo.CustReference = PRN;
                KCCADetailsinfo.PaymentAmount = AMOUNTDUE;
                KCCADetailsinfo.KCCADetails = new List<KCCADetails>();
                KCCADetailsinfo.KCCADetails.Add(new KCCADetails()
                {
                    AmountPaid = AMOUNTDUE,
                    Balance = AMOUNTDUE,
                    CustomerName = CUSTOMERNAME ,
                    CustomerType = "",
                    Remark = "",
                    Responcecode = "00",
                    StatusCode = STATUS ,
                    StatusDescription = StatusDescriptionx,
                    FlexResponse = EXREF
                });
                return KCCADetailsinfo.EXRef.ToString();
            }