Пример #1
0
        public IHttpActionResult getEncrypt(dynamic data)
        {
            dynamic objenc = new ExpandoObject();

            try
            {
                string json = JsonConvert.SerializeObject(data);

                string iv  = CryptLib.GenerateRandomIV(16);
                string key = CryptLib.getHashSha256("GSWS TEST", 32);

                string encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(json, key, iv);

                objenc.Status      = 100;
                objenc.encrypttext = encrypttext;
                objenc.key         = iv;
                objenc.Reason      = "";
                return(Ok(objenc));
            }
            catch (Exception ex)
            {
                objenc.Status = 102;
                objenc.Reason = ex.Message.ToString();
                return(Ok(objenc));
            }
        }
Пример #2
0
        public dynamic initiateSpandanaTransaction(transactionModel obj)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                obj.TYPE       = "1";
                obj.IP_ADDRESS = HttpContext.Current.Request.UserHostAddress;
                obj.SYS_NAME   = System.Environment.MachineName;
                obj.TXN_ID     = obj.SECRETRAINT_CODE + DateTime.Now.ToString("yymmddHHmm") + new Random().Next(1000, 9999);
                DataTable dt = transactionInsertion(obj);

                if (dt != null && dt.Rows.Count > 0)
                {
                    string encrypttext = "";
                    string iv          = "";

                    iv = CryptLib.GenerateRandomIV(16);
                    string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                    string obj2 = GetInputJsonFormat(obj);
                    encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);

                    objdata.status = 200;
                    if (obj.URL_ID == "340200101")
                    {
                        objdata.URL = "https://www.spandana.ap.gov.in/gsws/servicegrievance_registration?accessToken=" + Token() + "&Volunteerid=2255667788&AadhaarNo=" + obj.UID + "&vvstype=VVS2&DistId=" + obj.Sdistcode + "&MandalId=" + obj.Smcode + "&GpId=" + obj.Svtcode + "&GpFlag=" + obj.SRuflag + "&encryptId=" + encrypttext + "&KEY=" + key + "&IV=" + iv;
                    }
                    else
                    {
                        objdata.URL = "https://www.spandana.ap.gov.in/gsws/servicerequest_registration?HodId=" + obj.SERVICE_CODE + "&accessToken= " + Token() + "&Volunteerid=2255667788&AadhaarNo=" + obj.UID + "&vvstype=VVS2&DistId=" + obj.Sdistcode + "&MandalId=" + obj.Smcode + "&GpId=" + obj.Svtcode + "&GpFlag=" + obj.SRuflag + "&encryptId=" + encrypttext + "&KEY=" + key + "&IV=" + iv;
                    }


                    objdata.Reason = "Record Inserted Successfully !!!";
                }
                else
                {
                    objdata.status = 400;
                    objdata.Reason = "Failed to Insert Record, Please Try Again !!! ";
                }
            }
            catch (Exception ex)
            {
                objdata.status = 500;
                objdata.Reason = "Something Went Wrong.Please Try Again";                //ex.Message.ToString();
            }

            return(objdata);
        }
Пример #3
0
        public dynamic initiateTransaction(transactionModel obj)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                obj.TYPE       = "1";
                obj.IP_ADDRESS = HttpContext.Current.Request.UserHostAddress;
                obj.SYS_NAME   = System.Environment.MachineName;
                obj.TXN_ID     = obj.SECRETRAINT_CODE + DateTime.Now.ToString("yyMMddHHmm") + new Random().Next(1000, 9999);
                DataTable dt = transactionInsertion(obj);

                if (dt != null && dt.Rows.Count > 0)
                {
                    string encrypttext = "";
                    string iv          = "";
                    if (obj.TYPE_OF_SERVICE == "1")
                    {
                        iv = CryptLib.GenerateRandomIV(16);
                        string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                        string obj2 = GetInputJsonFormat(obj);
                        encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);
                    }
                    else if (obj.URL_ID == "110401301" || obj.URL_ID == "110102501" || obj.URL_ID == "110102601" || obj.URL_ID == "310300104")
                    {
                        iv = CryptLib.GenerateRandomIV(16);
                        string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                        string obj2 = GetInputJsonFormat(obj);
                        encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);
                    }
                    else if (obj.URL_ID == "200301401" || obj.URL_ID == "360201701" || obj.URL_ID == "360201401" || obj.URL_ID == "130101101" || obj.URL_ID == "280101201" || obj.URL_ID == "280101401" || obj.URL_ID == "280101301" || obj.URL_ID == "360201801" || obj.URL_ID == "3602018501" || obj.URL_ID == "170100102" || obj.URL_ID == "130101401" || obj.URL_ID == "130101501" || obj.URL_ID == "240200101")
                    {
                        iv = CryptLib.GenerateRandomIV(16);
                        string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                        string obj2 = GetInputJsonFormat(obj);
                        encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);
                    }
                    else
                    {
                    }
                    objdata.status = 200;
                    //objdata.Translist = dt;
                    objdata.encrypttext = encrypttext;
                    objdata.key         = iv;
                    objdata.TransId     = obj.TXN_ID;
                    objdata.Reason      = "Record Inserted Successfully !!!";
                }
                else
                {
                    objdata.status = 400;
                    objdata.Reason = "Failed to Insert Record, Please Try Again !!! ";
                }
            }
            catch (Exception ex)
            {
                objdata.status = 500;
                objdata.Reason = "Something Went Wrong.Please Try Again";                //ex.Message.ToString();
            }

            return(objdata);
        }
Пример #4
0
        public dynamic OrderDetails(paymentModel obj)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                obj.orderId = "80120201019362644";

                orderDetailsModel rootobj = new orderDetailsModel();
                rootobj.Amount       = obj.Amount;
                rootobj.Description  = obj.Description;
                rootobj.mobileNumber = obj.mobileNumber;
                rootobj.orderId      = obj.orderId;
                rootobj.totalAmount  = obj.totalAmount;
                rootobj.TxnDate      = obj.TxnDate;
                rootobj.userCharges  = obj.userCharges;
                rootobj.userName     = obj.userName;
                rootobj.walletType   = "";


                DataTable dt1 = gswsPaymentRequestProc(obj, "4", "");
                obj.gswsCode    = dt1.Rows[0][0].ToString();
                obj.UniqueTxnId = obj.merchantId + obj.mobileNumber + DateTime.Now.ToString("yyyyMMddhhmmssmm");

                string json = JsonConvert.SerializeObject(obj);

                string iv  = CryptLib.GenerateRandomIV(16);
                string key = CryptLib.getHashSha256("GSWS TEST", 32);

                string encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(json, key, iv);

                obj.encrypttext = encrypttext;
                obj.iv          = iv;

                rootobj.encrypttext = obj.encrypttext;
                rootobj.iv          = obj.iv;


                if (obj.gswsCode == "10690589" || obj.gswsCode == "10690588" || obj.gswsCode == "10690590" || obj.gswsCode == "21073101")
                {
                    rootobj.walletType = "TA";
                }
                else if (obj.gswsCode == "10690567" || obj.gswsCode == "10690568" || obj.gswsCode == "21073097" || obj.gswsCode == "21073098" || obj.gswsCode == "21073099")
                {
                    rootobj.walletType = "WONE";
                }

                else if (obj.gswsCode == "10690581" || obj.gswsCode == "10690561" || obj.gswsCode == "10690574" || obj.gswsCode == "10690572" || obj.gswsCode == "10690573" || obj.gswsCode == "10690582" || obj.gswsCode == "21073095" || obj.gswsCode == "21073096" || obj.gswsCode == "21073082" || obj.gswsCode == "21073083" || obj.gswsCode == "21073085" || obj.gswsCode == "21073088")
                {
                    rootobj.walletType = "APW";
                }


                DataTable dt = gswsPaymentRequestProc(obj, "1", "");
                if (dt != null && dt.Rows.Count > 0)
                {
                    token_gen.initialize();
                    token_gen.expiry_minutes = 60;
                    token_gen.addClaim("admin");
                    token_gen.PRIMARY_MACHINE_KEY   = "10101010101010101010101010101010";
                    token_gen.SECONDARY_MACHINE_KEY = "1010101010101010";
                    token_gen.addResponse("status", "200");
                    token_gen.addResponse("result", JsonConvert.SerializeObject(rootobj));
                    return(token_gen.generate_token());
                }
                else
                {
                    objdata.status = 400;
                    objdata.result = "Invalid Input";
                    string mappath   = HttpContext.Current.Server.MapPath("gswsPaymentRequestProc.");
                    Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_ReportLog_Exception(mappath, JsonConvert.SerializeObject(obj)));
                }
            }
            catch (Exception ex)
            {
                objdata.status = 500;
                objdata.result = ex.Message.ToString();
            }
            return(objdata);
        }