Пример #1
0
    public string GetOTP(string AadharNo)
    {
        string result = "";
        string json   = "";

        if (AadharNo == "")
        {
            json   = "";
            json  += "{";
            json  += "\"status\":false";
            json  += ",\"msg\":\"Enter AAdhar !\"";
            json  += "}";
            result = json;
        }
        else
        {
            if (objCommonfun.isValidAadhaar(AadharNo))
            {
                AuthOTP       objAuthOTP = new AuthOTP();
                StringBuilder strotp     = new StringBuilder();
                ASPID         = System.Configuration.ConfigurationManager.AppSettings["ASPID"].ToString();
                transactionID = DateTime.Now.ToString("yyyyMMddThhmmss");
                timeStamp     = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
                strotp.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                strotp.Append("<OTP ver=\"1.0\" aspId=\"" + ASPID + "\" ts=\"" + timeStamp + "\" uid=\"" + AadharNo + "\" txn=\"" + transactionID + "\">");
                strotp.Append("</OTP>");
                requestXML  = strotp.ToString();
                PFXPath     = System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ClientCertificate"].ToString());
                PFXPassword = "******";
                if (!string.IsNullOrEmpty(PFXPath))
                {
                    requestXML = SignXML(requestXML);
                }
                eSignURL = objCommonfun.getHttpOTPRequesturl();
                string URL = eSignURL;
                if (!string.IsNullOrEmpty(URL) && !string.IsNullOrEmpty(requestXML))
                {
                    responseXML = HttpsWebClientSendSMS(URL, System.Web.HttpUtility.UrlEncode(requestXML));
                    var xml = new XmlDocument();
                    xml.LoadXml(responseXML);
                    XmlNode OTPResp = xml.SelectSingleNode("OTPResp");
                    if (OTPResp.Attributes["errCode"].Value != string.Empty)
                    {
                        json   = "";
                        json  += "{";
                        json  += "\"status\":false";
                        json  += ",\"msg\":\"" + OTPResp.Attributes["errMsg"].Value + "\"";
                        json  += "}";
                        result = json;
                    }
                    else if (OTPResp.Attributes["status"].Value != "0")
                    {
                        json   = "";
                        json  += "{";
                        json  += "\"status\":true";
                        json  += ",\"msg\":\"OTP generated successfully\"";
                        json  += "}";
                        result = json;
                    }
                    else
                    {
                        json   = "";
                        json  += "{";
                        json  += "\"status\":false";
                        json  += ",\"msg\":\"OTP generation failed\"";
                        json  += "}";
                        result = json;
                    }
                }
            }
            else
            {
                json   = "";
                json  += "{";
                json  += "\"status\":false";
                json  += ",\"msg\":\"Invalid Aadhar !\"";
                json  += "}";
                result = json;
            }
        }
        return(result);
    }
Пример #2
0
    public string GetAadhaarOTP(string AadhaarNo, string access_token, string transaction_id)
    {
        string output      = string.Empty;
        string result      = "";
        string json        = "";
        string newFileName = System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["OTPLogFile"].ToString());

        if (AadhaarNo == "")
        {
            json   = "";
            json  += "{";
            json  += "\"status\":false";
            json  += ",\"msg\":\"Enter Aadhaar No.!\"";
            json  += "}";
            result = json;
        }
        else
        {
            if (objCommonfun.isValidAadhaar(AadhaarNo))
            {
                AuthOTP objAuthOTP   = new AuthOTP();
                string  otpXmlToSend = objAuthOTP.GenOTPXML(AadhaarNo.Trim(), transaction_id);
                string  ResponseXML  = "";

                string HttpWebRequesturl = objCommonfun.getHttpWebRequesturl();
                ResponseXML = objCommonfun.Postauthxml_OnAUA(otpXmlToSend, HttpWebRequesturl);

                output = objCommonfun.ParseRespXML(ResponseXML);
                if (output == "y")
                {
                    json   = "";
                    json  += "{";
                    json  += "\"status\":true";
                    json  += ",\"msg\":\"OTP Sent Successfully\"";
                    json  += ",\"access_token\":\"" + access_token + "\"";
                    json  += ",\"transaction_id\":\"" + transaction_id + "\"";
                    json  += "}";
                    result = json;
                    string clientDetails = AadhaarNo + "," + access_token + "," + transaction_id + "," + "true" + "," + "OTP Sent Successfully" + "," + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + Environment.NewLine;

                    File.AppendAllText(newFileName, clientDetails);
                }
                else if (output == "n")
                {
                    json   = "";
                    json  += "{";
                    json  += "\"status\":false";
                    json  += ",\"code\":101";
                    json  += ",\"msg\":\"OTP Sent Failed\"";
                    json  += "}";
                    result = json;
                    string clientDetails = AadhaarNo + "," + access_token + "," + transaction_id + "," + "false" + "," + "OTP Sent Failed" + "," + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + Environment.NewLine;
                    File.AppendAllText(newFileName, clientDetails);
                }
                else
                {
                    json   = "";
                    json  += "{";
                    json  += "\"status\":false";
                    json  += ",\"code\":102";
                    json  += ",\"msg\":\"" + output + "\"";
                    json  += "}";
                    result = json;
                    string clientDetails = AadhaarNo + "," + access_token + "," + transaction_id + "," + "false" + "," + output + "," + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + Environment.NewLine;
                    File.AppendAllText(newFileName, clientDetails);
                }
            }
            else
            {
                json   = "";
                json  += "{";
                json  += "\"status\":false";
                json  += ",\"msg\":\"Invalid Aadhar !\"";
                json  += "}";
                result = json;
            }
        }
        return(result);
    }