示例#1
0
        public static async Task GenerateOtpAsync(string aadhaarNumber)
        {
            #region Device Level

            // Set OTP Info
            var otpContext = new OtpContext
            {
                AadhaarNumber = aadhaarNumber,
                Channel       = OtpChannel.Sms,
                OtpInfo       = new OtpInfo()
            };

            #endregion

            #region Device To Agency
            // TODO: Wrap DeviceContext{T} into AUA specific protocol and send it to AUA.
            // On Device Side:
            // var deviceXml = deviceContext.ToXml();
            // var wrapped = WrapIntoAuaProtocol(deviceXml);

            // On Agency Side:
            // var auaXml = UnwrapFromAuaProtocol(wrapped);
            // var auaContext = new OtpContext();
            // auaContext.FromXml(auaXml);
            #endregion

            #region Agency Level

            // Perform One Time Pin Request
            var apiClient = new OtpClient
            {
                AgencyInfo = Options.AgencyInfo,
                Request    = new OtpRequest(otpContext)
                {
                    Signer = Signer
                },
                Response = new OtpResponse()
            };
            await apiClient.GetResponseAsync(null, b =>
            {
                return(b);
            });

            apiClient.Request.OtpInfo.Encode();
            apiClient.Response.OtpInfo.Decode();

            Console.WriteLine(string.IsNullOrEmpty(apiClient.Response.ErrorCode)
                ? "OTP sent to mobile."
                : $"Error Code: {apiClient.Response.ErrorCode}");

            #endregion

            #region Agency To Device
            // TODO: Wrap OtpResponse into AUA specific protocol and send it to device.
            #endregion
        }
示例#2
0
        public static async Task GenerateOtpAsync(string aadhaarNumber)
        {
            // A workaround to support version 1.5. Can be removed once v1.5 becomes obsolete.
            OtpRequest.OtpVersion = "1.5";

            #region Device Level

            // Set OTP Info
            var otpContext = new OtpContext
            {
                AadhaarOrMobileNumber = aadhaarNumber,
                Channel = OtpChannel.Sms
            };

            #endregion

            #region Device To Agency
            // TODO: Wrap DeviceContext{T} into AUA specific protocol and send it to AUA.
            // On Device Side:
            // var deviceXml = deviceContext.ToXml();
            // var wrapped = WrapIntoAuaProtocol(deviceXml);

            // On Agency Side:
            // var auaXml = UnwrapFromAuaProtocol(wrapped);
            // var auaContext = new OtpContext();
            // auaContext.FromXml(auaXml);
            #endregion

            #region Agency Level

            // Perform One Time Pin Request
            var apiClient = new OtpClient
            {
                AgencyInfo = Configuration.AgencyInfo,
                Request    = new OtpRequest(otpContext)
                {
                    Signer = Signer
                },
                Response = new OtpResponse()
            };
            await apiClient.GetResponseAsync();

            Console.WriteLine(string.IsNullOrEmpty(apiClient.Response.ErrorCode)
                ? $"Is OTP Sent: {apiClient.Response.IsOtpSent}"
                : $"Error Code: {apiClient.Response.ErrorCode}");

            #endregion

            #region Agency To Device
            // TODO: Wrap OtpResponse into AUA specific protocol and send it to device.
            #endregion
        }
示例#3
0
        public static async Task OneTimePasswordAsync()
        {
            OtpRequest.OtpVersion = "1.5";

            #region Device Level

            // Set OTP Info
            var otpContext = new OtpContext
            {
                AadhaarOrMobileNumber = "999999990019",
                Channel = OtpChannel.Sms
            };

            #endregion

            #region Device To Agency
            // TODO: Wrap DeviceContext{T} into AUA specific protocol and send it to AUA.
            // On Device Side:
            // var deviceXml = deviceContext.ToXml();
            // var wrapped = WrapIntoAuaProtocol(deviceXml);

            // On Agency Side:
            // var auaXml = UnwrapFromAuaProtocol(wrapped);
            // var auaContext = new OtpContext();
            // auaContext.FromXml(auaXml);
            #endregion

            #region Agency Level

            // Perform One Time Pin Request
            var otpClient = new OtpClient
            {
                AgencyInfo = Configuration.Current.AgencyInfo,
                Request    = new OtpRequest(otpContext)
                {
                    Signer = XmlSignature
                },
                Response = new OtpResponse()
            };
            await otpClient.GetResponseAsync();

            Console.WriteLine(string.IsNullOrEmpty(otpClient.Response.ErrorCode)
                ? $"Is Sent: {otpClient.Response.IsOtpSent}"
                : $"Error Code: {otpClient.Response.ErrorCode}");

            #endregion

            #region Agency To Device
            // TODO: Wrap OtpResponse into AUA specific protocol and send it to device.
            #endregion
        }