示例#1
0
    public string validateBVNforForex(string applicantsBVN, string beneficiaryBVN)
    {
        RestServiceInvocator restServiceObj = new RestServiceInvocator();

        BVNRecord transObj = new BVNRecord()
        {
            bvnApplicant   = applicantsBVN, //"22222222280",
            bvnBeneficiary = beneficiaryBVN // "22222222280"
        };

        string pingResp = restServiceObj.validateBVNforForex(transObj);



        return(pingResp);
    }
示例#2
0
        public string createSingleCustomerAccount(BVNRecord transObj)
        {
            string nibbsurl = ConfigurationManager.AppSettings["nibbsurl"]; //"http://192.234.10.104:86/icadservice/api/accountmanager"; //pick this from config manager instead incase IP later changes, there will then be no need to recompile the sourcecode
            string username = ConfigurationManager.AppSettings["username"]; //"*****@*****.**"; //pick from config manager
            string pswd     = ConfigurationManager.AppSettings["password"]; //"KLKG+!xooYqlKi@!";

            string authorization = Gizmo.Base64Encode(username + ":" + pswd);

            string signatureDate = DateTime.Now.ToString("yyyyMMdd");


            string signatureString = username + signatureDate + pswd;

            string signature = Gizmo.GenerateSHA512String(signatureString);


            RestClient client = new RestClient(nibbsurl);

            ByPassProxy(client);



            var request = new RestRequest(Method.POST);

            string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            request.AddHeader("Accept", "text/plain");
            request.AddHeader("Content-Type", "text/plain");
            request.AddHeader("ContentType", "text/plain");
            request.AddHeader("Authorization", authorization);
            request.AddHeader("SIGNATURE", signature);
            request.AddHeader("SIGNATURE_METH", "SHA512");
            request.AddHeader("TIMESTAMP", timestamp);



            String key = ConfigurationManager.AppSettings["AESKey"]; //"OUGW5XNSc/82rXAr";
            String iv  = ConfigurationManager.AppSettings["IVKey"];  // "1BNEMKUJXi3svqFk";



            var json = new JavaScriptSerializer().Serialize(transObj);



            String encryptedRequest = AES.Encrypt(json.ToString(), key, iv);


            var requestBody = request.AddParameter("text/plain", encryptedRequest, ParameterType.RequestBody);



            String decryptedText = AES.Decrypt(encryptedRequest, key, iv);



            var response = client.Execute(request);


            // String decryptedText = AES.Decrypt(encryptedText, key, iv);
            //Console.WriteLine("Decrypted text :" + decryptedText);

            string innerResponse = "";
            string ResponseCode  = "";

            if (response.StatusCode.ToString() == "Created")
            {
                innerResponse = response.Headers[5].Value.ToString();
                ResponseCode  = response.Headers[10].Value.ToString();
            }
            else
            {
                innerResponse = response.Headers[4].Value.ToString();
                ResponseCode  = response.Headers[9].Value.ToString();
            }



            return(ResponseCode + "|" + innerResponse);
        }
示例#3
0
        public string validateBVNforForex(BVNRecord transObj)
        {
            string nibbsurl = ConfigurationManager.AppSettings["nibbsurlforvalidatebvn"]; //pick this from config manager instead incase IP later changes, there will then be no need to recompile the sourcecode
            string username = ConfigurationManager.AppSettings["username"];               //pick from config manager
            string pswd     = ConfigurationManager.AppSettings["password"];               //"KLKG+!xooYqlKi@!";

            string nipcodeforsterling = ConfigurationManager.AppSettings["nipcodeforsterling"];

            string authorization = Gizmo.Base64Encode(username + ":" + pswd);

            string signatureDate = DateTime.Now.ToString("yyyyMMdd");


            string signatureString = username + signatureDate + pswd;

            string signature = Gizmo.GenerateSHA512String(signatureString);


            RestClient client = new RestClient(nibbsurl);

            ByPassProxy(client);



            var request = new RestRequest(Method.POST);

            string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");

            request.AddHeader("Accept", "text/plain");
            request.AddHeader("Content-Type", "text/plain");
            request.AddHeader("InstitutionCode", nipcodeforsterling);
            request.AddHeader("ContentType", "text/plain");
            request.AddHeader("Authorization", authorization);
            request.AddHeader("SIGNATURE", signature);
            request.AddHeader("SIGNATURE_METH", "SHA512");
            request.AddHeader("TIMESTAMP", timestamp);



            String key = ConfigurationManager.AppSettings["AESKey"]; //"OUGW5XNSc/82rXAr";
            String iv  = ConfigurationManager.AppSettings["IVKey"];  // "1BNEMKUJXi3svqFk";



            var json = new JavaScriptSerializer().Serialize(transObj);



            String encryptedRequest = AES.Encrypt(json.ToString(), key, iv);


            var requestBody = request.AddParameter("text/plain", encryptedRequest, ParameterType.RequestBody);



            String decryptedText = AES.Decrypt(encryptedRequest, key, iv);



            var response = client.Execute(request);

            string bvnvalidationResponse = response.StatusCode + "|" + response.Content;

            string realResponseCode    = "";
            string realResponseContent = "";

            //return bvnvalidationResponse;

            try
            {
                try
                {
                    realResponseCode    = Convert.ToString(response.Headers.Where(x => x.Name == "error").SingleOrDefault().Value);
                    realResponseContent = Convert.ToString(response.Headers.Where(x => x.Name == "respData").SingleOrDefault().Value);
                }
                catch (Exception ex)
                {
                    realResponseCode    = response.StatusCode.ToString();
                    realResponseContent = response.Content;
                }
            }
            catch (Exception ex)
            {
                realResponseCode    = "-1";
                realResponseContent = "Error Receiving response from nibss service" + ex;
            }

            //when bvn is down
            //StatusCode NoCOntent


            return(realResponseCode + "|" + realResponseContent);

            // string responsecode = response.ResponseStatus.ToString();



            //string innerResponse = "";
            //string ResponseCode = "";

            //if (response.StatusCode.ToString() == "Created")
            //{
            //    innerResponse = response.Headers[5].Value.ToString();
            //    ResponseCode = response.Headers[10].Value.ToString();
            //}
            //else
            //{
            //    innerResponse = response.Headers[4].Value.ToString();
            //    ResponseCode = response.Headers[9].Value.ToString();
            //}



            //return ResponseCode + "|" + innerResponse;
        }