예제 #1
0
        public static string AddressVerificationRequest(AddressVerificationRequest AddressVerifReq)
        {
            var responseString = "";
            var fullUrl        = seamFixBaseUrl + "/sfx-verify/v2/address";
            var json           = JsonConvert.SerializeObject(AddressVerifReq);
            var requestTime    = DateTime.Now;

            try
            {
                using (var client = new HttpClient())
                {
                    Utils.AddCustomHeadersToHttpClient(client);
                    var data = new StringContent(json, Encoding.UTF8, "application/json");
                    requestTime = DateTime.Now;
                    var httpResponseMsg = client.PostAsync(fullUrl, data).Result;

                    if (httpResponseMsg.IsSuccessStatusCode)
                    {
                        responseString = httpResponseMsg.Content.ReadAsStringAsync().Result;
                    }
                }
                var responseTime = DateTime.Now;
                RequestResponseRepository.SaveRequestResponse("POST", json, requestTime, fullUrl, responseString, "", responseTime);
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(responseString);
        }
예제 #2
0
        public static string AddressVerificationStatus(string referenceNo)
        {
            var responseString = "";
            var fullUrl        = seamFixBaseUrl + "/sfx-verify/v2/query/" + referenceNo;
            var requestTime    = DateTime.Now;

            try

            {
                using (var client = new HttpClient())
                {
                    Utils.AddCustomHeadersToHttpClient(client);
                    requestTime = DateTime.Now;
                    var httpResponseMsg = client.GetAsync(fullUrl).Result;

                    if (httpResponseMsg.IsSuccessStatusCode)
                    {
                        responseString = httpResponseMsg.Content.ReadAsStringAsync().Result;
                    }
                }
                var responseTime = DateTime.Now;
                RequestResponseRepository.SaveRequestResponse("GET", "", requestTime, fullUrl, responseString, "", responseTime);
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(responseString);
        }
예제 #3
0
        public static string DocumentServiceRequest(DocumentServiceRequest documentsValidation)
        {
            var responseString = "";
            var fullUrl        = seamFixBaseDocUrl + "document/check/";

            documentsValidation.transactionRef = KycLogic.GenerateTransactionRef();
            var json        = JsonConvert.SerializeObject(documentsValidation);
            var requestTime = DateTime.Now;

            try
            {
                using (var client = new HttpClient())
                {
                    Utils.AddCustomHeadersToHttpClient(client);
                    var data = new StringContent(json, Encoding.UTF8, "application/json");
                    requestTime = DateTime.Now;
                    var httpResponseMsg = client.PostAsync(fullUrl, data).Result;

                    if (httpResponseMsg.IsSuccessStatusCode)
                    {
                        responseString = httpResponseMsg.Content.ReadAsStringAsync().Result;
                    }
                }
                var responseTime = DateTime.Now;
                RequestResponseRepository.SaveRequestResponse("POST", json, requestTime, fullUrl, responseString, "", responseTime);
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(responseString);
        }
예제 #4
0
        public static string IdServiceValidation(IdValidationRequest idValidation)
        {
            var idType = "";

            switch (idValidation.idType.ToLower())
            {
            case "nin":
                idType = "nin";
                break;

            case "vin":
                idType = "vin";
                break;

            case "passport":
                idType = "passport";
                break;

            case "frsc":
                idType = "frsc";
                break;

            default:
                idType = "";
                break;
            }

            var responseString = "";
            var fullUrl        = seamFixBaseUrl + "id-service/" + idType;

            idValidation.transactionRef = KycLogic.GenerateTransactionRef();
            var json        = JsonConvert.SerializeObject(idValidation);
            var requestTime = DateTime.Now;

            try
            {
                using (var client = new HttpClient())
                {
                    Utils.AddCustomHeadersToHttpClient(client);

                    var data = new StringContent(json, Encoding.UTF8, "application/json");

                    requestTime = DateTime.Now;
                    var httpResponseMsg = client.PostAsync(fullUrl, data).Result;

                    if (httpResponseMsg.IsSuccessStatusCode)
                    {
                        responseString = httpResponseMsg.Content.ReadAsStringAsync().Result;
                    }
                }

                var responseTime = DateTime.Now;
                RequestResponseRepository.SaveRequestResponse("POST", json, requestTime, fullUrl, responseString, "", responseTime);
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(responseString);
        }
예제 #5
0
        public static string IdServiceFaceMatch(IdFaceMatchRequest idFaceValidation)
        {
            var responseString = "";
            var idType         = "";

            switch (idFaceValidation.idType.ToLower())
            {
            case "nin":
                idType = "nin";
                break;

            case "vin":
                idType = "vin";
                break;

            case "passport":
                idType = "passport";
                break;

            case "frsc":
                idType = "frsc";
                break;

            default:
                idType = "";
                break;
            }
            try
            {
                using (var client = new WebClient())
                {
                    var fullUrl = seamFixBaseUrl + "id-service/" + idType;
                    var values  = new NameValueCollection();
                    values["idNo"]                  = idFaceValidation.idNo;
                    values["idBase64String"]        = idFaceValidation.idBase64String;
                    values["surname"]               = idFaceValidation.surname;
                    values["firstname"]             = idFaceValidation.firstname;
                    values["dob"]                   = idFaceValidation.dob;
                    values["passportBase64String"]  = idFaceValidation.passportBase64String;
                    idFaceValidation.transactionRef = KycLogic.GenerateTransactionRef();
                    values["transactionRef"]        = idFaceValidation.transactionRef;
                    var requestTime  = DateTime.Now;
                    var response     = client.UploadValues(fullUrl, values);
                    var responseTime = DateTime.Now;
                    responseString = Encoding.Default.GetString(response);

                    RequestResponseRepository.SaveRequestResponse("POST", values.ToString(), requestTime, fullUrl, responseString, "", responseTime);
                }
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(responseString);
        }
예제 #6
0
        public static string DoMandateCancellation(string requestStr)
        {
            Serializer            ser           = new Serializer();
            string                xmlOutputData = string.Empty;
            string                responseCode  = string.Empty;
            DateTime              requestTime   = DateTime.Now;
            CancelMandateResponse objResp       = new CancelMandateResponse();

            try
            {
                CancelMandateRequest obj = ser.Deserialize <CancelMandateRequest>(requestStr);
                if (obj != null)
                {
                    bool isSaved = MandateRepo.CancelMandate(obj.MandateCode, obj.BillerID);

                    responseCode = isSaved ? ResponseCodeMap.Successful : ResponseCodeMap.UnknownError;

                    objResp = new CancelMandateResponse
                    {
                        BankCode      = obj.BankCode,
                        BillerID      = obj.BillerID,
                        BillerName    = obj.BillerName,
                        BillerTransId = obj.BillerTransId,
                        MandateCode   = obj.MandateCode,
                        TransType     = obj.TransType,
                        ResponseCode  = responseCode,
                        HashValue     = obj.HashValue
                    };
                }
                else
                {
                    objResp = new CancelMandateResponse {
                        ResponseCode = ResponseCodeMap.InvalidXml
                    };
                }
                xmlOutputData = ser.Serialize <CancelMandateResponse>(objResp);
            }
            catch (Exception e) {
                ExceptionLogRepo.SaveExceptionLog(e);
                xmlOutputData = ser.Serialize <CancelMandateResponse>(new CancelMandateResponse {
                    ResponseCode = ResponseCodeMap.InvalidXml
                });
            }
            DateTime responseTime = DateTime.Now;

            RequestResponseRepository.SaveRequestResponse("ASMX", requestStr, requestTime, "", xmlOutputData, responseTime);
            return(xmlOutputData);
        }
예제 #7
0
        public static string DoMandateRequery(string requestStr)
        {
            Serializer             ser           = new Serializer();
            string                 xmlOutputData = string.Empty;
            string                 responseCode  = string.Empty;
            DateTime               requestTime   = DateTime.Now;
            RequeryMandateResponse objResp       = new RequeryMandateResponse();

            try
            {
                RequeryMandateRequest obj = ser.Deserialize <RequeryMandateRequest>(requestStr);
                if (obj != null)
                {
                    MandateLog mandate = MandateRepo.QueryMandate(obj.MandateCode, obj.BillerID);

                    responseCode = mandate != null ? ResponseCodeMap.Successful : ResponseCodeMap.UnknownError;

                    objResp = new RequeryMandateResponse
                    {
                        BankCode      = mandate.BankCode,
                        BillerID      = mandate.BillerId,
                        BillerName    = mandate.BillerName,
                        BillerTransId = mandate.BillerTransId,
                        MandateCode   = mandate.MandateCode,
                        TransType     = mandate.TransType,
                        ResponseCode  = responseCode,
                        HashValue     = mandate.HashValue,
                        AcctName      = mandate.AccountName,
                        AcctNumber    = mandate.AccountNumber
                    };
                }
                else
                {
                    objResp = new RequeryMandateResponse {
                        ResponseCode = ResponseCodeMap.InvalidXml
                    };
                }
                xmlOutputData = ser.Serialize <RequeryMandateResponse>(objResp);
            }
            catch (Exception e) { ExceptionLogRepo.SaveExceptionLog(e);
                                  xmlOutputData = ser.Serialize <RequeryMandateResponse>(new RequeryMandateResponse {
                    ResponseCode = ResponseCodeMap.InvalidXml
                }); }
            DateTime responseTime = DateTime.Now;

            RequestResponseRepository.SaveRequestResponse("ASMX", requestStr, requestTime, "", xmlOutputData, responseTime);
            return(xmlOutputData);
        }
예제 #8
0
        public static string DoOTPValidationWithoutCustomerRegistration(string requestStr)
        {
            Serializer          ser           = new Serializer();
            string              xmlOutputData = string.Empty;
            string              responseCode  = string.Empty;
            DateTime            requestTime   = DateTime.Now;
            ValidateOTPResponse objResp       = new ValidateOTPResponse();

            try
            {
                ValidateOTPRequestEx obj = ser.Deserialize <ValidateOTPRequestEx>(requestStr);
                if (obj != null)
                {
                    bool isSaved = MandateRepo.ValidateOtp(obj.MandateCode, obj.OTP, Convert.ToDecimal(obj.Amount));

                    responseCode = isSaved ? ResponseCodeMap.Successful : ResponseCodeMap.InvalidXml;

                    objResp = new ValidateOTPResponse
                    {
                        BankCode      = obj.BankCode,
                        BillerID      = obj.BillerID,
                        BillerName    = obj.BillerName,
                        BillerTransId = obj.BillerTransId,
                        MandateCode   = obj.MandateCode,
                        TransType     = obj.TransType,
                        ResponseCode  = responseCode,
                        Amount        = obj.Amount,
                        HashValue     = obj.HashValue
                    };
                }
                else
                {
                    objResp = new ValidateOTPResponse {
                        ResponseCode = ResponseCodeMap.InvalidXml
                    };
                }
                xmlOutputData = ser.Serialize <ValidateOTPResponse>(objResp);
            }
            catch (Exception e) { ExceptionLogRepo.SaveExceptionLog(e);
                                  xmlOutputData = ser.Serialize <ValidateOTPResponse>(new ValidateOTPResponse {
                    ResponseCode = ResponseCodeMap.InvalidXml
                }); }
            DateTime responseTime = DateTime.Now;

            RequestResponseRepository.SaveRequestResponse("ASMX", requestStr, requestTime, "", xmlOutputData, responseTime);
            return(xmlOutputData);
        }
예제 #9
0
        public static BankBvnResponse getBvn(string bvn, string bankCode)
        {
            var bankBvnResponse = new BankBvnResponse();

            try
            {
                //str1 = o2.ResponseCode + "|" + o2.FirstName + "|" + o2.MiddleName + "|" + o2.LastName + "|" + o2.DateOfBirth + "|" + o2.ImageBase64
                BankBvnService.BVNProcessorSoapClient client = new BankBvnService.BVNProcessorSoapClient();
                var requestTime  = DateTime.Now;
                var response     = client.VerifySingleBVN(bvn, bankCode);
                var responseTime = DateTime.Now;
                RequestResponseRepository.SaveRequestResponse("ASMX", "bvn : " + bvn + "; bankcode :" + bankCode, requestTime, "bankBvnService", response, "", responseTime);
                bankBvnResponse = kyc.bridge.api.BusinessLogic.KycLogic.RetrieveBvnDetailsFromResponse(response);
            }
            catch (Exception e)
            {
                ExceptionLogRepository.SaveExceptionLog(e);
            }
            return(bankBvnResponse);
        }
예제 #10
0
파일: Startup.cs 프로젝트: edmd/glimpse
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddServerSideBlazor();

            services.AddDbContext <DataContext>(options =>
                                                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))
                                                .EnableSensitiveDataLogging());
            services.AddTransient <DbContext, DataContext>();

            services.AddHttpClient <RequestResponseClient>("RequestResponseClient", client => {
                client.Timeout = TimeSpan.FromSeconds(10);
            });

            services.AddTransient <IRequestResponseRepository>(ctx => {
                var context = ctx.GetRequiredService <DataContext>();
                var requestResponseRepository = new RequestResponseRepository(context);
                return(requestResponseRepository);
            });

            services.AddTransient <IHttpResponseEventRepository>(ctx => {
                var context = ctx.GetRequiredService <DataContext>();
                var httpResponseEventRepository = new HttpResponseEventRepository(context);
                return(httpResponseEventRepository);
            });

            services.AddTransient <IHttpClientInstance>(ctx => {
                var requestResponseClient = ctx.GetRequiredService <RequestResponseClient>().Client;
                var httpClientInstance    = new HttpClientInstance(requestResponseClient);
                return(httpClientInstance);
            });

            services.AddTransient <IConnectionFactory>(ctx => {
                var connStr     = this.Configuration["Rabbit"];
                var connFactory = new ConnectionFactory()
                {
                    Uri = new Uri(connStr),
                    DispatchConsumersAsync = true // This is mandatory to have Async Subscribers
                };
                return(connFactory);
            });

            services.AddTransient <IBusConnection>(ctx => {
                var connFactory          = ctx.GetRequiredService <IConnectionFactory>();
                var persistentConnection = new RabbitPersistentConnection(connFactory);
                return(persistentConnection);
            });


            services.AddTransient <IHttpEventManager>(ctx => {
                var requestRepo      = ctx.GetRequiredService <IRequestResponseRepository>();
                var connection       = ctx.GetRequiredService <IBusConnection>();
                var httpEventManager = new HttpEventManager(requestRepo, connection);
                return(httpEventManager);
            });

            services.AddTransient <ISubscriber>(ctx => {
                var busConn    = ctx.GetRequiredService <IBusConnection>();
                var subscriber = new RabbitSubscriber(busConn);
                return(subscriber);
            });

            var channel = System.Threading.Channels.Channel.CreateBounded <RequestResponse>(100);

            services.AddSingleton(channel);

            services.AddTransient <IProducer>(ctx =>
            {
                var channel     = ctx.GetRequiredService <System.Threading.Channels.Channel <RequestResponse> >();
                var logger      = ctx.GetRequiredService <ILogger <RequestResponseProducer> >();
                var instance    = ctx.GetRequiredService <IHttpClientInstance>();
                var requestRepo = ctx.GetRequiredService <IRequestResponseRepository>();
                var eventRepo   = ctx.GetRequiredService <IHttpResponseEventRepository>();
                var producer    = new RequestResponseProducer(channel.Writer, logger, instance, eventRepo);
                return(producer);
            });

            services.AddTransient <IConsumer>(ctx =>
            {
                var channel  = ctx.GetRequiredService <System.Threading.Channels.Channel <RequestResponse> >();
                var logger   = ctx.GetRequiredService <ILogger <RequestResponseConsumer> >();
                var consumer = new RequestResponseConsumer(channel.Reader, logger, 1);
                return(consumer);
            });

            // DI'ing these as an IHostedService to automatically call the Start and Stop methods
            services.AddSingleton <IHostedService>(ctx =>
            {
                var logger                    = ctx.GetRequiredService <ILogger <BackgroundPublisherWorker> >();
                var httpEventManager          = ctx.GetRequiredService <IHttpEventManager>();
                var backgroundPublisherWorker = new BackgroundPublisherWorker(httpEventManager, logger);
                return(backgroundPublisherWorker);
            });

            services.AddSingleton <IHostedService>(ctx =>
            {
                var subscriber = ctx.GetRequiredService <ISubscriber>();
                var producer   = ctx.GetRequiredService <IProducer>();
                var consumer   = ctx.GetRequiredService <IConsumer>();
                var logger     = ctx.GetRequiredService <ILogger <BackgroundSubscriberWorker> >();
                var backgroundSubscriberWorker = new BackgroundSubscriberWorker(
                    subscriber, producer, new List <IConsumer>()
                {
                    consumer
                }, logger);
                return(backgroundSubscriberWorker);
            });

            //services.AddHostedService<BackgroundSubscriberWorker>(ctx =>
            //{
            //    var subscriber = ctx.GetRequiredService<ISubscriber>();
            //    var producer = ctx.GetRequiredService<IProducer>();
            //    var consumer = ctx.GetRequiredService<IConsumer>();
            //    var logger = ctx.GetRequiredService<ILogger<BackgroundSubscriberWorker>>();
            //    var backgroundSubscriberWorker = new BackgroundSubscriberWorker(
            //        subscriber, producer, new List<IConsumer>() { consumer }, logger);
            //    return backgroundSubscriberWorker;
            //});
        }
예제 #11
0
        public static string DoOTPGenerationWithoutCustomerRegistration(string requestStr)
        {
            Serializer          ser           = new Serializer();
            string              xmlOutputData = string.Empty;
            string              responseCode  = string.Empty;
            DateTime            requestTime   = DateTime.Now;
            GenerateOTPResponse objResp       = new GenerateOTPResponse();

            try
            {
                GenerateOTPRequestEx obj = ser.Deserialize <GenerateOTPRequestEx>(requestStr);
                if (obj != null)
                {
                    var mandate = MandateRepo.GetMandateByCode(obj.MandateCode);
                    if (mandate != null)
                    {
                        CentralPayOtp otp = new CentralPayOtp()
                        {
                            DateGenerated   = DateTime.Now,
                            IsUsed          = false,
                            MandateCodeId   = mandate.Id,
                            otp             = Utils.GenerateNewOtp(),
                            Amount          = Convert.ToDecimal(obj.Amount),
                            ReferenceNumber = Guid.NewGuid().ToString()
                        };

                        bool isSaved = MandateRepo.SaveCentralPayOtp(otp);

                        responseCode = isSaved ? ResponseCodeMap.Successful : ResponseCodeMap.UnknownError;

                        objResp = new GenerateOTPResponse
                        {
                            BankCode      = obj.BankCode,
                            BillerID      = obj.BillerID,
                            BillerName    = obj.BillerName,
                            BillerTransId = obj.BillerTransId,
                            MandateCode   = obj.MandateCode,
                            TransType     = obj.TransType,
                            ResponseCode  = responseCode
                        };
                    }
                    else
                    {
                        objResp = new GenerateOTPResponse {
                            ResponseCode = ResponseCodeMap.USerNotSetUp
                        };
                    }
                }
                else
                {
                    objResp = new GenerateOTPResponse {
                        ResponseCode = ResponseCodeMap.InvalidXml
                    };
                }

                xmlOutputData = ser.Serialize <GenerateOTPResponse>(objResp);
            }
            catch (Exception e) { ExceptionLogRepo.SaveExceptionLog(e);
                                  xmlOutputData = ser.Serialize <GenerateOTPResponse>(new GenerateOTPResponse {
                    ResponseCode = ResponseCodeMap.InvalidXml
                }); }
            DateTime responseTime = DateTime.Now;

            RequestResponseRepository.SaveRequestResponse("ASMX", requestStr, requestTime, "", xmlOutputData, responseTime);
            return(xmlOutputData);
        }
예제 #12
0
        public static string DoMandateCreation(string createMandateStr)
        {
            Serializer            ser           = new Serializer();
            string                xmlOutputData = string.Empty;
            string                responseCode  = string.Empty;
            DateTime              requestTime   = DateTime.Now;
            CreateMandateResponse objResp       = new CreateMandateResponse();

            try
            {
                CreateMandateRequest obj = ser.Deserialize <CreateMandateRequest>(createMandateStr);
                if (obj != null)
                {
                    if (!string.IsNullOrEmpty(obj.BillerID) || !string.IsNullOrEmpty(obj.BillerName) || !string.IsNullOrEmpty(obj.BillerTransId) || !string.IsNullOrEmpty(obj.AcctName) || !string.IsNullOrEmpty(obj.AcctNumber) || !string.IsNullOrEmpty(obj.BankCode))
                    {
                        MandateLog mlog = new MandateLog()
                        {
                            AccountName   = obj.AcctName,
                            BankCode      = obj.BankCode,
                            AccountNumber = obj.AcctNumber,
                            BillerId      = obj.BillerID,
                            BillerName    = obj.BillerName,
                            BillerTransId = obj.BillerTransId,
                            DateCreated   = DateTime.Now,
                            HashValue     = obj.HashValue,
                            TransType     = obj.TransType
                        };

                        bool isSaved = MandateRepo.SaveMandate(mlog);

                        responseCode = isSaved ? ResponseCodeMap.Successful : ResponseCodeMap.UnknownError;

                        objResp = new CreateMandateResponse
                        {
                            AcctName      = obj.AcctName,
                            AcctNumber    = obj.AcctNumber,
                            BankCode      = obj.BankCode,
                            BillerID      = obj.BillerID,
                            BillerName    = obj.BillerName,
                            BillerTransId = obj.BillerTransId,
                            MandateCode   = isSaved ? mlog.MandateCode : "",
                            TransType     = obj.TransType,
                            ResponseCode  = responseCode
                        };
                    }
                    else
                    {
                        objResp = new CreateMandateResponse {
                            ResponseCode = ResponseCodeMap.InvalidXml
                        };
                    }
                }
                else
                {
                    objResp = new CreateMandateResponse {
                        ResponseCode = ResponseCodeMap.InvalidXml
                    };
                }
                xmlOutputData = ser.Serialize <CreateMandateResponse>(objResp);
            }
            catch (Exception e)
            {
                ExceptionLogRepo.SaveExceptionLog(e);
                xmlOutputData = ser.Serialize <CreateMandateResponse>(new CreateMandateResponse {
                    ResponseCode = ResponseCodeMap.InvalidXml
                });
            }
            DateTime responseTime = DateTime.Now;

            RequestResponseRepository.SaveRequestResponse("ASMX", createMandateStr, requestTime, "", xmlOutputData, responseTime);
            return(xmlOutputData);
        }